Skip to content

Commit

Permalink
Add the option.NewFileLoggerOption function
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev committed Oct 19, 2022
1 parent 3a83d5e commit ce503ad
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 1 addition & 7 deletions file_logger.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,7 @@ func NewFileLogger(lvl level.Level, logDir string, filePrefix string) (Logger, e

// NewFileLoggerWithAutoFlush get a file logger
func NewFileLoggerWithAutoFlush(lvl level.Level, logDir string, filePrefix string, autoFlush bool, flushInterval time.Duration) (Logger, error) {
return NewFileLoggerWithOption(option.FileLoggerOption{
Level: lvl,
LogDir: logDir,
FilePrefix: filePrefix,
AutoFlush: autoFlush,
FlushInterval: flushInterval,
})
return NewFileLoggerWithOption(option.NewFileLoggerOption(lvl, logDir, filePrefix, autoFlush, flushInterval, false))
}

// NewFileLoggerWithOption get a file logger with option
Expand Down
12 changes: 12 additions & 0 deletions option/file_logger_option.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,15 @@ type FileLoggerOption struct {
FlushInterval time.Duration
SplitDate bool
}

// NewFileLoggerOption returns an instance of the FileLoggerOption
func NewFileLoggerOption(lvl level.Level, logDir string, filePrefix string, autoFlush bool, flushInterval time.Duration, splitDate bool) FileLoggerOption {
return FileLoggerOption{
Level: lvl,
LogDir: logDir,
FilePrefix: filePrefix,
AutoFlush: autoFlush,
FlushInterval: flushInterval,
SplitDate: splitDate,
}
}

0 comments on commit ce503ad

Please sign in to comment.