Skip to main content

Inject logging handler for printing message in the format captured by pipeline

Project description

logging-pipeline

Python module to inject logging handler for printing message in the format captured by pipeline.

Install with:

pip install logging-pipeline

If logging is imported a handler is added to the root logger to print the error and warning messages in addition with a format recognized by the pipeline environment executing the script. If the script is executed outside a pipeline nothing is printed. Supported pipelines are:

  • Azure pipelines
  • GitHub actions
  • User defined by environment variables LOGGING_PIPELINE_WARNING_MESSAGE_FORMAT and LOGGING_PIPELINE_ERROR_MESSAGE_FORMAT. The value is used to configure the python logger with {}-format, see LogRecord attributes. E.g. LOGGING_PIPELINE_ERROR_MESSAGE_FORMAT="::%(filename)s:%(lineno)d::%(levelname)s::%(message)s::"

Compatibility

logging-pipeline uses a live-patching system to target the logging library and add a handler.

PyInstaller

The method used to automatically adding a logging handler relies on a .pth file script that python loads at startup. This method does not work when a python application is bundled into an executable with PyInstaller (or similar). If you want to use this tool in an application built with PyInstaller it will need to be manually enabled in your application. This can be done by adding the following line to the top of your main application script:

import logging_pipeline.wrapt_logging

This must be run before logging is imported.

Acknowledgements

The method of patching at runtime is built from the pip_system_certs module.

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

logging_pipeline-0.2.0.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

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

logging_pipeline-0.2.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: logging_pipeline-0.2.0.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for logging_pipeline-0.2.0.tar.gz
Algorithm Hash digest
SHA256 b108009ddde751562dabf9916b67256b7e2f51567409de218c3e42a92f75f3c3
MD5 a0f06b19fbd98bff1a0539588ee84497
BLAKE2b-256 d9c88d9f8fd8565dc7dc235032de1559535e7413816ea77d11569b29c834db3b

See more details on using hashes here.

File details

Details for the file logging_pipeline-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for logging_pipeline-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f36d02e7d40b5029828539aae6d31587d55594a429dccd956f8c58f00c4941d2
MD5 edbe0910688a426b036c1be3315e9ec1
BLAKE2b-256 3c0c086e058169dd6620011d330994d4e3e5b325f7446c9905fa0eb1c3719fa0

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