From 3768fedab418cbcd996d82e410e19a246aedebdc Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 6 Dec 2023 13:47:08 +0100 Subject: [PATCH] Revert "bridge: try logging to systemd-journald" This reverts commit e71bf74744e81772f52a6508c41c6828f2ed10c2. --- src/cockpit/bridge.py | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/cockpit/bridge.py b/src/cockpit/bridge.py index 22517653e871..139db92f90ce 100644 --- a/src/cockpit/bridge.py +++ b/src/cockpit/bridge.py @@ -24,7 +24,6 @@ import pwd import shlex import socket -import stat import subprocess from typing import Iterable, List, Optional, Sequence, Tuple, Type @@ -203,33 +202,11 @@ def try_to_receive_stderr(): os.close(fd) -def setup_journald() -> bool: - # If stderr is a socket, prefer systemd-journal logging. This covers the - # case we're already connected to the journal but also the case where we're - # talking to the ferny agent, while leaving logging to file or terminal - # unaffected. - if not stat.S_ISSOCK(os.fstat(2).st_mode): - # not a socket? Don't redirect. - return False - - try: - import systemd.journal # type: ignore[import] - except ImportError: - # No python3-systemd? Don't redirect. - return False - - logging.root.addHandler(systemd.journal.JournalHandler()) - return True - - -def setup_logging(*, debug: bool) -> None: +def setup_logging(*, debug: bool): """Setup our logger with optional filtering of modules if COCKPIT_DEBUG env is set""" modules = os.getenv('COCKPIT_DEBUG', '') - - # Either setup logging via journal or via formatted messages to stderr - if not setup_journald(): - logging.basicConfig(format='%(name)s-%(levelname)s: %(message)s') + logging.basicConfig(format='%(name)s-%(levelname)s: %(message)s') if debug or modules == 'all': logging.getLogger().setLevel(level=logging.DEBUG)