mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-02-23 07:22:16 +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)
|
file := l.w.(*os.File)
|
||||||
info, _ := file.Stat()
|
info, _ := file.Stat()
|
||||||
currentSize := uint64(info.Size())
|
currentSize := uint64(info.Size())
|
||||||
if currentSize < l.splitSize {
|
if l.splitSize == 0 || currentSize < l.splitSize {
|
||||||
break
|
break
|
||||||
} else {
|
} else {
|
||||||
_ = file.Close()
|
_ = file.Close()
|
||||||
@ -193,7 +193,7 @@ func WithSplitSize(size uint64) OptionFunc {
|
|||||||
var defaultOption = &Option{
|
var defaultOption = &Option{
|
||||||
Writer: os.Stdout,
|
Writer: os.Stdout,
|
||||||
TimeFormat: "2006-01-02 15:04:05.99",
|
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,
|
LevelFlag: FlagInfo | FlagWarn | FlagError | FlagDebug,
|
||||||
LogFile: "",
|
LogFile: "",
|
||||||
SplitSize: 0,
|
SplitSize: 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user