log
¶
JsonLogFormatter
¶
setup_logger
¶
Python
setup_logger(
level=INFO,
terminal: bool = True,
log_file: Path | str | None = Path("mojo.log"),
max_bytes: int = 10 * 1024 * 1024,
backup_count: int = 5,
) -> Logger
Shortcut to a sensible MuJoCo Mojo logger using Rich for the terminal.
Source code in src/mujoco_mojo/utils/log.py
get_trial_log_handler
¶
Python
get_trial_log_handler(
log_file: Path | str,
level: int | None = None,
mode: str = "a",
) -> FileHandler
Creates a file handler using the standard mojo log format for per-trial logging.
The returned handler is not attached to any logger. Attach it to the root logger (and remove/close it afterwards) to capture logs for a single trial.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_file
|
Path | str
|
Path to the log file. |
required |
level
|
int | None
|
Optional minimum level for this handler. |
None
|
mode
|
str
|
File open mode, passed straight to |
'a'
|
Source code in src/mujoco_mojo/utils/log.py
worker_init
¶
Initializes the worker process logger to match the parent's state.
This is used for logging with multiprocessing.