diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-08 23:09:26 +0900 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-09-10 13:58:26 +0900 |
commit | ba3a7ddb02855ffdf799a65c4cad7d75909a1371 (patch) | |
tree | cc3ce109cf39429ea7a02133c9641e9d5f0894b5 /table/path.go | |
parent | dae5f4eee235bfa6c81d76d1bf54889e50e7a51d (diff) |
table: add string method for easier debugging
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'table/path.go')
-rw-r--r-- | table/path.go | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/table/path.go b/table/path.go index 386d39c3..22a068eb 100644 --- a/table/path.go +++ b/table/path.go @@ -297,11 +297,15 @@ func (path *Path) getPathAttr(pattrType bgp.BGPAttrType) (int, bgp.PathAttribute // return Path's string representation func (path *Path) String() string { - str := fmt.Sprintf("Source: %v, ", path.GetSource()) - str += fmt.Sprintf(" NLRI: %s, ", path.getPrefix()) - str += fmt.Sprintf(" nexthop: %s, ", path.GetNexthop()) - str += fmt.Sprintf(" withdraw: %s, ", path.IsWithdraw) - return str + s := bytes.NewBuffer(make([]byte, 0, 64)) + s.WriteString(fmt.Sprintf("{ %s | ", path.getPrefix())) + s.WriteString(fmt.Sprintf("src: %s", path.GetSource())) + s.WriteString(fmt.Sprintf(", nh: %s", path.GetNexthop())) + if path.IsWithdraw { + s.WriteString(", withdraw") + } + s.WriteString(" }") + return s.String() } func (path *Path) getPrefix() string { |