产生的日志文件命令规则如下:
main.exe.XCL-PC.XCL-PC_XCL.log.WARNING.20150326-144521.10452程序名称.电脑名称.当前用户名.log.日志级别.YYYYMMDD-HHMMSS.pid号
program,
host,
userName,
tag,
t.Year(),
t.Month(),
t.Day(),
t.Hour(),
t.Minute(),
t.Second(),
pid
附测试用文件:
//glog使用例子
//glog: https://github.com/golang/glog
//author: Xiong Chuan Liang
//date: 2015-3-26
package main
import (
"flag"
"glog"
"os"
"test"
)
func main() {
flag.Parse()
p, err := os.Getwd()
if err != nil {
glog.Info("Getwd: ", err)
} else {
glog.Info("Getwd: ", p)
}
glog.Info("Prepare to repel boarders")
glog.Info("222222222222---log_backtrace_at")
glog.Info("333333333333")
glog.V(1).Infoln("Processed1", "nItems1", "elements1")
glog.V(2).Infoln("Processed2", "nItems2", "elements2")
glog.V(3).Infoln("Processed3", "nItems3", "elements3")
glog.V(4).Infoln("Processed4", "nItems4", "elements4")
glog.V(5).Infoln("Processed5", "nItems5", "elements5")
glog.Error("errrrr")
/*
if glog.V(2) {
glog.Info("Starting transaction...")
}
glog.V(2).Infoln("Processed", "nItems", "elements")
ch := make(chan int)
go func() {
for i := 0; i < 100; i++ {
glog.Info("info:", i)
}
ch <- 1
}()
<-ch
glog.Fatalf("Initialization failed: %s", errors.New("test info"))
*/
test.TestVmodule()
exit()
}
func exit() {
glog.Flush()
}
package test
import (
"glog"
)
func TestVmodule() {
glog.Info("test() 222222222222---log_backtrace_at")
glog.Info("test() 333333333333")
glog.V(1).Infoln("test() Processed1", "nItems1", "test() elements1")
glog.V(2).Infoln("test() Processed2", "nItems2", "test() elements2")
glog.V(3).Infoln("test()Processed3", "nItems3", "test() elements3")
glog.V(4).Infoln("test()Processed4", "nItems4", "test() elements4")
}
附部份测试命令:
MAIL : [email protected]
BLOG: http://blog.csdn.net/xcl168