parent
cceb044a02
commit
2e1b502463
5 changed files with 40 additions and 16 deletions
|
@ -171,7 +171,7 @@ var (
|
|||
// If logPath is configured -- function creates a dir and a file for logging.
|
||||
// If logPath is configured on Windows -- function returns closer to be
|
||||
// able to close sink for the opened log output file.
|
||||
func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.Logger, func() error, error) {
|
||||
func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.Logger, *zap.AtomicLevel, func() error, error) {
|
||||
var (
|
||||
level = zapcore.InfoLevel
|
||||
err error
|
||||
|
@ -179,7 +179,7 @@ func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.
|
|||
if len(cfg.LogLevel) > 0 {
|
||||
level, err = zapcore.ParseLevel(cfg.LogLevel)
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("log setting: %w", err)
|
||||
return nil, nil, nil, fmt.Errorf("log setting: %w", err)
|
||||
}
|
||||
}
|
||||
if debug {
|
||||
|
@ -198,7 +198,7 @@ func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.
|
|||
|
||||
if logPath := cfg.LogPath; logPath != "" {
|
||||
if err := io.MakeDirForFile(logPath, "logger"); err != nil {
|
||||
return nil, nil, err
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
|
||||
if runtime.GOOS == "windows" {
|
||||
|
@ -236,7 +236,7 @@ func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.
|
|||
return f, err
|
||||
})
|
||||
if err != nil {
|
||||
return nil, nil, fmt.Errorf("failed to register windows-specific sinc: %w", err)
|
||||
return nil, nil, nil, fmt.Errorf("failed to register windows-specific sinc: %w", err)
|
||||
}
|
||||
_winfileSinkRegistered = true
|
||||
}
|
||||
|
@ -247,5 +247,5 @@ func HandleLoggingParams(debug bool, cfg config.ApplicationConfiguration) (*zap.
|
|||
}
|
||||
|
||||
log, err := cc.Build()
|
||||
return log, _winfileSinkCloser, err
|
||||
return log, &cc.Level, _winfileSinkCloser, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue