Metadata-Version: 2.4
Name: logging-pipeline
Version: 0.4.0
Summary: Inject logging handler for printing message in the format captured by pipeline
Project-URL: Github, https://github.com/spacetown/logging_pipeline
Project-URL: Issues, https://github.com/spacetown/logging_pipeline/issues
Author-email: Michael Förderer <michael.foerderer@gmx.de>
License-Expression: BSD-3-Clause
License-File: LICENSE
Keywords: ADO,Azure,GitHub,Pipeline
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: BSD License
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Quality Assurance
Classifier: Topic :: Software Development :: Testing
Classifier: Topic :: Utilities
Requires-Python: >=3.8
Requires-Dist: wrapt>=1.10.4
Description-Content-Type: text/markdown

# logging-pipeline

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

Install with:

```bash
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](https://docs.python.org/3/library/logging.html#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:

```python
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](https://pypi.org/project/pip-system-certs/)
module.
