feat(script): Log into queue
This commit is contained in:
parent
466397f04a
commit
7dea3863aa
@ -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"
|
||||
}
|
||||
|
5
main.py
5
main.py
@ -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():
|
||||
|
Loading…
x
Reference in New Issue
Block a user