Logging¶
logging
¶
Simple logger for tracking MCMC sampling.
Classes:
| Name | Description |
|---|---|
LoggerSettings |
Data class for logger settings |
MCMCLogger |
Custom Logger class |
ls_mcmc.logging.LoggerSettings
dataclass
¶
Configuration settings for MCMC logging.
Attributes:
| Name | Type | Description |
|---|---|---|
do_printing |
bool
|
Whether to enable console output. Defaults to True. |
logfile_path |
str
|
Path to the log file. If None, no file logging is performed. |
write_mode |
str
|
File write mode ('w' for overwrite, 'a' for append). Defaults to 'w'. |
ls_mcmc.logging.MCMCLogger
¶
Logger for MCMC sampling with console and file output support.
Methods:
| Name | Description |
|---|---|
log_header |
Log formatted header for MCMC output |
log_outputs |
Log all outputs |
info |
Pass info message to underlying Python logger |
debug |
Pass debug message to underlying Python logger |
error |
Pass error message to underlying Python logger |
exception |
Pass exception message to underlying Python logger |
__init__
¶
Initialize the MCMC logger with specified settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
logger_settings
|
LoggerSettings
|
Logger settings |
required |
log_header
¶
Log a formatted header for MCMC output columns.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outputs
|
tuple[output.MCMCOutput]
|
Tuple of MCMC output objects to include in the header. |
required |
log_outputs
¶
Log formatted MCMC output values for the current iteration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
outputs
|
output.MCMCOutput
|
MCMC output objects containing values to log. |
required |
iteration
|
int
|
Current iteration number. |
required |
time
|
float
|
Elapsed time for this iteration. |
required |
info
¶
Log an info-level message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to log. |
required |
debug
¶
Log a debug-level message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to log. |
required |
exception
¶
Log an exception with traceback information.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to log. |
required |
error
¶
Log an error.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message
|
str
|
The message to log. |
required |