irsim.env.env_logger#

Classes#

EnvLogger

Thin wrapper around Loguru used by IR-SIM environments.

Module Contents#

class irsim.env.env_logger.EnvLogger(log_file: str | None = 'irsim_error.log', log_level: str = 'WARNING')[源代码]#

Thin wrapper around Loguru used by IR-SIM environments.

Each environment owns a console sink at its log_level and, when log_file is given, a file sink. Its messages are tagged and its sinks accept only that tag, so a second environment in the same process neither replaces the first one's sinks nor receives its messages. Sinks added by user code are left alone. close removes the sinks; garbage collection does the same.

Initialize the EnvLogger.

参数:
  • log_file (str, optional) -- Path to the log file. Default is 'irsim_error.log'.

  • log_level (str, optional) -- Logging level. Default is 'WARNING'.

CONSOLE_FORMAT = '<green>{time:YYYY-MM-DD HH:mm}</green> | <level>{level: <8}</level> | <level>{message}</level>'#
close() → None[源代码]#

Remove this environment's console and file sinks.

trace(msg: str) → None[源代码]#

Log a trace message.

参数:

msg (str) -- The message to log.

info(msg: str) → None[源代码]#

Log an info message.

参数:

msg (str) -- The message to log.

error(msg: str) → None[源代码]#

Log an error message.

参数:

msg (str) -- The message to log.

debug(msg: str) → None[源代码]#

Log a debug message.

参数:

msg (str) -- The message to log.

warning(msg: str) → None[源代码]#

Log a warning message.

参数:

msg (str) -- The message to log.

warning_once(msg: str, key: str | None = None) → None[源代码]#

Log a warning the first time key (default: msg) is seen, then at DEBUG.

For per-step conditions that would otherwise flood the log every step.

参数:
  • msg (str) -- The message to log.

  • key (str, optional) -- Identity of the condition when msg varies.

success(msg: str) → None[源代码]#

Log a success message.

参数:

msg (str) -- The message to log.

critical(msg: str) → None[源代码]#

Log a critical message.

参数:

msg (str) -- The message to log.