utils: add support for logging to stdout
Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
aba5bdf339
commit
aaa6ec8eb2
|
@ -6,6 +6,7 @@
|
||||||
import logging
|
import logging
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
import asyncio
|
import asyncio
|
||||||
from queue import SimpleQueue as Queue
|
from queue import SimpleQueue as Queue
|
||||||
|
@ -75,9 +76,14 @@ def setup_logging(log_file, software_version):
|
||||||
root_logger.setLevel(logging.INFO)
|
root_logger.setLevel(logging.INFO)
|
||||||
file_hdlr = MoonrakerLoggingHandler(
|
file_hdlr = MoonrakerLoggingHandler(
|
||||||
software_version, log_file, when='midnight', backupCount=2)
|
software_version, log_file, when='midnight', backupCount=2)
|
||||||
|
stdout_hdlr = logging.StreamHandler(sys.stdout)
|
||||||
formatter = logging.Formatter(
|
formatter = logging.Formatter(
|
||||||
'%(asctime)s [%(filename)s:%(funcName)s()] - %(message)s')
|
'%(asctime)s [%(filename)s:%(funcName)s()] - %(message)s')
|
||||||
file_hdlr.setFormatter(formatter)
|
file_hdlr.setFormatter(formatter)
|
||||||
listener = logging.handlers.QueueListener(queue, file_hdlr)
|
stdout_fmt = logging.Formatter(
|
||||||
|
'[%(filename)s:%(funcName)s()] - %(message)s')
|
||||||
|
stdout_hdlr.setFormatter(stdout_fmt)
|
||||||
|
listener = logging.handlers.QueueListener(
|
||||||
|
queue, file_hdlr, stdout_hdlr)
|
||||||
listener.start()
|
listener.start()
|
||||||
return listener
|
return listener
|
||||||
|
|
Loading…
Reference in New Issue