Permalink
Browse files

Make log timestamps optional; new version

On systemd we had duplicated timestamps so they're optional now.
  • Loading branch information...
1 parent 7969483 commit 034015a8d7000084bf63bf12cc3410d714961289 @fiorix committed Mar 15, 2016
Showing with 12 additions and 4 deletions.
  1. +7 −1 apiserver/config.go
  2. +4 −2 apiserver/main.go
  3. +1 −1 cmd/freegeoip/ansible-playbook/freegeoip.yml
View
@@ -31,6 +31,7 @@ type Config struct {
UseXForwardedFor bool
Silent bool
LogToStdout bool
+ LogTimestamp bool
RedisAddr string
RedisTimeout time.Duration
MemcacheAddr string
@@ -57,6 +58,7 @@ func NewConfig() *Config {
DB: freegeoip.MaxMindDB,
UpdateInterval: 24 * time.Hour,
RetryInterval: 2 * time.Hour,
+ LogTimestamp: true,
RedisAddr: "localhost:6379",
RedisTimeout: time.Second,
MemcacheAddr: "localhost:11211",
@@ -83,6 +85,7 @@ func (c *Config) AddFlags(fs *flag.FlagSet) {
fs.BoolVar(&c.UseXForwardedFor, "use-x-forwarded-for", c.UseXForwardedFor, "Use the X-Forwarded-For header when available (e.g. behind proxy)")
fs.BoolVar(&c.Silent, "silent", c.Silent, "Disable HTTP and HTTPS log request details")
fs.BoolVar(&c.LogToStdout, "logtostdout", c.LogToStdout, "Log to stdout instead of stderr")
+ fs.BoolVar(&c.LogTimestamp, "logtimestamp", c.LogTimestamp, "Prefix non-access logs with timestamp")
fs.StringVar(&c.RedisAddr, "redis", c.RedisAddr, "Redis address in form of host:port[,host:port] for quota")
fs.DurationVar(&c.RedisTimeout, "redis-timeout", c.RedisTimeout, "Redis read/write timeout")
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 {
}
func (c *Config) errorLogger() *log.Logger {
- return log.New(c.logWriter(), "[error] ", log.LstdFlags)
+ if c.LogTimestamp {
+ return log.New(c.logWriter(), "[error] ", log.LstdFlags)
+ }
+ return log.New(c.logWriter(), "[error] ", 0)
}
func (c *Config) accessLogger() *log.Logger {
View
@@ -19,7 +19,7 @@ import (
)
// Version tag.
-var Version = "3.1.2"
+var Version = "3.1.3"
// Run is the entrypoint for the freegeoip server.
func Run() {
@@ -34,7 +34,9 @@ func Run() {
if c.LogToStdout {
log.SetOutput(os.Stdout)
}
- log.SetPrefix("[freegeoip] ")
+ if !c.LogTimestamp {
+ log.SetFlags(0)
+ }
f, err := NewHandler(c)
if err != nil {
log.Fatal(err)
@@ -10,7 +10,7 @@
- redis
vars:
nodeexporter_url: http://github.com/prometheus/node_exporter/releases/download/0.11.0/node_exporter-0.11.0.linux-amd64.tar.gz
- freegeoip_url: https://github.com/fiorix/freegeoip/releases/download/v3.1.2/freegeoip-3.1.2-linux-amd64.tar.gz
+ freegeoip_url: https://github.com/fiorix/freegeoip/releases/download/v3.1.3/freegeoip-3.1.3-linux-amd64.tar.gz
freegeoip_params:
- -http=:80
- -https=:443

0 comments on commit 034015a

Please sign in to comment.