log_utils
Custom logger and associated utilities.
- class log_utils.CustomLogger(sdir, ref, log=True)[source]
Bases:
LoggerCustom logger.
Features:
Uses custom levels DATA, RESULTS, INPUT and INFO_NOSTREAM.
Implements a stream handler (level INFO) and a file handler (level DATA).
Wraps messages before logging.
Level
Value
File
Stream
DATA
15
o
x
RESULTS
16
o
x
INPUT
17
o
x
INFO_NOSTREAM
18
o
x
INFO
20
o
o
WARNING
30
o
o
- log_utils.parse_log(fpath)[source]
Get simulation results from log file.
- Parameters:
fpath (pathlib.Path instance) – Path to log file.
- Returns:
config (dict) – Input simulation parameters.
results (dict) – Simulation results (see
simu.NewSimulation.run()andsolvers.solver()).
- log_utils.get_and_log(dct, key, default, logger, key_alias=None, stream=True)[source]
Get dict value and send log if the key is absent from the dict.
- Parameters:
dct (dictionary) – Dictionary to be probed.
key (str) – Requested key.
default (any) – Value returned if key is not in dict.
key_alias (str, optional) – Name to be logged instead of key if key is absent. The default is None.
- Returns:
res – Value obtained from dict or default.
- Return type:
any