Skip to content
This repository has been archived by the owner on Feb 15, 2024. It is now read-only.

intento/chunk_logger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)