add_log_severity

safir.logging.add_log_severity(logger: Logger, method_name: str, event_dict: MutableMapping[str, Any]) MutableMapping[str, Any]

Add the log level to the event dict as severity.

Intended for use as a structlog processor.

This is the same as structlog.stdlib.add_log_level except that it uses the severity key rather than level for compatibility with Google Log Explorer and its automatic processing of structured logs.

Parameters:
  • logger (logging.Logger) – The wrapped logger object.

  • method_name (str) – The name of the wrapped method (warning or error, for example).

  • event_dict (structlog.types.EventDict) – Current context and current event. This parameter is also modified in place, matching the normal behavior of structlog processors.

Returns:

event_dict – The modified EventDict with the added key.

Return type:

structlog.types.EventDict