Skip to content

Commit 7888efa

Browse files
author
Sebastian Wagner
committed
BUG: bin/ctl: enhance disabled file logging handling
1 parent 2fd9d2f commit 7888efa

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ CHANGELOG
3535
### Tools
3636
- `intelmqsetup`:
3737
- Also cover required directory layout and file permissions for `intelmq-api` (PR#1787 by Sebastian Wagner, fixes #1783).
38+
- `intelmqctl`:
39+
- Do not log an error message if logging to file is explicitly disabled, e.g. in calls from `intelmsetup`. The error message would not be useful for the user and is not necessary.
3840

3941
### Contrib
4042

intelmq/bin/intelmqctl.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ def __init__(self, interactive: bool = False, return_type: str = "python", quiet
710710

711711
try:
712712
if no_file_logging:
713-
raise FileNotFoundError
713+
raise FileNotFoundError('Logging to file disabled.')
714714
logger = utils.log('intelmqctl', log_level=self.logging_level,
715715
log_format_stream=utils.LOG_FORMAT_SIMPLE,
716716
logging_level_stream=logging_level_stream,
@@ -720,7 +720,8 @@ def __init__(self, interactive: bool = False, return_type: str = "python", quiet
720720
logger = utils.log('intelmqctl', log_level=self.logging_level, log_path=False,
721721
log_format_stream=utils.LOG_FORMAT_SIMPLE,
722722
logging_level_stream=logging_level_stream)
723-
logger.error('Not logging to file: %s', exc)
723+
if not isinstance(exc, FileNotFoundError) and exc.args[0] != 'Logging to file disabled.':
724+
logger.error('Not logging to file: %s', exc)
724725
self.logger = logger
725726
if defaults_loading_exc:
726727
self.logger.exception('Loading the defaults configuration failed!',

0 commit comments

Comments
 (0)