Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_object_to_json(obj, expected):
result = gelf.object_to_json(obj)
assert result == expected
def __init__(self, debug=False, version='1.1', include_extra_fields=False, compress=False,
static_fields=None, json_default=gelf.object_to_json, **kwargs):
"""
Logging handler that transforms each record into GELF (graylog extended log format) and sends it over TCP.
:param debug: include debug fields, e.g. line number, or not
:param include_extra_fields: include non-default fields from record to message, or not
:param json_default: function that is called for objects that cannot be serialized to JSON natively by python
:param kwargs: additional fields that will be included in the log message, e.g. application name.
Each additional field should start with underscore, e.g. _app_name
"""
self.debug = debug
self.version = version
self.additional_fields = static_fields if static_fields else kwargs
self.include_extra_fields = include_extra_fields
self.additional_fields.pop('_id', None)
self.domain = socket.gethostname()