Skip to main content

A Python JSON logger with output matching Pino.js

Project description

pypino

A Python JSON logger with output matching Pino.js

While working in Node.js, I always use Pino.js. The output is quickly parsable by my logging system, but the output is still quite readable for humans. There are several of logging solutions for Python, but rather than write an independent log parser, I wrote a logging module which is compatible with Pino.js.

There are other modules, but nothing that met my list of requirements:

  • Use the same handlers used by Pino, ex: log.warn(...).
  • Be able to pass basic dicts of extra keys to be included in JSON, ex: log.error({"foo": "bar"}, "foo is bar").
  • The output format must CLOSELY match Pino.js. All keys, structure and data formatting should match.
  • Lightweight, low overhead, dependency light.
  • Compatible with older versions of Python.

Example usage:

import pypino

log = pypino.PyPino(name="my-app")

# All common log types. Default log level is ">= info", so trace and debug are not shown
log.trace("log trace is level 10")
log.debug("log debug is level 20")
log.info("log info is level 30")
log.warn("log warn is level 40")
log.error("log error is level 50")
log.fatal("log fatal is level 60")
# out: {"hostname":"myhost","pid":14668,"name":"my-app","level":60,"time":1591994603380,"msg":"log1 fatal"}

# Alter the logging level
log.level("trace")
log.trace("log trace is now shown")

# Add additional kv context
log.warn({"foo": "bar", "biz": 123}, "log warn")
# out: {"hostname":"myhost","pid":14786,"name":"my-app","level":40,"time":1591994920229,"foo":"bar","biz":123,"msg":"log1 warn"}

And just like with Pino, you can pipe the output through pino-pretty.

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

pypino-0.1.0.tar.gz (3.1 kB view details)

Uploaded Source

Built Distribution

pypino-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file pypino-0.1.0.tar.gz.

File metadata

  • Download URL: pypino-0.1.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.3

File hashes

Hashes for pypino-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40f5259eafe98dc69c92f54d8d8527e01cbb9297195e60a75e4fd538d7931f79
MD5 8c5723d7fae3010d6ef0e09cea59314c
BLAKE2b-256 6e3bd1bc5e9a9b904b399a427ad3815238cdaab7fa8918287fb7a785ec9c0e59

See more details on using hashes here.

File details

Details for the file pypino-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pypino-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.3

File hashes

Hashes for pypino-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e8e01b626ac0e592ccfe3cfb44c3dedaf7193f42b2c7eb7151bb4d200238d05
MD5 3fef12d398678c174dc34a1c06dcbff2
BLAKE2b-256 361867fad64591db49a51c7b898aa2a80fe660ea3ebd811c4184ece37d9993ff

See more details on using hashes here.

Supported by

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