From 099c98402f89c2d7be3eead848ce083f1d6ca308 Mon Sep 17 00:00:00 2001 From: shanks Date: Tue, 27 Oct 2015 10:47:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=BB=E6=8E=89=E5=91=BD=E4=BB=A4=E8=A1=8C?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20flushInterval,=E7=BC=93=E5=AD=98=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E6=97=B6=E9=97=B4=E6=94=B9=E4=B8=BA5s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- glog.go | 3 +-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index f43abf1f9..20b976e3e 100644 --- a/README.md +++ b/README.md @@ -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 ##使用示例 ``` @@ -30,5 +30,5 @@ func main() { } //假设编译后的可执行程序名为demo,运行时指定log_dir参数将日志文件保存到特定的目录 -// ./demo --log_dir=./log --dailyRolling=true --flushInterval=5s +// ./demo --log_dir=./log --dailyRolling=true ``` diff --git a/glog.go b/glog.go index 1715f9af0..4424bacd1 100644 --- a/glog.go +++ b/glog.go @@ -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") @@ -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() {