mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-02-22 15:02:14 +08:00
docs: 手动实现 simple log 日志库
日志文件分割
This commit is contained in:
parent
f472470291
commit
851c81dd52
@ -73,7 +73,7 @@ func (l *Logger) PrintLog(level LogLevel, log string) {
|
||||
file := l.w.(*os.File)
|
||||
info, _ := file.Stat()
|
||||
currentSize := uint64(info.Size())
|
||||
if currentSize < l.splitSize {
|
||||
if l.splitSize == 0 || currentSize < l.splitSize {
|
||||
break
|
||||
} else {
|
||||
_ = file.Close()
|
||||
@ -193,7 +193,7 @@ func WithSplitSize(size uint64) OptionFunc {
|
||||
var defaultOption = &Option{
|
||||
Writer: os.Stdout,
|
||||
TimeFormat: "2006-01-02 15:04:05.99",
|
||||
LogFormat: "%-22s %s %v --- [%20s] : %s\n",
|
||||
LogFormat: "%-22s %-5s %v --- [%20s] : %s\n",
|
||||
LevelFlag: FlagInfo | FlagWarn | FlagError | FlagDebug,
|
||||
LogFile: "",
|
||||
SplitSize: 0,
|
||||
|
Loading…
Reference in New Issue
Block a user