Skip to content

Commit

Permalink
Fix log messages being logged twice to the daemon log file (#6051)
Browse files Browse the repository at this point in the history
In 276a93f the logging configuration
logic was modified to respect the log level being changed through the
`--verbosity` option when invoking `verdi`. The changes added the `cli`
handler to all loggers.

This code was also being executed when a daemon worker started up and
called `aiida.common.log.configure_logging` causing all logging to end
up twice in the daemon log file.

The assertion of the `test_duplicate_subscriber_identifier` test is
updated since the expected error message contained the `Error:` literal
which is the log level at which the message is logged and is therefore
formatted based on the loggers formatter, which is configurable. In this
case, it is actually formatted as `[ERROR]` which was causing the test
to fail.
  • Loading branch information
sphuber authored Jun 8, 2023
1 parent 68cb457 commit bfd63c7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aiida/common/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def configure_logging(with_orm=False, daemon=False, daemon_log_file=None):

# If the ``CLI_ACTIVE`` is set, a ``verdi`` command is being executed, so we replace the ``console`` handler with
# the ``cli`` one for all loggers.
if CLI_ACTIVE is True:
if CLI_ACTIVE is True and not daemon:
for logger in config['loggers'].values():
handlers = logger['handlers']
if 'console' in handlers:
Expand Down
2 changes: 1 addition & 1 deletion tests/manage/external/test_rmq.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def test_duplicate_subscriber_identifier(aiida_local_code_factory, started_daemo

# Verify that the receiving of the duplicate task was logged by the daemon
daemon_log = pathlib.Path(started_daemon_client.daemon_log_file).read_text(encoding='utf-8')
assert f'Error: A subscriber with the process id<{node.pk}> already exists' in daemon_log
assert f'A subscriber with the process id<{node.pk}> already exists' in daemon_log


@pytest.fixture
Expand Down

0 comments on commit bfd63c7

Please sign in to comment.