semvec/pypi-packages huggingface dataset:
ploki 0.4.1
Automatic logging from Python to Loki.
License: MIT
Requires Python: >=3.6.0

Ploki
=====
Automatic logging from Python to Loki.  
[<img src="https://github.com/landmaj/ploki/workflows/tests/badge.svg" width="100" alt="Build Status">](https://github.com/landmaj/ploki/actions)

Usage
-----
Send all logs
```python
import logging
from ploki import Ploki, ignore_logger

Ploki().initialize(
    url="http://localhost:3100",
    tags={"application": "ploki"},
    level=logging.INFO,
)
ignore_logger("ignored")

logger = logging.getLogger("my-app")
ignored = logging.getLogger("ignored")

logger.info(
    "This log will be sent to Loki.",
    extra={"tags":  {"custom": "label"}},
)
ignored.warning("This logger will be ignored.")

# reinitialize
Ploki().initialize(
    url="http://localhost:3100",
    auth=("user", "password"),
)

with ignore_logger("my-app"):
    logger.error("This message will not be sent.")

ignore_logger("you", "can", "pass", "multiple", "loggers")

Ploki().terminate()  # disable Ploki
```

Credits
-------
The original Loki handler and emitter by courtesy of
[Andrey Maslov](https://github.com/greyzmeem/python-logging-loki).

Python logging integration is based on
[Sentry](https://github.com/getsentry/sentry-python).