summaryrefslogtreecommitdiffhomepage
path: root/server/collector.go
diff options
context:
space:
mode:
authordsp <dsp@2f30.org>2016-07-30 14:16:48 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-07-30 12:17:37 +0900
commitc4fe45902e736a858c4870bcab01c9143551f696 (patch)
treecbc45786d584fd98c1fb55851f2200bea938c909 /server/collector.go
parentbb15c18402ffcb5beb60aa61cfdc57577633f234 (diff)
all logging is done with log.WithFields
Signed-off-by: dsp <dsp@2f30.org> Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'server/collector.go')
-rw-r--r--server/collector.go13
1 files changed, 7 insertions, 6 deletions
diff --git a/server/collector.go b/server/collector.go
index 583a1999..59f945be 100644
--- a/server/collector.go
+++ b/server/collector.go
@@ -111,11 +111,11 @@ func path2data(path *table.Path) (map[string]interface{}, map[string]string) {
}
if err := bgp.FlatUpdate(tags, path.GetNlri().Flat()); err != nil {
- log.Error(err)
+ log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("NLRI FlatUpdate failed")
}
for _, p := range path.GetPathAttrs() {
if err := bgp.FlatUpdate(tags, p.Flat()); err != nil {
- log.Error(err)
+ log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("PathAttr FlatUpdate failed")
}
}
return fields, tags
@@ -173,15 +173,15 @@ func (c *Collector) loop() {
switch msg := ev.(type) {
case *WatchEventUpdate:
if err := c.writeUpdate(msg); err != nil {
- log.Error(err)
+ log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to write update event message")
}
case *WatchEventPeerState:
if err := c.writePeer(msg); err != nil {
- log.Error(err)
+ log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to write state changed event message")
}
case *WatchEventAdjIn:
if err := c.writeTable(msg); err != nil {
- log.Error(err)
+ log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to write Adj-In event message")
}
}
}
@@ -199,12 +199,13 @@ func NewCollector(s *BgpServer, url, dbName string, interval uint64) (*Collector
_, _, err = c.Ping(0)
if err != nil {
log.Error("can not connect to InfluxDB")
+ log.WithFields(log.Fields{"Type": "collector", "Error": err}).Error("Failed to connect to InfluxDB")
return nil, err
}
q := client.NewQuery("CREATE DATABASE "+dbName, "", "")
if response, err := c.Query(q); err != nil || response.Error() != nil {
- log.Error("can not create database " + dbName)
+ log.WithFields(log.Fields{"Type": "collector", "Error": err}).Errorf("Failed to create database:%s", dbName)
return nil, err
}