Skip to content

Commit ce503ad

Browse files
committed
Add the option.NewFileLoggerOption function
1 parent 3a83d5e commit ce503ad

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

file_logger.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,7 @@ func NewFileLogger(lvl level.Level, logDir string, filePrefix string) (Logger, e
5555

5656
// NewFileLoggerWithAutoFlush get a file logger
5757
func NewFileLoggerWithAutoFlush(lvl level.Level, logDir string, filePrefix string, autoFlush bool, flushInterval time.Duration) (Logger, error) {
58-
return NewFileLoggerWithOption(option.FileLoggerOption{
59-
Level: lvl,
60-
LogDir: logDir,
61-
FilePrefix: filePrefix,
62-
AutoFlush: autoFlush,
63-
FlushInterval: flushInterval,
64-
})
58+
return NewFileLoggerWithOption(option.NewFileLoggerOption(lvl, logDir, filePrefix, autoFlush, flushInterval, false))
6559
}
6660

6761
// NewFileLoggerWithOption get a file logger with option

option/file_logger_option.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,15 @@ type FileLoggerOption struct {
1515
FlushInterval time.Duration
1616
SplitDate bool
1717
}
18+
19+
// NewFileLoggerOption returns an instance of the FileLoggerOption
20+
func NewFileLoggerOption(lvl level.Level, logDir string, filePrefix string, autoFlush bool, flushInterval time.Duration, splitDate bool) FileLoggerOption {
21+
return FileLoggerOption{
22+
Level: lvl,
23+
LogDir: logDir,
24+
FilePrefix: filePrefix,
25+
AutoFlush: autoFlush,
26+
FlushInterval: flushInterval,
27+
SplitDate: splitDate,
28+
}
29+
}

0 commit comments

Comments
 (0)