Skip to main content

Asynchronous python logger for Loki

Project description

Ploki

Asynchronous python logger for Loki

Usage

Send all logs

import logging
from ploki import BasicAuth, Ploki, ignore_logger

Ploki().initialize(url="http://localhost:3100", level=logging.INFO)
ignore_logger("ignored")

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

logger.info("This log will be sent to Loki.")
ignored.warning("This logger is always ignored.")

# reinitialize
Ploki().initialize(
    url="http://localhost:3100",
    auth=BasicAuth("user", "password"),
    labels={"application": "my-app"},
)

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

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

Ploki().terminate()  # disable Ploki

Send from a single logger

import logging
from ploki import PlokiHandler

handler = PlokiHandler("http://localhost:3100")
logger = logging.getLogger("my-app")
logger.addHandler(handler)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for ploki, version 0.2.1
Filename, size File type Python version Upload date Hashes
Filename, size ploki-0.2.1-py3-none-any.whl (5.1 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size ploki-0.2.1.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page