outpost: improve logging
This commit is contained in:
		| @ -427,6 +427,7 @@ _LOGGING_HANDLER_MAP = { | |||||||
|     "dbbackup": "ERROR", |     "dbbackup": "ERROR", | ||||||
|     "kubernetes": "INFO", |     "kubernetes": "INFO", | ||||||
|     "asyncio": "WARNING", |     "asyncio": "WARNING", | ||||||
|  |     "aioredis": "WARNING", | ||||||
| } | } | ||||||
| for handler_name, level in _LOGGING_HANDLER_MAP.items(): | for handler_name, level in _LOGGING_HANDLER_MAP.items(): | ||||||
|     # pyright: reportGeneralTypeIssues=false |     # pyright: reportGeneralTypeIssues=false | ||||||
|  | |||||||
| @ -70,10 +70,11 @@ func (ac *APIController) Shutdown() { | |||||||
|  |  | ||||||
| func (ac *APIController) startWSHandler() { | func (ac *APIController) startWSHandler() { | ||||||
| 	notConnectedBackoff := 1 | 	notConnectedBackoff := 1 | ||||||
|  | 	logger := ac.logger.WithField("loop", "ws-handler") | ||||||
| 	for { | 	for { | ||||||
| 		if !ac.wsConn.IsConnected() { | 		if !ac.wsConn.IsConnected() { | ||||||
| 			notConnectedWait := time.Duration(notConnectedBackoff) * time.Second | 			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) | 			time.Sleep(notConnectedWait) | ||||||
| 			notConnectedBackoff += notConnectedBackoff | 			notConnectedBackoff += notConnectedBackoff | ||||||
| 			continue | 			continue | ||||||
| @ -81,15 +82,16 @@ func (ac *APIController) startWSHandler() { | |||||||
| 		var wsMsg websocketMessage | 		var wsMsg websocketMessage | ||||||
| 		err := ac.wsConn.ReadJSON(&wsMsg) | 		err := ac.wsConn.ReadJSON(&wsMsg) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
| 			ac.logger.WithField("loop", "ws-handler").Println("read:", err) | 			logger.Println("read:", err) | ||||||
| 			ac.wsConn.CloseAndReconnect() | 			ac.wsConn.CloseAndReconnect() | ||||||
| 			continue | 			continue | ||||||
| 		} | 		} | ||||||
| 		if wsMsg.Instruction == WebsocketInstructionTriggerUpdate { | 		if wsMsg.Instruction == WebsocketInstructionTriggerUpdate { | ||||||
| 			time.Sleep(ac.reloadOffset) | 			time.Sleep(ac.reloadOffset) | ||||||
|  | 			logger.Debug("Got update trigger...") | ||||||
| 			err := ac.Server.Refresh() | 			err := ac.Server.Refresh() | ||||||
| 			if err != nil { | 			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
	
	Block a user
	 Jens Langhammer
					Jens Langhammer