Make debug ops a bit safer

This commit is contained in:
Viktor Liu
2025-01-16 20:28:38 +01:00
parent 21a3679590
commit 9b5c0439e9
2 changed files with 21 additions and 8 deletions

View File

@@ -496,11 +496,20 @@ func (s *Server) SetLogLevel(_ context.Context, req *proto.SetLogLevelRequest) (
log.SetLevel(level)
if s.connectClient != nil &&
s.connectClient.Engine() != nil &&
s.connectClient.Engine().GetFirewallManager() != nil {
s.connectClient.Engine().GetFirewallManager().SetLogLevel(level)
if s.connectClient == nil {
return nil, fmt.Errorf("connect client not initialized")
}
engine := s.connectClient.Engine()
if engine == nil {
return nil, fmt.Errorf("engine not initialized")
}
fwManager := engine.GetFirewallManager()
if fwManager == nil {
return nil, fmt.Errorf("firewall manager not initialized")
}
fwManager.SetLogLevel(level)
log.Infof("Log level set to %s", level.String())