Skip to main content

out-of-the-box, ready-to-use JSON logger

Project description

jonson

out-of-the-box, ready-to-use JSON logger

from jonson import logger

logger.info("Something going as expected", { "host": socket.gethostname() })
logger.warn("Something must have gone terribly wrong")

except Exception as e:
    logger.error(e, { description: "something descriptive" })

Log level

Create logger instance with a minimal log level

from jonson import Logger

logger = Logger("warn")

logger.info("Something going as expected", { "host": socket.gethostname() }) # ignored
logger.warn("Something must have gone terribly wrong") # sent

Log levels hirarchy

A few synonyms are available for convenience

  1. trace, verbose
  2. debug
  3. info, log
  4. warn
  5. error
  6. critical, fatal, panic

For example, a logger with log level "warn" will only print logs with level "warn", "error", or "critical".

Arguments

Create: Logger class accepts one or two arguments:

  1. {string} Case insensitive name of minimal log level. defaults to "info"
  2. {dictionary} {'Key':'Value'} pairs, optional. Persistent enrichment fields for all log records
logger = Logger(os.environ["LOG_LEVEL"], { "host": socket.gethostname() })

Send: Logger functions accept one or two arguments:

  1. {any} Record's "message" field. Traditionally this would be a string or an exception.
  2. {dictionary} {'Key':'Value'} pairs, optional. Values should be JSON serializable
logger.info("something, something", { dark: "side" })

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

jonson-1.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

jonson-1.1.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file jonson-1.1.1.tar.gz.

File metadata

  • Download URL: jonson-1.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for jonson-1.1.1.tar.gz
Algorithm Hash digest
SHA256 b523df1568027e8ea6af81c1712532fec8f58ea5b827c924eb2d78a0c4df83b0
MD5 1042b3a59f752cc4ab0e594599b0e33f
BLAKE2b-256 13cae86c2b670e936871f6820aa49642d8043e3c93d7c618f1e3c2ac7c601f3a

See more details on using hashes here.

File details

Details for the file jonson-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: jonson-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.14

File hashes

Hashes for jonson-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c2f99d10216edb972f63358a6ec311d87190d569def39b582e7a68538a9a15df
MD5 825652cf1d514289e07d6ad6439008cf
BLAKE2b-256 d382bf043a863a9c16307a5fccbb55ca17dc595ebe0793009c660be7f3d4f610

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