Skip to content

Commit

Permalink
去掉命令行参数 flushInterval,缓存刷新时间改为5s
Browse files Browse the repository at this point in the history
  • Loading branch information
shanks committed Oct 27, 2015
1 parent 1b6469c commit 099c984
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
glog
====

项目在[golang/glog](https://github.com/golang/glog)的基础上做了一些修改。
[golang/glog](https://github.com/golang/glog)的基础上做了一些修改。

## 修改的地方:
1. 增加每天切割日志文件的功能,程序运行时指定 --dailyRolling=true参数即可
2. 将日志等级由原来的INFO WARN ERROR FATAL 改为DEBUG INFO ERROR FATAL
2. 将日志等级由原来的INFO WARN ERROR FATAL改为DEBUG INFO ERROR FATAL
3. 增加日志输出等级设置,当日志信息等级低于输出等级时则不输出日志信息
4. 增加命令行参数 flushInterval 可以自定义日志缓存同步到磁盘文件的时间间隔,原程序为固定的30s
4. 将默认的刷新缓冲区时间由20s改为5s

##使用示例
```
Expand All @@ -30,5 +30,5 @@ func main() {
}
//假设编译后的可执行程序名为demo,运行时指定log_dir参数将日志文件保存到特定的目录
// ./demo --log_dir=./log --dailyRolling=true --flushInterval=5s
// ./demo --log_dir=./log --dailyRolling=true
```
3 changes: 1 addition & 2 deletions glog.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,6 @@ func init() {
flag.BoolVar(&logging.toStderr, "logtostderr", false, "log to standard error instead of files")
flag.BoolVar(&logging.dailyRolling, "dailyRolling", false, " weather to handle log files daily")
flag.BoolVar(&logging.alsoToStderr, "alsologtostderr", false, "log to standard error as well as files")
flag.DurationVar(&flushInterval, "flushInterval", 30*time.Second, "specify the interval to flush")
flag.Var(&logging.verbosity, "v", "log level for V logs")
flag.Var(&logging.stderrThreshold, "stderrthreshold", "logs at or above this threshold go to stderr")
flag.Var(&logging.vmodule, "vmodule", "comma-separated list of pattern=N settings for file-filtered logging")
Expand Down Expand Up @@ -914,7 +913,7 @@ func (l *loggingT) createFiles(sev severity) error {
return nil
}

var flushInterval = 30 * time.Second
var flushInterval time.Duration = 5 * time.Second

// flushDaemon periodically flushes the log file buffers.
func (l *loggingT) flushDaemon() {
Expand Down

0 comments on commit 099c984

Please sign in to comment.