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

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

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for fw_logging-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8ee4e5acf8c4cd467e46c1563a16d370a5229a0251eb41607b0c91cb6ad081bc
MD5 b8d7847fc17a3a3cb2829a27eca4567d
BLAKE2b-256 0035aa2b223a1e7a95f731a6abdf943d785ef19d4b23f4c6f24d7bd62a0c593b

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