Skip to content
This repository was archived by the owner on Dec 21, 2024. It is now read-only.

Commit b437839

Browse files
committed
Document and test support for Python 3.8 format strings
1 parent 6d43bde commit b437839

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ formatter = CustomJsonFormatter('one;two')
5858

5959
# is equivalent to:
6060

61-
formatter = jsonlogger.JsonFormatter('(one) (two)')
61+
formatter = jsonlogger.JsonFormatter('%(one)s %(two)s')
6262
```
6363

6464
You can also add extra fields to your json output by specifying a dict in place of message, as well as by specifying an `extra={}` argument.
@@ -80,7 +80,7 @@ class CustomJsonFormatter(jsonlogger.JsonFormatter):
8080
else:
8181
log_record['level'] = record.levelname
8282

83-
formatter = CustomJsonFormatter('(timestamp) (level) (name) (message)')
83+
formatter = CustomJsonFormatter('%(timestamp)s %(level)s %(name)s %(message)s')
8484
```
8585

8686
Items added to the log record will be included in *every* log message, no matter what the format requires.

tests/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def testFormatKeys(self):
6262
'threadName'
6363
]
6464

65-
log_format = lambda x: ['%({0:s})'.format(i) for i in x]
65+
log_format = lambda x: ['%({0:s})s'.format(i) for i in x]
6666
custom_format = ' '.join(log_format(supported_keys))
6767

6868
fr = jsonlogger.JsonFormatter(custom_format)

0 commit comments

Comments
 (0)