Skip to content

Standalone logger for emitting NDJSON-formatted log events in Python apps.

License

Notifications You must be signed in to change notification settings

twuni/python-logging-ndjson

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NDJSON Logging | Twuni

Standalone logger for emitting NDJSON-formatted logs.

Part of the Twuni Twelve-Factor App suite for Python apps.

Installing

To install directly:

pip install --index https://releases.twuni.dev/python/packages twuni_logging_ndjson

Alternatively, you can create a file with the following contents:

--index https://releases.twuni.dev/python/packages
twuni_logging_ndjson

...and install via that as a requirements file using pip install -r <file>.

Usage

For full documentation, see the API Reference.

Here's some example usage with comments:

from twuni_logging_ndjson import Logger

logger = Logger(level="DEBUG")
# by setting the level to DEBUG (lowest priority), all log levels are emitted

logger.debug("example")
# prints {"event":{"type":"example"},"level":"DEBUG","timestamp":"<ISO-8601 timestamp>"} to standard output

logger.info("hello", {"message": "Hello, world!"})
# prints {"event":{"context":{"message":"Hello, world!"},"type":"hello"},"level":"INFO","timestamp":"<ISO-8601 timestamp>"} to standard output

# other logging levels are: warning, error, critical

About

Standalone logger for emitting NDJSON-formatted log events in Python apps.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages