swh.core.logger module#
- swh.core.logger.db_level_of_py_level(lvl)[source]#
convert a log level of the logging module to a log level suitable for the logging Postgres DB
- swh.core.logger.get_extra_data(record: LogRecord) Dict[str, Any] [source]#
Get the extra data to send to the log handler from the logging record.
- This gets the following data:
all fields in the record data starting with EXTRA_LOGDATA_PREFIX
arguments to the logging call (which can either be a tuple, or a dict if the arguments were named)
if this is called within a celery task, the following data: - the (uu)id of the task - the name of the task - any task keyword arguments named for values in LOGGED_TASK_KWARGS
- swh.core.logger.flatten(data: Any, separator: str = '_') Generator[Tuple[str, Any], None, None] [source]#
Flatten the data dictionary into a flat structure
- class swh.core.logger.JournalHandler(level=0, sender_function=<function send>, **kwargs)[source]#
Bases:
JournalHandler
Initializes the instance - basically setting the formatter to None and the filter list to empty.
- emit(record)[source]#
Write record as a journal event.
MESSAGE is taken from the message provided by the user, and PRIORITY, LOGGER, THREAD_NAME, CODE_{FILE,LINE,FUNC} fields are appended automatically. In addition, record.MESSAGE_ID will be used if present.
This also records all the extra data fetched by get_extra_data.