django_dd_logger.formatters package¶
Submodules¶
django_dd_logger.formatters.datadog module¶
- class django_dd_logger.formatters.datadog.DataDogJSONFormatter(fmt=None, datefmt=None, style='%', validate=True, *, defaults=None)[source]¶
Bases:
JSONFormatter- extra_from_record(record)[source]¶
Returns extra dict you passed to logger.
The extra keyword argument is used to populate the __dict__ of the LogRecord.
- json_record(message, extra, record)[source]¶
Prepares a JSON payload which will be logged.
Override this method to change JSON log format.
- Parameters:
message – Log message, e.g., logger.info(msg=’Sign up’).
extra – Dictionary that was passed as extra param logger.info(‘Sign up’, extra={‘referral_code’: ‘52d6ce’}).
record – LogRecord we got from JSONFormatter.format().
- Returns:
Dictionary which will be passed to JSON lib.
- to_json(record)[source]¶
Converts record dict to a JSON string.
It makes best effort to serialize a record (represents an object as a string) instead of raising TypeError if json library supports default argument. Note, ujson doesn’t support it. ValueError and OverflowError are also caught to avoid crashing an app, e.g., due to circular reference.
Override this method to change the way dict is converted to JSON.