logging - loggers and formatters¶
This module contains list of default log formatter and loggers used by package logging services.
- FORMATTERS¶
Registry of log formatter classes (see
ClassRegistryfor available methods).
- HANDLERS¶
Registry of log handlers classes (see
ClassRegistryfor available methods).
- class TextFormatter[source]¶
Formatter for human-readable text.
- __init__(*args, datefmt: str = default_date_fmt, fmt: str = default_log_fmt, **kws)[source]¶
Initialize.
- Parameters:
output_data – output log extra data
output_context – output log adapter context data
datefmt – log date format
fmt – log format
limit_var – limit variables in log in symbols
args – see logging.Formatter.__init__
kws – see logging.Formatter.__init__
- class DataFormatter[source]¶
Colored formatter is used to pretty-print colored text in CLI.
Text color depends on log level.
- __init__(*args, debug: bool = False, encoder: str = MimeType.json.value, encoders=ENCODERS, **kws)[source]¶
Initialize.
- Parameters:
debug – output debug information about exceptions
encoder – data encoding format or encoder object itself or None for no additional encoding
encoders – optional encoder classes registry
args – see
TextFormatterkws – see
TextFormatter
- class JSONHandler[source]¶
JSON log queue handler (better performance).
- formatter_cls¶
alias of
DataFormatter
- class TextHandler[source]¶
Human-readable text log queue handler.
- formatter_cls¶
alias of
TextFormatter
- __init__(app=None, formatter: dict = None, stream: str = None)[source]¶
Initialize.
- Parameters:
app – web app
formatter – formatter class settings
stream – optional stream type ‘stdout’ or ‘stderr’
- prepare(record)[source]¶
Prepare a record for queuing. The object returned by this method is enqueued.
The base implementation formats the record to merge the message and arguments, and removes unpickleable items from the record in-place. Specifically, it overwrites the record’s msg and message attributes with the merged message (obtained by calling the handler’s format method), and sets the args, exc_info and exc_text attributes to None.
You might want to override this method if you want to convert the record to a dict or JSON string, or send a modified copy of the record while leaving the original intact.