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.5.0.tar.gz
(3.1 kB
view details)
Built Distribution
File details
Details for the file datadog_log-1.5.0.tar.gz
.
File metadata
- Download URL: datadog_log-1.5.0.tar.gz
- Upload date:
- Size: 3.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7d346860ca33b4db8b5bee746779edaac25a153ffce7f8c47d7e22d1636ef41 |
|
MD5 | e2ba2364c77022dbdfd77a491d048a82 |
|
BLAKE2b-256 | f2ae6941721677f4358d4738922846cd0a3ffc7458f3245125e550dea7ad5f7e |
File details
Details for the file datadog_log-1.5.0-py3-none-any.whl
.
File metadata
- Download URL: datadog_log-1.5.0-py3-none-any.whl
- Upload date:
- Size: 3.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.4 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bf1f7f38f134faa797cd3ec22d0fbe5e71ad4f003699a17751eda15eaa32098 |
|
MD5 | 252e2c6de837dd44de71627bf31475f0 |
|
BLAKE2b-256 | 9fd17ca22ed072362e0b4767fac58157981fc58ad99442f9a3d9a28acf9ee852 |