chunk-logger

SafeTimedChunksFileHandler


License
MIT
Install
pip install chunk-logger==1.0.0

Documentation

chunk_logger

Description

SafeTimedChunksFileHandler is concurrent safe FileHandler that splits logs into N-minute chunks. It also creates a directories in path if they are missing. Used some code from safe_logger

Install

pip3 install chunk_logger

Usage

import os
import logging
from chunk_logger import SafeTimedChunksFileHandler

LOG_FILE = '/tmp/debug.log'

logging.basicConfig(level=logging.DEBUG)
root = logging.root
log_handler = SafeTimedChunksFileHandler(LOG_FILE, minutesInterval=10, oldCount=(60/10)*24*31)  # 10min chunks, 31d retention
log_handler.setLevel(logging.DEBUG)
root.addHandler(log_handler)