Skip to content

Commit e8301f9

Browse files
committed
Clean up and fix logging
1 parent c54bf7b commit e8301f9

2 files changed

Lines changed: 8 additions & 11 deletions

File tree

src/hermes/commands/cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"""
1111
import argparse
1212

13+
from hermes import logger
1314
from hermes.commands import HermesHelpCommand, HermesCleanCommand, HermesHarvestCommand, HermesProcessCommand, \
1415
HermesCurateCommand, HermesDepositCommand, HermesPostprocessCommand
1516
from hermes.commands.base import HermesCommand
@@ -56,6 +57,8 @@ def main() -> None:
5657
# Actually parse the command line, configure it and execute the selected sub-command.
5758
args = parser.parse_args()
5859

60+
logger.init_logging()
61+
5962
args.command.load_settings(args)
6063
args.command.patch_settings(args)
6164
args.command(args)

src/hermes/logger.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
'class': "logging.FileHandler",
3232
'formatter': "logfile",
3333
'level': "DEBUG",
34-
'filename': "./.hermes/hermes.log",
34+
'filename': "./hermes.log",
3535
},
3636

3737
'auditfile': {
@@ -50,12 +50,6 @@
5050
},
5151
}
5252

53-
# This dict caches all the different configuration sections already loaded
54-
_config = {
55-
# We need some basic logging configuration to get logging up and running at all
56-
'logging': _logging_config,
57-
}
58-
5953
_loggers = {}
6054

6155

@@ -64,14 +58,14 @@ def init_logging():
6458
return
6559

6660
# Make sure the directories to hold the log files exists (or else create)
67-
pathlib.Path(_config['logging']['handlers']['logfile']['filename']).parent.mkdir(exist_ok=True, parents=True)
68-
pathlib.Path(_config['logging']['handlers']['auditfile']['filename']).parent.mkdir(exist_ok=True, parents=True)
61+
pathlib.Path(_logging_config['handlers']['logfile']['filename']).parent.mkdir(exist_ok=True, parents=True)
62+
pathlib.Path(_logging_config['handlers']['auditfile']['filename']).parent.mkdir(exist_ok=True, parents=True)
6963

7064
# Inintialize logging system
7165
import logging.config
7266

73-
logging.config.dictConfig(_config['logging'])
74-
for log_name in _config['logging']['loggers']:
67+
logging.config.dictConfig(_logging_config)
68+
for log_name in _logging_config['loggers']:
7569
_loggers[log_name] = logging.getLogger(log_name)
7670

7771

0 commit comments

Comments
 (0)