docs: 手动实现 simple log 日志库

日志文件分割
This commit is contained in:
Shikong 2021-10-07 00:18:50 +08:00
parent f472470291
commit 851c81dd52

View File

@ -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,