diff --git a/bird/parser.go b/bird/parser.go index 4533f59..aaf41e7 100644 --- a/bird/parser.go +++ b/bird/parser.go @@ -65,7 +65,7 @@ func init() { regex.routeCount.countRx = regexp.MustCompile(`^(\d+)\s+of\s+(\d+)\s+routes.*$`) regex.protocol.channel = regexp.MustCompile("Channel ipv([46])") - regex.protocol.protocol = regexp.MustCompile(`^(?:1002\-)?([^\s]+)\s+(BGP|Pipe|BFD|Direct|Device|Kernel)\s+([^\s]+)\s+([^\s]+)\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|[^\s]+)(?:\s+(.*))?$`) + regex.protocol.protocol = regexp.MustCompile(`^(?:1002\-)?([^\s]+)\s+(BGP|Pipe|BFD|Direct|Device|Kernel)\s+([^\s]+)\s+([^\s]+)\s+(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}|[^\s]+)(?:\s+(.*?)\s*)?$`) regex.protocol.numericValue = regexp.MustCompile(`^\s+([^:]+):\s+([\d]+)\s*$`) regex.protocol.routes = regexp.MustCompile(`^\s+Routes:\s+(.*)`) regex.protocol.stringValue = regexp.MustCompile(`^\s+([^:]+):\s+(.+)\s*$`) diff --git a/birdwatcher.go b/birdwatcher.go index 91c12a8..e0548e1 100644 --- a/birdwatcher.go +++ b/birdwatcher.go @@ -2,11 +2,9 @@ package main import ( "flag" - "fmt" "log" "net/http" "os" - "time" "strings" @@ -126,6 +124,8 @@ func (m *MyLogger) Write(p []byte) (n int, err error) { } func main() { + // Disable timestamps for the default logger, as they are generated by the syslog implementation + log.SetFlags(log.Flags() &^ (log.Ldate | log.Ltime)) bird6 := flag.Bool("6", false, "Use bird6 instead of bird") workerPoolSize := flag.Int("worker-pool-size", 8, "Number of go routines used to parse routing tables concurrently") configfile := flag.String("config", "/etc/birdwatcher/birdwatcher.conf", "Configuration file location") @@ -168,12 +168,10 @@ func main() { // Make server r := makeRouter(conf.Server) - // Set up our own custom log.Logger - // Use this weird golang format to imitate log.Logger's timestamp in log.Prefix() - ts := time.Now().Format("2006/01/02 15:04:05") - // set log prefix timestamp to our own custom prefix - log.SetPrefix(ts) - myquerylog := log.New(os.Stdout, fmt.Sprintf("%s %s: ", ts, "QUERY"), 0) + // Set up our own custom log.Logger without a prefix + myquerylog := log.New(os.Stdout, "", 0) + // Disable timestamps, as they are contained in the query log + myquerylog.SetFlags(myquerylog.Flags() &^ (log.Ldate | log.Ltime)) mylogger := &MyLogger{myquerylog} if conf.Server.EnableTLS { diff --git a/test/routes_bird2_ipv4.sample b/test/routes_bird2_ipv4.sample index 8a9c552..71d7ef3 100644 --- a/test/routes_bird2_ipv4.sample +++ b/test/routes_bird2_ipv4.sample @@ -19,7 +19,7 @@ BIRD 1.6.3 ready. BGP.community: (65011,40) (9033,3251) BGP.large_community: (9033, 65666, 12) (9033, 65666, 9) BGP.ext_community: (ro, 21414, 52001) (ro, 21414, 52004) (ro, 21414, 64515) - unicast [ID8503_AS1340 2017-06-21 08:17:33] (100/?) [AS1340i] + unicast [ID8503_AS1340 2017-06-21 08:17:33] (100/?) [AS1340i] via 1.2.3.16 on eno8 Type: BGP univ BGP.origin: IGP