Skip to content

Commit 5e042bb

Browse files
kushacmanaha
authored andcommitted
Fix issue with dictionary logging (cmanaha#47)
Elasticsearch failed at 'arg' field parsing if log function argument is dictionary. Example: logging.info("POST query: %s", {'any': 'dictionary'}) This fix enforces conversion of log arguments to strings.
1 parent 6765a24 commit 5e042bb

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cmreslogging/handlers.py

+2
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,8 @@ def emit(self, record):
328328
rec = self.es_additional_fields.copy()
329329
for key, value in record.__dict__.items():
330330
if key not in CMRESHandler.__LOGGING_FILTER_FIELDS:
331+
if key == "args":
332+
value = tuple(str(arg) for arg in value)
331333
rec[key] = "" if value is None else value
332334
rec[self.default_timestamp_field_name] = self.__get_es_datetime_str(record.created)
333335
with self._buffer_lock:

0 commit comments

Comments
 (0)