Skip to main content

Logging helper library.

Project description

fw-logging

Logging helper library for standard logging configuration, JSON formatting, and for tailing (non-)structured logs re-formatted and colorized for humans.

Installation

pip install fw-logging

Usage

logformat

Use the CLI utility logformat to re-format (Flywheel) logs for humans:

# pipe json and/or text logs directly
kubectl logs my-pod | logformat
# OR pass a filename containing the same
kubectl logs my-pod > my-pod.log
logformat my-pod.log
# OR pass a rich text file (.rtf) of logs
logformat my-pod-log.rtf

Library

Use the fw_logging module to set up python logging in 2 lines:

import fw_logging
fw_logging.setup_logging()

The default configuration sets up logging at level INFO to stdout, formatted as text with colorized levels and caller information.

To emit structured JSON logs in production just override the formatter using an environment variable: FW_LOG_FORMATTER=json.

Table of main config options and the corresponding envvars:

Envvar Default Alternative / Example
FW_LOG_LEVEL INFO DEBUG
FW_LOG_HANDLER stdout stderr
FW_LOG_FORMATTER text json
FW_LOG_LOGGERS {"pika":"ERROR"}
FW_LOG_FILTERS {"lgr":{"msg":"rgx"}}

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

fw_logging-1.5.0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file fw_logging-1.5.0-py3-none-any.whl.

File metadata

  • Download URL: fw_logging-1.5.0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Linux/5.15.154+

File hashes

Hashes for fw_logging-1.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2e75b7290156d68a7e9ee8f2fe9669c2809f1c5604d007e03d3125a4ffd3c1d9
MD5 7293cf007eca25539c0eda51cbd1acd7
BLAKE2b-256 41e516f632604a6fb7691f543d935228accd8362e42891d05b389a1a8134cc82

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