Skip to main content

Project in development phase.

Project description

nextlog

This is a python logging library which asynchronously dispatches logs to monitoring services like loki. It uses the OOTB python logging library as its base.
Whenever the logger statement - logger.info() / logger.debug() / logger.error() etc. gets executed, the log is pushed onto a redis queue.
A process running on separate thread will keep dispatching those logs to the specified loki endpoint.

Features

  • Seamless Integration: nextlog builds upon the Python logging library, so its usage is similar and familiar.
  • Async Dispatch: Logs are asynchronously dispatched to monitoring services like Loki, ensuring minimal impact on the main code flow.
  • Redis Backup: Utilizes Redis to temporarily store logs in case the monitoring service (e.g., Loki) is unavailable.

Setup

Install the library

pip3 install nextlog

Setup redis server

docker run -d --name redis-stack-server -p 6379:6379 redis/redis-stack-server:latest

Usage

from nextlog import Logger
import logging

# Define labels for logs
labels = {'source': 'localhost'}

# Loki server URL
loki_url = "http://localhost:3100/api/prom/push"

# Initialize nextlog logger
logger = Logger(name="my_logger", level=logging.DEBUG, loki_url=loki_url, labels=labels)

# Log messages
logger.debug("DEBUG log test 0")
logger.warning("WARNING log test 0")
logger.error("ERROR log test 0")
logger.critical("CRITICAL log test 0")

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

nextlog-0.0.2.tar.gz (3.8 kB view hashes)

Uploaded Source

Built Distribution

nextlog-0.0.2-py3-none-any.whl (4.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page