Metadata-Version: 2.4
Name: sag-py-logging-logstash
Version: 3.0.5
Summary: Python logging logstash handler
Home-page: https://github.com/SamhammerAG/sag_py_logging_logstash
Author: Samhammer AG
Author-email: support@samhammer.de
License: MIT
Project-URL: Documentation, https://github.com/SamhammerAG/sag_py_logging_logstash
Project-URL: Bug Reports, https://github.com/SamhammerAG/sag_py_logging_logstash/issues
Project-URL: Source, https://github.com/SamhammerAG/sag_py_logging_logstash
Keywords: logging,logstash
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Software Development
Classifier: Topic :: System :: Logging
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.txt
Requires-Dist: limits<6.0.0,>=5.8.0
Requires-Dist: requests>=2.32.5
Provides-Extra: dev
Requires-Dist: build>=1.2.2.post1; extra == "dev"
Requires-Dist: coverage-lcov; extra == "dev"
Requires-Dist: mock; extra == "dev"
Requires-Dist: mypy; extra == "dev"
Requires-Dist: pytest; extra == "dev"
Requires-Dist: pytest-asyncio; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: ruff; extra == "dev"
Requires-Dist: toml; extra == "dev"
Requires-Dist: types-mock; extra == "dev"
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: provides-extra
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# sag_py_logging_logstash

[![Maintainability][codeclimate-image]][codeclimate-url]
[![Coverage Status][coveralls-image]][coveralls-url]
[![Known Vulnerabilities](https://snyk.io/test/github/SamhammerAG/sag_py_logging_logstash/badge.svg)](https://snyk.io/test/github/SamhammerAG/sag_py_logging_logstash)

[coveralls-image]:https://coveralls.io/repos/github/SamhammerAG/sag_py_logging_logstash/badge.svg?branch=master
[coveralls-url]:https://coveralls.io/github/SamhammerAG/sag_py_logging_logstash?branch=master
[codeclimate-image]:https://api.codeclimate.com/v1/badges/5e8f1c5bef6aeecd543d/maintainability
[codeclimate-url]:https://codeclimate.com/github/SamhammerAG/sag_py_logging_logstash/maintainability


Python Logstash Async is an asynchronous Python logging handler to submit
log events to a remote Logstash instance.
It based on  open source library, see the documentation http://python-logstash-async.readthedocs.io/en/latest/.
In this version transporter is limited to HTTPTransport, according to  Logstash intern installation requirements.

Unlike most other Python Logstash logging handlers, this package works asynchronously
by collecting log events from Python's logging subsystem and then transmitting the
collected events in a separate worker thread to Logstash.
This way, the main application (or thread) where the log event occurred, doesn't need to
wait until the submission to the remote Logstash instance succeeded.

This is especially useful for applications like websites or web services or any kind of
request serving API where response times matter.

## Usage

Example::

    from logstash_async.handler import AsynchronousLogstashHandler
    from logstash_async.formatter import LogstashFormatter
    import logging

    logstash_handler = AsynchronousLogstashHandler(
        host='my_host',
        port=123,
        username='my_user',
        password='my_password',
        index_name = 'my_index')
    logstash_formatter = LogstashFormatter( extra_prefix='',
    extra={'customer': "name", 'ap_environment': "local"})
    logstash_handler.setFormatter(logstash_formatter)

    logging_handlers = []
    logging_handlers.append(logstash_handler)

    logging.basicConfig(
    level="INFO",
    format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
    handlers=logging_handlers)

    logging.getLogger().info("Logging Message", extra = {'new_field':"value"})


### Installation
pip install sag-py-logging-logstash

## How to start developing

### With vscode

Just install vscode with dev containers extension. All required extensions and configurations are prepared automatically.

### With pycharm

* Install latest pycharm
* Configure the python interpreter/venv
* pip install requirements-dev.txt
* Restart pycharm

## How to publish
* Update the version in setup.py and commit your change
* Create a tag with the same version number
* Let github do the rest

## How to test

To avoid publishing to pypi unnecessarily you can do as follows

* Tag your branch however you like
* Use the chosen tag in the requirements.txt-file of the project you want to test this library in, eg. `sag_py_logging_logstash==<your tag>`
* Rebuild/redeploy your project
