A comprehensive, portable logging library available in both Python and JavaScript with consistent APIs and features.
This library provides a robust logging solution with:
- Multiple log levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
- Various formatters: Simple, JSON, Colored, Template
- Flexible handlers: Console, File, Rotating, TimedRotating, Memory
- Configuration helpers: Quick setup for development, production, and specialized use cases
- Singleton registry: Manage multiple loggers across your application
- Location:
Python/Logger/
- Requirements: Python 3.6+
- Installation: Copy the
Logger
folder to your project - Usage: See
Python/USAGE.md
for detailed examples
- Location:
JavaScript/Logger/
- Requirements: Node.js 14+
- Installation: Copy the
Logger
folder to your project - Usage: See
JavaScript/USAGE.md
for detailed examples
from Logger import create_logger, LogLevel
# Create a logger
logger = create_logger('myapp', level='INFO', console=True, file='app.log')
# Use it
logger.info('Application started')
logger.error('An error occurred', extra={'user_id': 123})
import { createLogger, LogLevel } from './Logger/index.js';
// Create a logger
const logger = create_logger('myapp', {
level: 'INFO',
console: true,
file: 'app.log'
});
// Use it
logger.info('Application started');
logger.error('An error occurred', { userId: 123 });
- ✅ Log Levels: DEBUG, INFO, WARNING, ERROR, CRITICAL
- ✅ Formatters: Simple, JSON, Colored, Template
- ✅ Handlers: Console, File, Rotating, TimedRotating, Memory
- ✅ Configuration: Development, Production, JSON, Rotating setups
- ✅ Registry: Singleton pattern for managing multiple loggers
- ✅ Child Loggers: Hierarchical logging with inheritance
- ✅ Exception Handling: Automatic stack trace logging
- ✅ Extra Data: Structured logging with additional context
- ✅ File Rotation: Size-based and time-based rotation
- ✅ Colored Output: ANSI color codes for console output
- ✅ JSON Formatting: Structured logging for machine processing
- ✅ Template Formatting: Customizable log message templates
- ✅ Memory Buffering: In-memory log storage with flush capabilities
Logger/
├── Python/
│ ├── Logger/ # Python library
│ ├── example.py # Basic usage example
│ └── USAGE.md # Detailed usage guide
├── JavaScript/
│ ├── Logger/ # JavaScript library
│ ├── example.js # Basic usage example
│ └── USAGE.md # Detailed usage guide
├── LICENSE # MIT License
└── README.md # This file
- Copy the
Python/Logger/
folder to your project - Import and use as shown in the examples
- Copy the
JavaScript/Logger/
folder to your project - Import and use as shown in the examples
Both versions include comprehensive test suites:
cd Python
python Logger/test.py
cd JavaScript
node Logger/test.js
MIT License - see LICENSE file for details.
This is a portable library designed to be easily integrated into any project. Feel free to:
- Copy and modify for your specific needs
- Extend with additional formatters or handlers
- Adapt for other programming languages
See the example.py
and example.js
files in each language directory for basic usage examples, and the test.py
and test.js
files for comprehensive feature demonstrations.