gale.log.config module
This file contains configure (sets up the console/file handlers, or lets a game override them), get_logger (returns a named logger, auto-configuring with the defaults on first use), and add_handler/ remove_handler for attaching extra destinations on top.
Author: Alejandro Mujica (aledrums@gmail.com)
- gale.log.config.configure(level=20, log_file='gale.log', console=True)[source]
Set up gale’s default logging: a console handler and/or a plain-text file handler. Call this once, as early as convenient (get_logger auto-configures with these same defaults on first use if you never call this explicitly, so calling it is only needed to override the defaults).
Extra “strategies” — where else records should go, such as a Graylog server — are added on top of whatever this sets up, with add_handler; calling configure again replaces the console/file handlers but leaves any handler added through add_handler alone.
- Parameters:
level (int) – The minimum severity to emit, one of the LogLevel constants. The default value is LogLevel.INFO.
log_file (str | None) – Path to the plain-text log file to write to. The default value is “gale.log”. Pass None to disable file logging.
console (bool) – Whether to also print log records to the terminal. The default value is True.
- Return type:
None
- gale.log.config.get_logger(name=None)[source]
- Parameters:
name (str | None) – A dotted name for the logger, nested under gale’s own (e.g. “space_trip.player” becomes “gale.space_trip.player”). The default value is None, returning gale’s own top-level logger.
- Returns:
A standard library Logger, so it composes with anything else that already understands logging.Logger. Auto-configures with configure()’s defaults on first use if configure() was never called explicitly.
- Return type:
Logger