logging_ldp.formatters
— Formatters¶
-
class
logging_ldp.formatters.
LDPGELFFormatter
¶ A subclass of
logging_ldp.GELFFormatter
to format LogRecord into GELF.-
__init__
(token, schema=<logging_ldp.schemas.LDPSchema>, null_character=True, JSONEncoder=json.JSONEncoder, exclude_patterns=None)¶ A GELF formatter to format a
logging.LogRecord
into GELF.Parameters: - token (str) – The LDP token (aka. X-OVH-TOKEN).
- schema (logging_ldp.schemas.LDPSchema) – The marshmallow schema to use to format data.
- null_character (bool) – Append a ‘0’ at the end of the string. It depends on the input used.
- JSONEncoder (json.JSONEncoder) – A custom json encoder to use.
- exclude_patterns (list|None) – List of regexp used to exclude keys
-
format
(record)¶ Format the specified record into json using the schema which MUST inherit from
logging_ldp.schemas.LDPSchema
to support LDP casting type (see: The field naming convention).Parameters: record (logging.LogRecord) – Contains all the information pertinent to the event being logged. Returns: A JSON dump of the record. Return type: str
-
logging_ldp.handlers
— Handlers¶
-
class
logging_ldp.handlers.
LDPGELFTCPSocketHandler
¶ The
LDPGELFTCPSocketHandler
, which inherit fromlogging_gelf.GELFTCPSocketHandler
, sends logging output to a TCP/TLS network socket.-
__init__
(hostname)¶ Initialize a TCP/TLS connection to the given hostname.
Parameters: hostname (str) – Hostname/FQDN to connect to.
-
logging_ldp.schemas
— Schemas¶
-
class
logging_ldp.schemas.
LDPSchema
¶ Schema which allow to specify a mapping for
logging.LogRecord
. It based onlogging_gelf.schemas.GelfSchema
. All schema MUST inherit from this.-
static
_forge_key
(key, value)¶ Allow to rename keys to cast types (see: The field naming convention).
Parameters: - key (str) – The attribute key
- value (Any) – The attribute value
Returns: The key suffixed
Return type: str
-
static