From aaa6ec8eb29aefb3fb96f1dc2392c28ae07e09dd Mon Sep 17 00:00:00 2001 From: Arksine Date: Sat, 5 Dec 2020 19:20:03 -0500 Subject: [PATCH] utils: add support for logging to stdout Signed-off-by: Eric Callahan --- moonraker/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/moonraker/utils.py b/moonraker/utils.py index fde1640..55d8b8e 100644 --- a/moonraker/utils.py +++ b/moonraker/utils.py @@ -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