calliope.util.logging
¶
Create the Calliope logger object and apply other logging tools/functionality.
LogWriter(logger, level, strip=False)
¶
log_time(logger, timings, identifier, comment=None, level='info', time_since_solve_start=False)
¶
Simultaneously log the time of a Calliope event to dictionary and to the logger.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
logger |
Logger
|
Logger to use for logging the time. |
required |
timings |
dict
|
Dictionary of model timings. |
required |
identifier |
str
|
Short description to use as the event key in |
required |
comment |
Optional[str]
|
Long description of the event.
If not given, |
None
|
level |
str
|
Level at which to log the event with the |
'info'
|
time_since_solve_start |
bool
|
If True, append comment in log message on the event's time compared to the time since the model was sent to the solver (in seconds). Defaults to False. |
False
|
Source code in src/calliope/util/logging.py
set_log_verbosity(verbosity, include_solver_output=True, capture_warnings=True)
¶
Set the verbosity of logging and setup the root logger to log to console (stdout) with timestamp output formatting.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbosity |
str | int
|
Logging level to use in all Calliope loggers.
Can be a string (e.g. |
required |
include_solver_output |
bool
|
If True, the logging level for just the backend model is set to DEBUG, which turns on display of solver output. Defaults to True. |
True
|
capture_warnings |
bool
|
If True, capture Python warnings in the logger (at the |
True
|
Source code in src/calliope/util/logging.py
setup_root_logger(verbosity, capture_warnings=True)
¶
Setup Calliope root logger.
Here, we set the logger format, clear any existing "handlers", set the Calliope-wide logging level (i.e. verbosity), and optionally fold in python warnings into logging.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
verbosity |
str | int
|
Logging level to use in all Calliope loggers.
Can be a string (e.g. |
required |
capture_warnings |
bool
|
If True, capture Python warnings in the logger (at the |
True
|
Returns:
Type | Description |
---|---|
Logger
|
logging.Logger: Calliope root logger with all setup applied. |