feat(script): Log into queue

This commit is contained in:
hygienic-books 2025-03-02 20:28:37 +01:00
parent 466397f04a
commit 7dea3863aa
2 changed files with 14 additions and 2 deletions

View File

@ -36,13 +36,20 @@
"formatter": "json",
"maxBytes": 10000,
"backupCount": 3
},
"queue_handler": {
"class": "logging.handlers.QueueHandler",
"handlers": [
"rich",
"file"
],
"respect_handler_level": true
}
},
"loggers": {
"root": {
"handlers": [
"rich",
"file"
"queue_handler"
],
"level": "DEBUG"
}

View File

@ -1,4 +1,5 @@
# import gnupg
import atexit
import json
import logging.config
import pathlib
@ -12,6 +13,10 @@ def setup_logging():
with open(config_file, "r") as config_file:
config = json.load(config_file)
logging.config.dictConfig(config)
queue_handler = logging.getHandlerByName("queue_handler")
if queue_handler is not None:
queue_handler.listener.start()
atexit.register(queue_handler.listener.stop)
def main():