diff --git a/docs/advanced-setup.md b/docs/advanced-setup.md index 93a2025ed..54d489aa1 100644 --- a/docs/advanced-setup.md +++ b/docs/advanced-setup.md @@ -192,7 +192,7 @@ $RepeatedMsgReduction on ### Logging to journald -This needs the `systemd` python package installed as the dependency, which is not available on Windows. Hence, the whole journald logging functionality is not available for a bot running on Windows. +This needs the `cysystemd` python package installed as dependency (`pip install cysystemd`), which is not available on Windows. Hence, the whole journald logging functionality is not available for a bot running on Windows. To send Freqtrade log messages to `journald` system service use the `--logfile` command line option with the value in the following format: diff --git a/freqtrade/loggers.py b/freqtrade/loggers.py index f365053c9..ff002f5d6 100644 --- a/freqtrade/loggers.py +++ b/freqtrade/loggers.py @@ -103,7 +103,7 @@ def setup_logging(config: Config) -> None: logging.root.addHandler(handler_sl) elif s[0] == 'journald': # pragma: no cover try: - from systemd.journal import JournaldLogHandler + from cysystemd.journal import JournaldLogHandler except ImportError: raise OperationalException("You need the systemd python package be installed in " "order to use logging to journald.") diff --git a/tests/conftest.py b/tests/conftest.py index 06a86c3b3..c74b1f0f1 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2573,7 +2573,7 @@ def import_fails() -> None: realimport = builtins.__import__ def mockedimport(name, *args, **kwargs): - if name in ["filelock", 'systemd.journal', 'uvloop']: + if name in ["filelock", 'cysystemd.journal', 'uvloop']: raise ImportError(f"No module named '{name}'") return realimport(name, *args, **kwargs) diff --git a/tests/test_configuration.py b/tests/test_configuration.py index a2a1b72cc..abf7be5d1 100644 --- a/tests/test_configuration.py +++ b/tests/test_configuration.py @@ -701,15 +701,16 @@ def test_set_loggers_journald(mocker): 'logfile': 'journald', } + setup_logging_pre() setup_logging(config) - assert len(logger.handlers) == 2 + assert len(logger.handlers) == 3 assert [x for x in logger.handlers if type(x).__name__ == "JournaldLogHandler"] assert [x for x in logger.handlers if type(x) == logging.StreamHandler] # reset handlers to not break pytest logger.handlers = orig_handlers -def test_set_loggers_journald_importerror(mocker, import_fails): +def test_set_loggers_journald_importerror(import_fails): logger = logging.getLogger() orig_handlers = logger.handlers logger.handlers = []