Skip to main content

defaults for structlog

Project description

logma

Build PyPI version fury.io

Great default logging.

Usage

Install:

% pip install logma

Example file:

% cat example/logex.py
from logma.wech import datlog
import structlog


# auto detects tty and outputs json or text accordingly
datlog()


log = structlog.get_logger("logex")


def main():
    log.info("Hello")
    log.warn("Hello")
    log.error("Hello")
    log.debug("Hello")


if __name__ == "__main__":
    main()

Usage in the console (it uses colorama):

% env/bin/python example/logex.py
2020-03-04T11:27:41.523012Z [info     ] Hello                          [logex] func=main lineno=13 module=__main__
2020-03-04T11:27:41.529786Z [warning  ] Hello                          [logex] func=main lineno=14 module=__main__
2020-03-04T11:27:41.529982Z [error    ] Hello                          [logex] func=main lineno=15 module=__main__
2020-03-04T11:27:41.530156Z [debug    ] Hello                          [logex] func=main lineno=16 module=__main__

Usage in background (json output to stderr):

% env/bin/python example/logex.py &> logex.log && cat logex.log
{"event": "Hello", "level": "info", "logger": "logex", "timestamp": "2020-03-04T11:28:17.565149Z", "module": "__main__", "lineno": 13, "func": "main"}
{"event": "Hello", "level": "warning", "logger": "logex", "timestamp": "2020-03-04T11:28:17.571626Z", "module": "__main__", "lineno": 14, "func": "main"}
{"event": "Hello", "level": "error", "logger": "logex", "timestamp": "2020-03-04T11:28:17.571821Z", "module": "__main__", "lineno": 15, "func": "main"}
{"event": "Hello", "level": "debug", "logger": "logex", "timestamp": "2020-03-04T11:28:17.571995Z", "module": "__main__", "lineno": 16, "func": "main"}

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

logma-0.2.0.tar.gz (5.3 kB view details)

Uploaded Source

File details

Details for the file logma-0.2.0.tar.gz.

File metadata

  • Download URL: logma-0.2.0.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.20.1 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.19.1 CPython/3.6.7

File hashes

Hashes for logma-0.2.0.tar.gz
Algorithm Hash digest
SHA256 689c59388092b892399c13514c6389ac486b7035b0d1a8255f482acdcf6f4e24
MD5 b92d3ed2c3e85baeb686ba62c479e9c2
BLAKE2b-256 7a50509823592a0f342d965ab6e329dabc1d85316ff5e8fdebf5d3aff56a83d6

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