Skip to main content

A teensy structured JSON logger for python.

Project description

lignum

A teensy structured JSON logger for python.

Usage

Install lignum with pip:

pip install lignum

Initialize the logger and use the level functions to start logging messages:

import lignum
log = lignum.Logger()
log.info('Application started.') # Prints {"timestamp":1724129120,"message":"Application started.","level":"info"} to STDERR

By default, lignum prints to sys.stderr. You can use another stream type by specifying it in the arguments:

import lignum
log = lignum.Logger(sys.stdout)
log.error('The system is down.') # Prints {"timestamp":17241236120,"message":"The system is down.","level":"error"} to STDOUT

You can use a File as a stream to log to files on disk:

import lignum
with open('log.log','w') as f:
  log = lignum(f)
  log.warn('I will haunt your dreams.') # Prints {"timestamp":17241336120,"message":"I will haunt your dreams.","level":"warn"} to ./log.log

Add additional fields using extra dictionaries:

import lignum
log = lignum()
log.debug('Unknown value.', { 'value': mystery }) # Prints {"timestamp":1724149120,"message":"Unknown value.","level":"debug","value":-32768} to STDERR

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

lignum-0.0.3.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lignum-0.0.3-py2.py3-none-any.whl (1.9 kB view details)

Uploaded Python 2Python 3

File details

Details for the file lignum-0.0.3.tar.gz.

File metadata

  • Download URL: lignum-0.0.3.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for lignum-0.0.3.tar.gz
Algorithm Hash digest
SHA256 b63bd2d037fa6ab9c8b07138ad1bce925e7d9c5ff925d9e04dd41287ef0584f8
MD5 9fee5777b0306f032cc490d60b3992aa
BLAKE2b-256 f4deccadbc0ed034306f9272037ae94a39e5b4e8e6a45d00346cb5e54dbd2da2

See more details on using hashes here.

File details

Details for the file lignum-0.0.3-py2.py3-none-any.whl.

File metadata

  • Download URL: lignum-0.0.3-py2.py3-none-any.whl
  • Upload date:
  • Size: 1.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.5

File hashes

Hashes for lignum-0.0.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e71b587199af6973e5ecf0e9846754f6422cc1cdc105826bd8b89e9b16286001
MD5 2708ea1d650b79dcbd80ee4986b285bc
BLAKE2b-256 d295dfac2bd15803bb5a21ccdb22ba35ef2eebf02bd8fc40e97d99c152df01f7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page