Json Log Formatter
Project description
==================
`Repository <https://bitbucket.org/bear_belly/json_log_formatter>`__
Formats log output in JSON format. Shows all fields of a log record.
Here is an example of the output.
::
...
{
"name": "somemodule.util",
"msg": "This is a log message",
"args": "()",
"levelname": "DEBUG",
"levelno": "10",
"pathname": "/path/to/pyfile.py",
"filename": "util.py",
"module": "util",
"exc_info": "None",
"exc_text": "None",
"stack_info": "None",
"lineno": "217",
"funcName": "do_something",
"created": "1520373828.7142632",
"msecs": "714.2632007598877",
"relativeCreated": "2531.79669380188",
"thread": "140244615616320",
"threadName": "MainThread",
"processName": "MainProcess",
"process": "11519"
}
{
"name": "somemodule.util",
"msg": "This is an error message",
"args": "()",
"levelname": "ERROR",
"levelno": "10",
"pathname": "/path/to/otherfile.py",
"filename": "util.py",
"module": "util",
"exc_info": "None",
"exc_text": "None",
"stack_info": "None",
"lineno": "217",
"funcName": "do_something",
"created": "1520373218.7142632",
"msecs": "810.2632007598877",
"relativeCreated": "8531.79669380188",
"thread": "140244615616320",
"threadName": "MainThread",
"processName": "MainProcess",
"process": "11519"
}
...
Installation
------------
Install as you would any other python package::
::
$ pip install json-log-formatter
Usage
-----
To use the formatter, include it in logging config as you would other
formatters.
The formatter takes one optional argument ``json_kwargs``. These are
keywords that are passed directly to
```json.dumps()`` <https://docs.python.org/3/library/json.html#json.dumps>`__.
YAML Example
~~~~~~~~~~~~
::
logging:
version: 1
formatters:
...
json:
class: json_log_formatter.JsonFormatter
json_kwargs:
indent: 2
...
handlers:
....
json_console:
class: logging.StreamHandler
formatter: json
...
loggers:
...
console:
level: DEBUG
handler: json_console
...
root:
...
level: DEBUG
handlers: [json_console, ]
...
Dict example
~~~~~~~~~~~~
::
'logging': {
'version': 1,
'formatters': {
...
'json': {
'class': 'json_log_formatter.JsonFormatter',
'json_kwargs': {
indent: 2
...
},
...
},
...
},
'handlers': {
....
'json_console': {
'class': 'logging.StreamHandler',
'formatter': 'json',
},
...
},
'loggers': {
...
'console': {
'level': 'DEBUG',
'handler': 'json_console',
},
...
},
'root': {
...
'level': 'DEBUG',
'handlers': ['json_console', ]
...
},
...
}
Home-page: UNKNOWN
Author: Jordan Hewitt
Author-email: jordan.h@startmail.com
License: GPLv3
Description: UNKNOWN
Keywords: json log output format flannel
Platform: UNKNOWN
`Repository <https://bitbucket.org/bear_belly/json_log_formatter>`__
Formats log output in JSON format. Shows all fields of a log record.
Here is an example of the output.
::
...
{
"name": "somemodule.util",
"msg": "This is a log message",
"args": "()",
"levelname": "DEBUG",
"levelno": "10",
"pathname": "/path/to/pyfile.py",
"filename": "util.py",
"module": "util",
"exc_info": "None",
"exc_text": "None",
"stack_info": "None",
"lineno": "217",
"funcName": "do_something",
"created": "1520373828.7142632",
"msecs": "714.2632007598877",
"relativeCreated": "2531.79669380188",
"thread": "140244615616320",
"threadName": "MainThread",
"processName": "MainProcess",
"process": "11519"
}
{
"name": "somemodule.util",
"msg": "This is an error message",
"args": "()",
"levelname": "ERROR",
"levelno": "10",
"pathname": "/path/to/otherfile.py",
"filename": "util.py",
"module": "util",
"exc_info": "None",
"exc_text": "None",
"stack_info": "None",
"lineno": "217",
"funcName": "do_something",
"created": "1520373218.7142632",
"msecs": "810.2632007598877",
"relativeCreated": "8531.79669380188",
"thread": "140244615616320",
"threadName": "MainThread",
"processName": "MainProcess",
"process": "11519"
}
...
Installation
------------
Install as you would any other python package::
::
$ pip install json-log-formatter
Usage
-----
To use the formatter, include it in logging config as you would other
formatters.
The formatter takes one optional argument ``json_kwargs``. These are
keywords that are passed directly to
```json.dumps()`` <https://docs.python.org/3/library/json.html#json.dumps>`__.
YAML Example
~~~~~~~~~~~~
::
logging:
version: 1
formatters:
...
json:
class: json_log_formatter.JsonFormatter
json_kwargs:
indent: 2
...
handlers:
....
json_console:
class: logging.StreamHandler
formatter: json
...
loggers:
...
console:
level: DEBUG
handler: json_console
...
root:
...
level: DEBUG
handlers: [json_console, ]
...
Dict example
~~~~~~~~~~~~
::
'logging': {
'version': 1,
'formatters': {
...
'json': {
'class': 'json_log_formatter.JsonFormatter',
'json_kwargs': {
indent: 2
...
},
...
},
...
},
'handlers': {
....
'json_console': {
'class': 'logging.StreamHandler',
'formatter': 'json',
},
...
},
'loggers': {
...
'console': {
'level': 'DEBUG',
'handler': 'json_console',
},
...
},
'root': {
...
'level': 'DEBUG',
'handlers': ['json_console', ]
...
},
...
}
Home-page: UNKNOWN
Author: Jordan Hewitt
Author-email: jordan.h@startmail.com
License: GPLv3
Description: UNKNOWN
Keywords: json log output format flannel
Platform: UNKNOWN
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file python3_json_log_formatter-1.6.1.linux-x86_64.tar.gz
.
File metadata
- Download URL: python3_json_log_formatter-1.6.1.linux-x86_64.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15469065e02b52e41188a4aa1ac366b6a87d528ca8781a412ecf3c56caae7214 |
|
MD5 | a1f616847e37dbe3c2908271987c8094 |
|
BLAKE2b-256 | 11ca230e75aed543d850f16cb4bde6ac07ab11e28b1b51605f74361e7d6ac6d4 |
File details
Details for the file python3_json_log_formatter-1.6.1-py3-none-any.whl
.
File metadata
- Download URL: python3_json_log_formatter-1.6.1-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a351b51acaddbc89bc22a1188f3e21e59dac6f2e1e355edb9c8dc9b189f3eeb |
|
MD5 | 1761a60ba2020b9e021ecb8d1cf9a75d |
|
BLAKE2b-256 | 264a6a81a388024dd3f3d2d971e4b3024086d27431a054e336400a53fdf7e80b |