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-1.0.2.tar.gz
(3.9 kB
view hashes)