mini_arcade_core.utils.logging ============================== .. py:module:: mini_arcade_core.utils.logging .. autoapi-nested-parse:: Logging utilities for Mini Arcade Core. Provides a console logger with colored output and class/function context. Attributes ---------- .. autoapisummary:: mini_arcade_core.utils.logging.LOGGER_FORMAT mini_arcade_core.utils.logging.logger Classes ------- .. autoapisummary:: mini_arcade_core.utils.logging.EnsureClassName mini_arcade_core.utils.logging.ConsoleColorFormatter mini_arcade_core.utils.logging.OnlyPerf mini_arcade_core.utils.logging.ExcludePerf mini_arcade_core.utils.logging.PerfFormatter Functions --------- .. autoapisummary:: mini_arcade_core.utils.logging.configure_logging Module Contents --------------- .. py:class:: EnsureClassName(name='') Bases: :py:obj:`logging.Filter` Populate 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. .. py:method:: 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. .. py:class:: ConsoleColorFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) Bases: :py:obj:`logging.Formatter` Console formatter with ANSI colors by log level. .. py:attribute:: COLORS .. py:method:: 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. .. py:data:: LOGGER_FORMAT :value: '%(asctime)s [%(levelname)-8.8s] [%(name)s] %(module)s.%(classname)s.%(funcName)s: %(message)s... .. py:class:: OnlyPerf(name='') Bases: :py:obj:`logging.Filter` Performance logger filter to include only perf logs. .. py:method:: 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. .. py:class:: ExcludePerf(name='') Bases: :py:obj:`logging.Filter` Performance logger filter to exclude perf logs. .. py:method:: 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. .. py:class:: PerfFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None) Bases: :py:obj:`logging.Formatter` Formatter for performance logs. .. py:method:: 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. .. py:function:: 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. .. py:data:: logger