mini_arcade_core.utils.logging¶
Logging utilities for Mini Arcade Core. Provides a console logger with colored output and class/function context.
Attributes¶
Classes¶
Populate record.classname by finding the emitting frame: |
|
Console formatter with ANSI colors by log level. |
|
Performance logger filter to include only perf logs. |
|
Performance logger filter to exclude perf logs. |
|
Formatter for performance logs. |
Functions¶
|
Configure logging once for the whole app (root logger). |
Module Contents¶
- class mini_arcade_core.utils.logging.EnsureClassName(name='')¶
Bases:
logging.FilterPopulate record.classname by finding the emitting frame: match by (pathname, funcName) and read self/cls from its locals. Falls back to “-” when not in a class context.
- filter(record: logging.LogRecord) bool¶
Determine if the specified record is to be logged.
Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.
- class mini_arcade_core.utils.logging.ConsoleColorFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)¶
Bases:
logging.FormatterConsole formatter with ANSI colors by log level.
- COLORS¶
- format(record: logging.LogRecord) str¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- mini_arcade_core.utils.logging.LOGGER_FORMAT = '%(asctime)s [%(levelname)-8.8s] [%(name)s] %(module)s.%(classname)s.%(funcName)s: %(message)s...¶
- class mini_arcade_core.utils.logging.OnlyPerf(name='')¶
Bases:
logging.FilterPerformance logger filter to include only perf logs.
- filter(record: logging.LogRecord) bool¶
Determine if the specified record is to be logged.
Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.
- class mini_arcade_core.utils.logging.ExcludePerf(name='')¶
Bases:
logging.FilterPerformance logger filter to exclude perf logs.
- filter(record: logging.LogRecord) bool¶
Determine if the specified record is to be logged.
Returns True if the record should be logged, or False otherwise. If deemed appropriate, the record may be modified in-place.
- class mini_arcade_core.utils.logging.PerfFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)¶
Bases:
logging.FormatterFormatter for performance logs.
- format(record: logging.LogRecord) str¶
Format the specified record as text.
The record’s attribute dictionary is used as the operand to a string formatting operation which yields the returned string. Before formatting the dictionary, a couple of preparatory steps are carried out. The message attribute of the record is computed using LogRecord.getMessage(). If the formatting string uses the time (as determined by a call to usesTime(), formatTime() is called to format the event time. If there is exception information, it is formatted using formatException() and appended to the message.
- mini_arcade_core.utils.logging.configure_logging(level: int = logging.DEBUG)¶
Configure logging once for the whole app (root logger). Call this early (app entrypoint). Safe to call multiple times.
- mini_arcade_core.utils.logging.logger¶