flare.log

Generalized Python logging for Pyodide.

Module Contents

Classes

FlareLogRecord

A LogRecord instance represents an event being logged.

JSConsoleHandler

Brings our awesome log messages onto the js console.

Functions

prepareLogger(→ None)

Call this before first usage of logging or getLogger().

getLogger(→ Any)

Creates a child logger of our 'root' logger with a name.

Attributes

loggers

flare.log.loggers = []
class flare.log.FlareLogRecord(name, level, pathname, lineno, msg, args, exc_info, func=None, sinfo=None, mergeArgs=False, **kwargs)

Bases: logging.LogRecord

A LogRecord instance represents an event being logged.

LogRecord instances are created every time something is logged. They contain all the information pertinent to the event being logged. The main information passed in is in msg and args, which are combined using str(msg) % args to create the message field of the record. The record also includes information such as when the record was created, the source line where the logging call was made, and any exception information to be logged.

NOTE: This is mostly the same as the original LogRecord. Differences:

  • Do not use a single dict as keyword args because pyodites’ Proxy objects cannot be used

with isinstance(proxy, collections.abc.Mapping). This will be discussed upstream. * User-supplied arguments to logging messages will not be replaced in message, but will be forwarded to js console via separate arguments.

getMessage() str

Optionally merge args into message driven by mergeArgs flag in ctor, otherwise this will happen later in js console as objects.

Returns

class flare.log.JSConsoleHandler(stream=None)

Bases: logging.StreamHandler

Brings our awesome log messages onto the js console.

emit(record: logging.LogRecord) None

Emit a record.

If a formatter is specified, it is used to format the record. The record is then written to the stream with a trailing newline. If exception information is present, it is formatted using traceback.print_exception and appended to the stream. If the stream has an ‘encoding’ attribute, it is used to determine how to do the output to the stream.

flare.log.prepareLogger(level: str, mergeArgs: bool = False) None

Call this before first usage of logging or getLogger().

:param level Log level as str as of all, info, debug, warning, error or critical :param mergeArgs: If True we’re merging args into resulting message resulting in possible duplicated output or get the ‘raw’ message output if False.

flare.log.getLogger(name: str) Any

Creates a child logger of our ‘root’ logger with a name.

Usually it’s the __name__ attribute of the module you want to use a logger for.

Parameters

name

Returns