From b195aca12ff189a3e0a37d13d27b9c4160305659 Mon Sep 17 00:00:00 2001 From: spl0k Date: Sun, 11 Nov 2018 19:25:14 +0100 Subject: [PATCH] watcher: log to stderr when no logfile is set --- supysonic/watcher.py | 5 +++-- tests/base/test_watcher.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/supysonic/watcher.py b/supysonic/watcher.py index 3e1d309..ab80713 100644 --- a/supysonic/watcher.py +++ b/supysonic/watcher.py @@ -254,9 +254,10 @@ class SupysonicWatcher(object): def run(self): if self.__config.DAEMON['log_file']: log_handler = TimedRotatingFileHandler(self.__config.DAEMON['log_file'], when = 'midnight') + log_handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")) else: - log_handler = logging.NullHandler() - log_handler.setFormatter(logging.Formatter("%(asctime)s [%(levelname)s] %(message)s")) + log_handler = logging.StreamHandler() + log_handler.setFormatter(logging.Formatter("[%(levelname)s] %(message)s")) logger.addHandler(log_handler) if 'log_level' in self.__config.DAEMON: level = getattr(logging, self.__config.DAEMON['log_level'].upper(), logging.NOTSET) diff --git a/tests/base/test_watcher.py b/tests/base/test_watcher.py index d8fef7a..229c6f0 100644 --- a/tests/base/test_watcher.py +++ b/tests/base/test_watcher.py @@ -30,7 +30,7 @@ from ..testbase import TestConfig class WatcherTestConfig(TestConfig): DAEMON = { 'wait_delay': 0.5, - 'log_file': None, + 'log_file': '/dev/null', 'log_level': 'DEBUG' }