Check for a generic Mapping type instead of dict

This commit is contained in:
R. Richard 2019-11-12 14:23:09 +01:00
parent 1b274fa019
commit 52280acf41

View File

@ -2,6 +2,7 @@
from datetime import datetime
from typing import TextIO, Union
from dataclasses import dataclass
from collections.abc import Mapping
from traceback import format_exception
from logging import DEBUG, getLogger, Handler, Formatter, Filter
@ -81,7 +82,7 @@ class LogFormatter(Formatter):
def format(self, record):
time = datetime.utcfromtimestamp(record.created).strftime('%H:%M:%S')
if record.args:
tuple_args = (record.args,) if isinstance(record.args, dict) else record.args
tuple_args = (record.args,) if isinstance(record.args, Mapping) else record.args
clean_args = tuple((self.trim(arg) for arg in tuple_args))
message = record.msg % clean_args
else: