Skip to content

Commit c6af8e1

Browse files
#2 fix: dictConfig
1 parent 9bd1cf4 commit c6af8e1

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

jsonformatter/jsonformatter.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,15 @@ class JsonFormatter(logging.Formatter):
6969
def parseFmt(self, fmt):
7070
if isinstance(fmt, str):
7171
return json.loads(fmt, object_pairs_hook=dictionary)
72-
elif isinstance(fmt, OrderedDict):
72+
elif isinstance(fmt, dictionary):
7373
return fmt
7474
elif isinstance(fmt, dict):
75-
if sys.version_info < (3, 7):
76-
warnings.warn("Your Python version is below 3.7.0, the key's order of dict may be different from the definition, Please Use `OrderedDict`.", UserWarning)
77-
return dictionary([(k, fmt[k]) for k in sorted(fmt.keys())])
75+
warnings.warn(
76+
"Current Python version is below 3.7.0, the key's order of dict may be different from the definition, Please Use `OrderedDict` replace.", UserWarning)
77+
return dictionary([(k, fmt[k]) for k in sorted(fmt.keys())])
7878
else:
79-
raise TypeError('fmt must be jsong sting, OrderedDcit or dict type.')
79+
raise TypeError(
80+
'The type `%s` is not supported, fmt must be `string` with json format, `OrderedDcit` or `dict` type. ' % type(fmt))
8081

8182
def checkRecordCustomAttrs(self, record_custom_attrs):
8283
if isinstance(record_custom_attrs, dict):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
setup(
1515
name='jsonformatter',
16-
version='0.1.3',
16+
version='0.1.4',
1717
description=(
1818
'Python log in json format.'
1919
),

0 commit comments

Comments
 (0)