outpost: improve logging
This commit is contained in:
parent
cb73210447
commit
f3ccb5341d
|
@ -427,6 +427,7 @@ _LOGGING_HANDLER_MAP = {
|
|||
"dbbackup": "ERROR",
|
||||
"kubernetes": "INFO",
|
||||
"asyncio": "WARNING",
|
||||
"aioredis": "WARNING",
|
||||
}
|
||||
for handler_name, level in _LOGGING_HANDLER_MAP.items():
|
||||
# pyright: reportGeneralTypeIssues=false
|
||||
|
|
|
@ -70,10 +70,11 @@ func (ac *APIController) Shutdown() {
|
|||
|
||||
func (ac *APIController) startWSHandler() {
|
||||
notConnectedBackoff := 1
|
||||
logger := ac.logger.WithField("loop", "ws-handler")
|
||||
for {
|
||||
if !ac.wsConn.IsConnected() {
|
||||
notConnectedWait := time.Duration(notConnectedBackoff) * time.Second
|
||||
ac.logger.WithField("loop", "ws-handler").WithField("wait", notConnectedWait).Info("Not connected, trying again...")
|
||||
logger.WithField("wait", notConnectedWait).Info("Not connected, trying again...")
|
||||
time.Sleep(notConnectedWait)
|
||||
notConnectedBackoff += notConnectedBackoff
|
||||
continue
|
||||
|
@ -81,15 +82,16 @@ func (ac *APIController) startWSHandler() {
|
|||
var wsMsg websocketMessage
|
||||
err := ac.wsConn.ReadJSON(&wsMsg)
|
||||
if err != nil {
|
||||
ac.logger.WithField("loop", "ws-handler").Println("read:", err)
|
||||
logger.Println("read:", err)
|
||||
ac.wsConn.CloseAndReconnect()
|
||||
continue
|
||||
}
|
||||
if wsMsg.Instruction == WebsocketInstructionTriggerUpdate {
|
||||
time.Sleep(ac.reloadOffset)
|
||||
logger.Debug("Got update trigger...")
|
||||
err := ac.Server.Refresh()
|
||||
if err != nil {
|
||||
ac.logger.WithField("loop", "ws-handler").WithError(err).Debug("Failed to update")
|
||||
logger.WithError(err).Debug("Failed to update")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue