summaryrefslogtreecommitdiffhomepage
path: root/table/table_manager.go
diff options
context:
space:
mode:
authorFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-22 04:33:09 -0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2014-12-22 04:33:09 -0800
commit6ecf5e15ceda5e8535727d16a3d04e35cb7f51d0 (patch)
treeb69464e974cc00cab9dadd5c1b8a6c66e5cf13b1 /table/table_manager.go
parentd2bbac0697bfdbf6395172163cd0d171bb196246 (diff)
clean up logger usage
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'table/table_manager.go')
-rw-r--r--table/table_manager.go32
1 files changed, 10 insertions, 22 deletions
diff --git a/table/table_manager.go b/table/table_manager.go
index 4a71bf6f..c6b15543 100644
--- a/table/table_manager.go
+++ b/table/table_manager.go
@@ -18,17 +18,9 @@ package table
import (
log "github.com/Sirupsen/logrus"
"github.com/osrg/gobgp/packet"
- "os"
"time"
)
-var logger *log.Logger = &log.Logger{
- Out: os.Stderr,
- Formatter: new(log.JSONFormatter),
- Hooks: make(map[log.Level][]log.Hook),
- Level: log.InfoLevel,
-}
-
type RouteFamily int
const (
@@ -230,22 +222,18 @@ func NewTableManager() *TableManager {
return t
}
-func setLogger(loggerInstance *log.Logger) {
- logger = loggerInstance
-}
-
func (manager *TableManager) calculate(destinationList []Destination) ([]Path, []Destination, error) {
bestPaths := make([]Path, 0)
lostDest := make([]Destination, 0)
for _, destination := range destinationList {
// compute best path
- logger.Infof("Processing destination: %v", destination.String())
+ log.Infof("Processing destination: %v", destination.String())
newBestPath, reason, err := destination.Calculate(manager.localAsn)
- logger.Debugf("new best path: %v, reason=%v", newBestPath, reason)
+ log.Debugf("new best path: %v, reason=%v", newBestPath, reason)
if err != nil {
- logger.Error(err)
+ log.Error(err)
continue
}
@@ -254,25 +242,25 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [
if newBestPath != nil && currentBestPath == newBestPath {
// best path is not changed
- logger.Debug("best path is not changed")
+ log.Debug("best path is not changed")
continue
}
if newBestPath == nil {
- logger.Debug("best path is nil")
+ log.Debug("best path is nil")
if len(destination.getKnownPathList()) == 0 {
// create withdraw path
if currentBestPath != nil {
- logger.Debug("best path is lost")
+ log.Debug("best path is lost")
destination.setOldBestPath(destination.getBestPath())
lostDest = append(lostDest, destination)
}
destination.setBestPath(nil)
} else {
- logger.Error("known path list is not empty")
+ log.Error("known path list is not empty")
}
} else {
- logger.Debugf("new best path: NLRI: %v, next_hop=%v, reason=%v",
+ log.Debugf("new best path: NLRI: %v, next_hop=%v, reason=%v",
newBestPath.getPrefix().String(),
newBestPath.getNexthop().String(),
reason)
@@ -285,7 +273,7 @@ func (manager *TableManager) calculate(destinationList []Destination) ([]Path, [
rf := destination.getRouteFamily()
t := manager.Tables[rf]
deleteDest(t, destination)
- logger.Debugf("destination removed route_family=%v, destination=%v", rf, destination)
+ log.Debugf("destination removed route_family=%v, destination=%v", rf, destination)
}
}
return bestPaths, lostDest, nil
@@ -315,7 +303,7 @@ func (manager *TableManager) ProcessUpdate(fromPeer *PeerInfo, message *bgp.BGPM
// check msg's type if it's BGPUpdate
if message.Header.Type != bgp.BGP_MSG_UPDATE {
- logger.Warn("message is not BGPUpdate")
+ log.Warn("message is not BGPUpdate")
return bestPaths, lostDest, nil
}