mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-11-22 03:31:32 +00:00
Check for a generic Mapping type instead of dict
This commit is contained in:
parent
1b274fa019
commit
52280acf41
@ -2,6 +2,7 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from typing import TextIO, Union
|
from typing import TextIO, Union
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
|
from collections.abc import Mapping
|
||||||
from traceback import format_exception
|
from traceback import format_exception
|
||||||
from logging import DEBUG, getLogger, Handler, Formatter, Filter
|
from logging import DEBUG, getLogger, Handler, Formatter, Filter
|
||||||
|
|
||||||
@ -81,7 +82,7 @@ class LogFormatter(Formatter):
|
|||||||
def format(self, record):
|
def format(self, record):
|
||||||
time = datetime.utcfromtimestamp(record.created).strftime('%H:%M:%S')
|
time = datetime.utcfromtimestamp(record.created).strftime('%H:%M:%S')
|
||||||
if record.args:
|
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))
|
clean_args = tuple((self.trim(arg) for arg in tuple_args))
|
||||||
message = record.msg % clean_args
|
message = record.msg % clean_args
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user