JSON formatted logging for Datadog
Project description
Datadog-log
Write out JSON formatted logs in the format and with the attributes that Datadog expects
Installation
pip install datadog-log
Setup
The simplest way is to use init_logging()
which will log to stdout.
If you want finner control then you can use DatadogFormatter
directly. See init_logging
for example usage.
Logging
Use logging as normal:
import logging
import datadoglog
datadoglog.init_logging()
log = logging.getLogger("example")
log.setLevel(logging.INFO)
log.info("Some info", extra={"extra": ["json"]})
The above would output json like below (but as a single line, shown 'pretty' here for readability):
{
"message": "Some info",
"extra": ["json"],
"timestamp": "2021-09-18T21:14:07.707371+00:00",
"status": "info",
"logger": {
"name": "example",
"method_name": "<stdin>.<module>",
"thread_name": "MainThread"
}
}
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
datadog-log-1.3.0.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for datadog_log-1.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 994e241c3eae7e2062979254fb216c699d8a60ad24230ea346fa8e02c92a8a0c |
|
MD5 | dd9e140cd2413b2b7d4069a859e1adc5 |
|
BLAKE2b-256 | a2877ae5d6f64861c5829f185e72381f82f8af9f9f93e80b9888a15c1a2426a8 |