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.handlers
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
import asyncio
|
||||
from queue import SimpleQueue as Queue
|
||||
|
@ -75,9 +76,14 @@ def setup_logging(log_file, software_version):
|
|||
root_logger.setLevel(logging.INFO)
|
||||
file_hdlr = MoonrakerLoggingHandler(
|
||||
software_version, log_file, when='midnight', backupCount=2)
|
||||
stdout_hdlr = logging.StreamHandler(sys.stdout)
|
||||
formatter = logging.Formatter(
|
||||
'%(asctime)s [%(filename)s:%(funcName)s()] - %(message)s')
|
||||
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()
|
||||
return listener
|
||||
|
|
Loading…
Reference in New Issue