Add queue logging

This commit is contained in:
Andrew 2023-12-07 18:02:54 -05:00
parent 4447fdfdff
commit d2b738f857
2 changed files with 27 additions and 0 deletions

View File

@ -23,6 +23,7 @@ from app.classes.web.tornado_handler import Webserver
from app.classes.shared.websocket_manager import WebSocketManager from app.classes.shared.websocket_manager import WebSocketManager
logger = logging.getLogger("apscheduler") logger = logging.getLogger("apscheduler")
command_log = logging.getLogger("cmd_queue")
scheduler_intervals = { scheduler_intervals = {
"seconds", "seconds",
"minutes", "minutes",
@ -94,7 +95,15 @@ class TasksManager:
def command_watcher(self): def command_watcher(self):
while True: while True:
# select any commands waiting to be processed # select any commands waiting to be processed
command_log.info(
"Queue currently has "
f"{self.controller.management.command_queue.qsize()} queued commands."
)
if not self.controller.management.command_queue.empty(): if not self.controller.management.command_queue.empty():
command_log.info(
"Current queued commands: "
f"{list(self.controller.management.command_queue.queue)}"
)
cmd = self.controller.management.command_queue.get() cmd = self.controller.management.command_queue.get()
try: try:
svr = self.controller.servers.get_server_instance_by_id( svr = self.controller.servers.get_server_instance_by_id(

View File

@ -13,6 +13,9 @@
}, },
"auth": { "auth": {
"format": "%(asctime)s - [AUTH] - %(levelname)s - %(message)s" "format": "%(asctime)s - [AUTH] - %(levelname)s - %(message)s"
},
"cmd_queue": {
"format": "%(asctime)s - [CMD_QUEUE] - %(levelname)s - %(message)s"
} }
}, },
"handlers": { "handlers": {
@ -59,6 +62,14 @@
"maxBytes": 10485760, "maxBytes": 10485760,
"backupCount": 20, "backupCount": 20,
"encoding": "utf8" "encoding": "utf8"
},
"cmd_queue_file_handler": {
"class": "logging.handlers.RotatingFileHandler",
"formatter": "auth",
"filename": "logs/cmd_queue.log",
"maxBytes": 10485760,
"backupCount": 20,
"encoding": "utf8"
} }
}, },
"loggers": { "loggers": {
@ -90,6 +101,13 @@
"auth_file_handler" "auth_file_handler"
], ],
"propagate": false "propagate": false
},
"cmd_queue": {
"level": "INFO",
"handlers": [
"cmd_queue_file_handler"
],
"propagate": false
} }
} }
} }