feat(script): Log into queue
This commit is contained in:
parent
466397f04a
commit
7dea3863aa
@ -36,13 +36,20 @@
|
|||||||
"formatter": "json",
|
"formatter": "json",
|
||||||
"maxBytes": 10000,
|
"maxBytes": 10000,
|
||||||
"backupCount": 3
|
"backupCount": 3
|
||||||
|
},
|
||||||
|
"queue_handler": {
|
||||||
|
"class": "logging.handlers.QueueHandler",
|
||||||
|
"handlers": [
|
||||||
|
"rich",
|
||||||
|
"file"
|
||||||
|
],
|
||||||
|
"respect_handler_level": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"loggers": {
|
"loggers": {
|
||||||
"root": {
|
"root": {
|
||||||
"handlers": [
|
"handlers": [
|
||||||
"rich",
|
"queue_handler"
|
||||||
"file"
|
|
||||||
],
|
],
|
||||||
"level": "DEBUG"
|
"level": "DEBUG"
|
||||||
}
|
}
|
||||||
|
5
main.py
5
main.py
@ -1,4 +1,5 @@
|
|||||||
# import gnupg
|
# import gnupg
|
||||||
|
import atexit
|
||||||
import json
|
import json
|
||||||
import logging.config
|
import logging.config
|
||||||
import pathlib
|
import pathlib
|
||||||
@ -12,6 +13,10 @@ def setup_logging():
|
|||||||
with open(config_file, "r") as config_file:
|
with open(config_file, "r") as config_file:
|
||||||
config = json.load(config_file)
|
config = json.load(config_file)
|
||||||
logging.config.dictConfig(config)
|
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():
|
def main():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user