diff options
author | Steve Shaw <shaw38@gmail.com> | 2020-10-21 13:25:38 -0400 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2020-11-06 21:15:10 +0900 |
commit | 393d82f955cf432fb41871275566e16fc7992e3e (patch) | |
tree | 3e5725c51f15264c96f8505d7d33b50436030b3a /pkg | |
parent | 01aa3f287bd41a3351396a303e60219b12a15475 (diff) |
Adding gRPC support for modified logging level
Signed-off-by: Steve Shaw <shaw38@gmail.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/server/grpc_server.go | 4 | ||||
-rw-r--r-- | pkg/server/server.go | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/pkg/server/grpc_server.go b/pkg/server/grpc_server.go index a9f621fb..25c8495e 100644 --- a/pkg/server/grpc_server.go +++ b/pkg/server/grpc_server.go @@ -1772,3 +1772,7 @@ func (s *server) StopBgp(ctx context.Context, r *api.StopBgpRequest) (*empty.Emp func (s *server) GetTable(ctx context.Context, r *api.GetTableRequest) (*api.GetTableResponse, error) { return s.bgpServer.GetTable(ctx, r) } + +func (s *server) SetLogLevel(ctx context.Context, r *api.SetLogLevelRequest) (*empty.Empty, error) { + return &empty.Empty{}, s.bgpServer.SetLogLevel(ctx, r) +} diff --git a/pkg/server/server.go b/pkg/server/server.go index ee58585f..5971bc6d 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -3796,6 +3796,22 @@ func (s *BgpServer) MonitorPeer(ctx context.Context, r *api.MonitorPeerRequest, return nil } +func (s *BgpServer) SetLogLevel(ctx context.Context, r *api.SetLogLevelRequest) error { + prevLevel := log.GetLevel() + newLevel := log.Level(r.Level) + if prevLevel == newLevel { + log.WithFields(log.Fields{ + "Topic": "Config", + }).Infof("Logging level unchanged -- level already set to %v", newLevel) + } else { + log.SetLevel(newLevel) + log.WithFields(log.Fields{ + "Topic": "Config", + }).Infof("Logging level changed -- prev: %v, new: %v", prevLevel, newLevel) + } + return nil +} + type watchEventType string const ( |