A modern way to auto log system errors
Project description
Features
- Deduplicated Logging: Prevents duplicate log entries within each log file, keeping your logs concise and clean.
- Per-Level Log Files: Saves log entries to separate files by level (
Debug.txt,Info.txt,Warning.txt,Error.txt,Critical.txt) for easy tracking and analysis. - Automatic Log Cleanup: Periodically purges log entries older than your retention window (default: 24 hours), with full customization.
- Thread-Safe: All logging and cleanup operations are safe for multi-threaded environments.
- Console Output: Only errors and critical logs are printed to the console by default, with consistent formatting.
- Flexible Integration: Just call
configureBitSig(logsDir)and start logging—no need to rewrite your codebase.
Installation
pip install BitSig
Quick Start
from BitSig import configureBitSig
from pathlib import Path
import logging
# Initialize BitSig (set your desired logs directory)
logsDir = Path("logs")
configureBitSig(logsDir)
# Use standard logging
def loggingErrorTest(self):
try:
# Simulate an error for testing
raise ValueError("This is a test error for logging.")
except Exception as e:
logger.error(f"An error occurred", exc_info=True)
How It Works
- Deduplication: BitSig compares each new log entry (except the timestamp/level prefix) to recent entries in its level’s file and writes only unique messages.
- Cleanup:
Log files are automatically cleaned in the background, keeping only entries within your retention window (default: 24 hours, configurable with
LOG_RETENTION_HOURSin your.envor environment). - Retention:
Customize how long logs are kept by setting the
LOG_RETENTION_HOURSenvironment variable.
Configuration
-
Log Directory: Pass any
PathtoconfigureBitSig(). Directory will be created if missing. -
Log Retention: Set the number of hours to keep log entries:
LOG_RETENTION_HOURS=48(in your
.envor system environment) -
Threaded Cleanup: BitSig launches a daemon thread to clean logs every hour. No user intervention needed.
Advanced Usage
- Multiple Loggers: All loggers in your app will use the same log directory and handlers by default.
Notes
- BitSig is compatible with Python 3.8+ and all standard
loggingcalls. - Log file deduplication works at the message-body level for maximum efficiency.
- BitSig is optimized for long-running, high-traffic, or mission-critical systems.
Code Examples
You can find code examples on my GitHub repository.
License
This project is licensed under the Apache License, Version 2.0. Copyright 2025 Tristan McBride Sr.
Acknowledgements
Project by:
- Tristan McBride Sr.
- Sybil
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bitsig-0.1.2.tar.gz.
File metadata
- Download URL: bitsig-0.1.2.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5718728fbbf21291e58720e31a2a8a2a4a7fad6b2a7d6ed9107bbbf2e50ff965
|
|
| MD5 |
21d9da1f7868ff4227954898076f6ffb
|
|
| BLAKE2b-256 |
4ee62f907d44ef6518327cc595435d625699dec2f0a8f6b57db4003457e3ed0e
|
File details
Details for the file bitsig-0.1.2-py3-none-any.whl.
File metadata
- Download URL: bitsig-0.1.2-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c7dbe20f42f03f4d2d290aed58e3376b1a439c7fbe33d5adae420d47ee007e82
|
|
| MD5 |
62490cde2e396aa79f0bc1ca0668cbde
|
|
| BLAKE2b-256 |
71632b8f73c636e3be7c790556475ef02098296c8bbd2f4cc2bb0606003a6e8d
|