An enterprise-ready, high-performance logging library for Node.js. Optimized for production with Worker Threads, Sensitive Data Redaction, and Asynchronous Context Tracking. Built with TypeScript for full type safety.
- 🧵 Worker Threads: Offload serialization and I/O to background threads. Near-zero overhead on your main event loop.
- 🛡️ Ultra-Security Redaction: Automatically masks passwords, API keys, and sensitive patterns (Stripe, AWS, Credit Cards) even inside strings and deep objects.
- 🆔 Async Context Tracking: Automatically attach
requestIdoruserIdto all logs within a request flow using Node.jsAsyncLocalStorage. - 🔌 Modular Transport System: Easily extend logging to Console, File, or your own custom transports.
- 📜 Smart Error Serialization: Properly serializes
Errorobjects, including stacks, hidden properties, and custom metadata. - 🌐 Auto-Environment Detection: Intelligently switches between human-readable (Dev) and optimized JSON (Prod) formats.
- 🔄 Safe & Reliable: Built-in protection against circular references and extremely deep objects.
- ⚡ High Performance: Features time caching and hot-path optimizations to rival libraries like Pino.
npm install @onurege3467/logimport { CustomLogger } from '@onurege3467/log';
const logger = new CustomLogger();
logger.info('Server started on port 3000');
logger.warn('Low disk space', { available: '15%' });
logger.error('Database connection failed', new Error('Timeout'));In production (NODE_ENV=production), the logger automatically enables Worker Threads and JSON formatting for ELK/Datadog compatibility.
// Automatically optimized for Production
const logger = new CustomLogger(); The logger automatically scrubs sensitive information from log messages and metadata.
logger.info('Connecting to service', {
apiKey: 'AKIA1234567890ABCDEF', // Automatically masked
password: 'super-secret-pass' // Automatically masked
});
// String pattern detection
logger.info('User requested: https://my-app.com/api?token=secret-123');
// Output: User requested: https://my-app.com/api?token=[REDACTED]Trace a request's logs through different functions without passing IDs manually.
logger.runWithContext({ requestId: 'req-123', userId: 42 }, () => {
doSomething(); // Any logger call inside here will include requestId and userId
});
function doSomething() {
logger.info('Performing action');
// Output includes: {"requestId":"req-123","userId":42}
}For high-traffic applications, enable Worker Threads to keep your application snappy.
const logger = new CustomLogger({
useWorker: true // Processes logs in a separate thread
});| Option | Type | Default | Description |
|---|---|---|---|
prefix |
string | '' |
Add a prefix to all log messages |
timestamp |
boolean | true |
Enable/disable timestamps |
output |
string | 'console' |
'console', 'file', 'both', 'custom' |
useWorker |
boolean | false |
Enable background worker thread (true in Prod) |
sensitiveKeys |
string[] | [...] |
Custom keys to be redacted |
silent |
boolean | true |
Fail-safe mode: logger errors won't crash app |
logger.addLevel({
name: 'success',
priority: 1,
color: 'green',
symbol: '✅'
});
logger.success('Operation complete!');High-performance file logging with rotation and compression.
const logger = new CustomLogger({
fileLogging: {
enabled: true,
path: './logs',
filename: 'app.log',
rotation: 'daily',
maxFiles: 10,
format: 'json'
}
});| Library | Total Overhead | Context Support | Worker Threads |
|---|---|---|---|
| @onurege3467/log | Near-Zero | Native | Yes |
| winston | Medium | via Plugins | No |
| pino | Ultra-Low | Native | via Extreme Mode |
npm run test:all- 💿 Disk Persistence: lite-fs disk mode ile gerçek dosya yazma
- 📦 Updated Dependencies: lite-fs v3.0.0'a güncelleme
- 🛠️ Improved File Logging: Persistent logging desteği
- 🚀 Worker Threads: High-performance async logging
- 🔄 Async Context: Request tracing and correlation
- 🛡️ Redaction: Sensitive data protection
- 📊 Advanced Features: Compression, rotation, multiple formats
- 🎯 Initial Release: Basic logging functionality
MIT © onure9e