Skip to content

Commit 0351ec2

Browse files
authored
Update log.go
bug-fix: loop updating Logger instance options before setting logFileDir,EncodeTime etc....
1 parent 915fd28 commit 0351ec2

File tree

1 file changed

+3
-3
lines changed
  • all_packaged_library/logtool

1 file changed

+3
-3
lines changed

all_packaged_library/logtool/log.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ func NewLogger(mod ...ModOptions) *zap.Logger {
6363
MaxBackups: 60,
6464
MaxAge: 30,
6565
}
66+
for _, fn := range mod {
67+
fn(l.Opts)
68+
}
6669
if l.Opts.LogFileDir == "" {
6770
l.Opts.LogFileDir, _ = filepath.Abs(filepath.Dir(filepath.Join(".")))
6871
l.Opts.LogFileDir += sp + "logs" + sp
@@ -80,9 +83,6 @@ func NewLogger(mod ...ModOptions) *zap.Logger {
8083
if l.Opts.ErrorOutputPaths == nil || len(l.Opts.ErrorOutputPaths) == 0 {
8184
l.zapConfig.OutputPaths = []string{"stderr"}
8285
}
83-
for _, fn := range mod {
84-
fn(l.Opts)
85-
}
8686
l.zapConfig.Level.SetLevel(l.Opts.Level)
8787
l.init()
8888
l.inited = true

0 commit comments

Comments
 (0)