mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-31 15:19:45 +07:00
feat/chore: add log file/refine code/add tip for no-load (#219)
This commit is contained in:
@ -8,9 +8,10 @@ package logger
|
||||
import (
|
||||
"github.com/sirupsen/logrus"
|
||||
prefixed "github.com/x-cray/logrus-prefixed-formatter"
|
||||
"gopkg.in/natefinch/lumberjack.v2"
|
||||
)
|
||||
|
||||
func NewLogger(logLevel string, disableTimestamp bool) *logrus.Logger {
|
||||
func NewLogger(logLevel string, disableTimestamp bool, logFileOpt *lumberjack.Logger) *logrus.Logger {
|
||||
log := logrus.New()
|
||||
|
||||
level, err := logrus.ParseLevel(logLevel)
|
||||
@ -24,6 +25,9 @@ func NewLogger(logLevel string, disableTimestamp bool) *logrus.Logger {
|
||||
FullTimestamp: true,
|
||||
TimestampFormat: "Jan 02 15:04:05",
|
||||
})
|
||||
if logFileOpt != nil {
|
||||
log.SetOutput(logFileOpt)
|
||||
}
|
||||
|
||||
return log
|
||||
}
|
||||
|
Reference in New Issue
Block a user