nemo_voice_agent.utils.misc

View as Markdown

Module Contents

Classes

NameDescription
FileLoggerSimple file+stdout logger with caller location tracking.

Functions

NameDescription
setup_loggingConfigure loguru to emit to stderr and a rotating log file.
setup_rotating_logRoll an existing log file aside (or delete it), then call setup_logging.

API

class nemo_voice_agent.utils.misc.FileLogger(
log_file: typing.Optional[str] = None,
mode: str = 'w'
)

Simple file+stdout logger with caller location tracking.

nemo_voice_agent.utils.misc.FileLogger.__call__(
message: str,
include_caller: bool = True
)

Allow calling the logger instance directly like a function.

nemo_voice_agent.utils.misc.FileLogger._get_caller_location() -> str

Return file:function:line of the caller, skipping frames inside FileLogger.

nemo_voice_agent.utils.misc.FileLogger.debug(
message: str,
include_caller: bool = True
)

Log at DEBUG level.

nemo_voice_agent.utils.misc.FileLogger.error(
message: str,
include_caller: bool = True
)

Log at ERROR level.

nemo_voice_agent.utils.misc.FileLogger.info(
message: str,
include_caller: bool = True
)

Log at INFO level.

nemo_voice_agent.utils.misc.FileLogger.log(
message: str,
include_caller: bool = True
)

Write a timestamped line to the log file (if set) and stdout.

nemo_voice_agent.utils.misc.FileLogger.warning(
message: str,
include_caller: bool = True
)

Log at WARNING level.

nemo_voice_agent.utils.misc.setup_logging(
log_file: str = 'bot_server.log',
log_level: str = 'DEBUG',
rotation: str = '1 day'
)

Configure loguru to emit to stderr and a rotating log file.

nemo_voice_agent.utils.misc.setup_rotating_log(
log_file: str,
log_level: str = 'DEBUG',
create_new_log: bool = False,
overwrite_existing: bool = False,
rotation: str = '1 day'
) -> None

Roll an existing log file aside (or delete it), then call setup_logging.

If create_new_log is True and the file exists, it is either removed (overwrite_existing=True) or renamed with a timestamp suffix. Used by bot server scripts that want a fresh log on every run.