logger⚓︎
Run logging: a table-formatting file logger and a no-op stand-in for when logging is off.
NullLogger
⚓︎
Callable no-op standing in for a :class:PetLogger when logging is
disabled -- so callers can invoke self.logger(...) unconditionally
without checking whether logging is on, and no log file is created.
info(*args, **kwargs)
⚓︎
No-op.
PetLogger
⚓︎
A custom logger that logs messages and key-value pairs in a formatted table.
Parameters: filename (str): The name of the log file. Defaults to 'PET.log'.
__call__(*args, **kwargs)
⚓︎
Log messages or key-value pairs in a formatted table.
Parameters: *args: Positional arguments to log as a single message. **kwargs: Keyword arguments to log in a formatted table.
Example: >>> logger = PetLogger() >>> logger('This is a log message.') 2024-06-01│12:00:00 : This is a log message. >>> >>> logger(iteration=1, fun=0.5, step_size=0.1) 2024-06-01│12:00:00 : 2024-06-01│12:00:00 : ┌────────────┬────────────┬────────────┐ 2024-06-01│12:00:00 : │ iteration │ fun │ step_size │ 2024-06-01│12:00:00 : ├────────────┼────────────┼────────────┤ 2024-06-01│12:00:00 : │ 1 │ 5.000e-01 │ 1.000e-01 │ 2024-06-01│12:00:00 : └────────────┴────────────┴────────────┘ 2024-06-01│12:00:00 :
info(*args, **kwargs)
⚓︎
Log as given; __call__ is the table-aware form.