@@ -31,6 +31,7 @@ type Config struct {
3131 UseXForwardedFor bool
3232 Silent bool
3333 LogToStdout bool
34+ LogTimestamp bool
3435 RedisAddr string
3536 RedisTimeout time.Duration
3637 MemcacheAddr string
@@ -57,6 +58,7 @@ func NewConfig() *Config {
5758 DB : freegeoip .MaxMindDB ,
5859 UpdateInterval : 24 * time .Hour ,
5960 RetryInterval : 2 * time .Hour ,
61+ LogTimestamp : true ,
6062 RedisAddr : "localhost:6379" ,
6163 RedisTimeout : time .Second ,
6264 MemcacheAddr : "localhost:11211" ,
@@ -83,6 +85,7 @@ func (c *Config) AddFlags(fs *flag.FlagSet) {
8385 fs .BoolVar (& c .UseXForwardedFor , "use-x-forwarded-for" , c .UseXForwardedFor , "Use the X-Forwarded-For header when available (e.g. behind proxy)" )
8486 fs .BoolVar (& c .Silent , "silent" , c .Silent , "Disable HTTP and HTTPS log request details" )
8587 fs .BoolVar (& c .LogToStdout , "logtostdout" , c .LogToStdout , "Log to stdout instead of stderr" )
88+ fs .BoolVar (& c .LogTimestamp , "logtimestamp" , c .LogTimestamp , "Prefix non-access logs with timestamp" )
8689 fs .StringVar (& c .RedisAddr , "redis" , c .RedisAddr , "Redis address in form of host:port[,host:port] for quota" )
8790 fs .DurationVar (& c .RedisTimeout , "redis-timeout" , c .RedisTimeout , "Redis read/write timeout" )
8891 fs .StringVar (& c .MemcacheAddr , "memcache" , c .MemcacheAddr , "Memcache address in form of host:port[,host:port] for quota" )
@@ -101,7 +104,10 @@ func (c *Config) logWriter() io.Writer {
101104}
102105
103106func (c * Config ) errorLogger () * log.Logger {
104- return log .New (c .logWriter (), "[error] " , log .LstdFlags )
107+ if c .LogTimestamp {
108+ return log .New (c .logWriter (), "[error] " , log .LstdFlags )
109+ }
110+ return log .New (c .logWriter (), "[error] " , 0 )
105111}
106112
107113func (c * Config ) accessLogger () * log.Logger {
0 commit comments