make log folder optional
This commit is contained in:
parent
4f97fc125f
commit
e2a465b4df
1 changed files with 10 additions and 9 deletions
|
|
@ -11,6 +11,7 @@ var Log = logrus.New()
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
Log.SetOutput(os.Stdout)
|
Log.SetOutput(os.Stdout)
|
||||||
|
if os.Getenv("LOG_FOLDER") != "" {
|
||||||
Log.AddHook(&LumberjackHook{
|
Log.AddHook(&LumberjackHook{
|
||||||
Logger: &lumberjack.Logger{
|
Logger: &lumberjack.Logger{
|
||||||
Filename: os.Getenv("LOG_FOLDER") + "/application.log",
|
Filename: os.Getenv("LOG_FOLDER") + "/application.log",
|
||||||
|
|
@ -19,6 +20,7 @@ func Init() {
|
||||||
MaxAge: 28, // Max age in days to keep a log file
|
MaxAge: 28, // Max age in days to keep a log file
|
||||||
Compress: true, // Compress old log files
|
Compress: true, // Compress old log files
|
||||||
}})
|
}})
|
||||||
|
}
|
||||||
|
|
||||||
if os.Getenv("LOG_LEVEL") == "" {
|
if os.Getenv("LOG_LEVEL") == "" {
|
||||||
Log.SetLevel(logrus.InfoLevel)
|
Log.SetLevel(logrus.InfoLevel)
|
||||||
|
|
@ -39,4 +41,3 @@ func Init() {
|
||||||
})
|
})
|
||||||
Log.Infof("Logger initialized with %s log level", Log.Level)
|
Log.Infof("Logger initialized with %s log level", Log.Level)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue