Skip to content

Commit

Permalink
优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
alex cai committed Nov 4, 2016
1 parent e47baa0 commit 06680d8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions log.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ const (
cacheInitCap = 64
)

// 是否需要Flag信息
const (
NoFlag = 0
StdFlag = log.LstdFlags
)

// 异步日志变量
var asyncLog *asyncLogType

Expand Down Expand Up @@ -110,7 +116,7 @@ func NewLogFile(filename string) *LogFile {

lf := &LogFile{
filename: filename,
flag: log.LstdFlags,
flag: StdFlag,
}

// 默认按小时切割文件
Expand Down Expand Up @@ -140,7 +146,7 @@ func (lf *LogFile) SetUseCache(useCache bool) {

// 写缓存
func (lf *LogFile) Write(msg string) error {
if lf.flag == log.LstdFlags {
if lf.flag == StdFlag {
msg = time.Now().Format(logTimeFormat) + " " + msg + newlineChar
} else {
msg = msg + newlineChar
Expand Down

0 comments on commit 06680d8

Please sign in to comment.