Skip to content

Commit

Permalink
Update dependency to cysystemd
Browse files Browse the repository at this point in the history
  • Loading branch information
xmatthias committed Feb 19, 2023
1 parent b0ec35d commit e9c64c5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/advanced-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion freqtrade/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
5 changes: 3 additions & 2 deletions tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit e9c64c5

Please sign in to comment.