plesty.lib.utils.logger
Logging setup utilities for Plesty.
Attributes
Functions
|
Return a filesystem-safe token for log file names. |
|
Return True if a plesty-installed console (or file) handler is on root. |
|
Make INFO-level records visible on the console; idempotent, no file sink. |
|
Configure console logging plus a |
Module Contents
- plesty.lib.utils.logger._safe_filename_part(value: str) str
Return a filesystem-safe token for log file names.
- Parameters:
value (str)
- Return type:
str
- plesty.lib.utils.logger._FORMAT = '%(asctime)s | %(levelname)s | %(name)s | %(message)s'
- plesty.lib.utils.logger._has_plesty_sink(root: logging.Logger, file: bool) bool
Return True if a plesty-installed console (or file) handler is on root.
- Parameters:
root (logging.Logger)
file (bool)
- Return type:
bool
- plesty.lib.utils.logger.ensure_logging(level: str = 'INFO', console_print: bool = True) None
Make INFO-level records visible on the console; idempotent, no file sink.
The lightweight bootstrap every plesty building block calls on construction (
CompositeDevice,Experiment): a rig that connects before the experiment exists must not be silent while a server is unreachable. Sets the root level and adds one console handler unless something (a host application, pytest’s capture, an earlier call) already writes to the console.setup_logging()adds the per-run file on top.- Parameters:
level (str) – Root logger level name.
console_print (bool) – Add the console handler when none exists.
- Return type:
None
- plesty.lib.utils.logger.setup_logging(app_name: str, level: str = 'INFO', console_print: bool = True) None
Configure console logging plus a
logs/<app_name>_<timestamp>.logfile.Builds on
ensure_logging(); the file sink is added once per process — the first app_name names the file, later calls only re-assert the level.- Parameters:
app_name (str) – Application name used in the log file name.
level (str) – Root logger level name.
console_print (bool) – Also print to the console when no console sink exists.
- Return type:
None