Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
alex cai committed Nov 3, 2016
1 parent 1877ee9 commit e47baa0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions level.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ const (
var (
// 日志等级
levelTitle = map[Priority]string{
LevelDebug: "DEBUG",
LevelInfo: "INFO",
LevelWarn: "WARN",
LevelError: "ERROR",
LevelFatal: "FATAL",
LevelDebug: "[DEBUG]",
LevelInfo: "[INFO]",
LevelWarn: "[WARN]",
LevelError: "[ERROR]",
LevelFatal: "[FATAL]",
}
)

Expand Down Expand Up @@ -55,7 +55,7 @@ func (lf *LogFile) Fatal(msg string) error {

func (lf *LogFile) writeLevelMsg(msg string, level Priority) error {
if level >= lf.level {
return lf.Write("[" + levelTitle[level] + "] " + msg)
return lf.Write(levelTitle[level] + msg)
}

return nil
Expand Down
4 changes: 2 additions & 2 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ func (lf *LogFile) flush() error {
// 获取文件名的后缀
func (lf *LogFile) getFilenameSuffix() string {
if lf.logRotate.rotate == RotateDate {
return time.Now().Local().Format("20060102")
return time.Now().Format("20060102")
}
return time.Now().Local().Format("2006010215")
return time.Now().Format("2006010215")
}

// 直接写入日志文件
Expand Down

0 comments on commit e47baa0

Please sign in to comment.