@wgtechlabs/log-engine 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +869 -608
  3. package/dist/formatter/data-formatter.d.ts +2 -1
  4. package/dist/formatter/data-formatter.d.ts.map +1 -1
  5. package/dist/formatter/data-formatter.js +1 -1
  6. package/dist/formatter/message-formatter.d.ts +23 -23
  7. package/dist/formatter/message-formatter.d.ts.map +1 -1
  8. package/dist/formatter/message-formatter.js +23 -23
  9. package/dist/formatter/timestamp.d.ts.map +1 -1
  10. package/dist/index.d.ts +130 -136
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +108 -108
  13. package/dist/logger/advanced-outputs.d.ts +159 -0
  14. package/dist/logger/advanced-outputs.d.ts.map +1 -0
  15. package/dist/logger/advanced-outputs.js +586 -0
  16. package/dist/logger/config.d.ts +18 -18
  17. package/dist/logger/config.d.ts.map +1 -1
  18. package/dist/logger/config.js +32 -29
  19. package/dist/logger/core.d.ts +128 -84
  20. package/dist/logger/core.d.ts.map +1 -1
  21. package/dist/logger/core.js +259 -74
  22. package/dist/logger/environment.d.ts +15 -15
  23. package/dist/logger/environment.d.ts.map +1 -1
  24. package/dist/logger/environment.js +15 -15
  25. package/dist/logger/filtering.d.ts +16 -16
  26. package/dist/logger/filtering.d.ts.map +1 -1
  27. package/dist/logger/filtering.js +37 -22
  28. package/dist/redaction/config.d.ts +8 -8
  29. package/dist/redaction/config.d.ts.map +1 -1
  30. package/dist/redaction/config.js +8 -8
  31. package/dist/redaction/redactor.d.ts +60 -60
  32. package/dist/redaction/redactor.d.ts.map +1 -1
  33. package/dist/redaction/redactor.js +101 -96
  34. package/dist/types/index.d.ts +98 -16
  35. package/dist/types/index.d.ts.map +1 -1
  36. package/package.json +80 -68
package/README.md CHANGED
@@ -1,608 +1,869 @@
1
- # Log Engine 📜🚂 [![made by](https://img.shields.io/badge/made%20by-WG%20Tech%20Labs-0060a0.svg?logo=github&longCache=true&labelColor=181717&style=flat-square)](https://github.com/wgtechlabs)
2
-
3
- [![github actions workflow status](https://img.shields.io/github/actions/workflow/status/wgtechlabs/log-engine/test.yml?branch=main&style=flat-square&logo=github&labelColor=181717)](https://github.com/wgtechlabs/log-engine/actions/workflows/test.yml) [![codecov](https://img.shields.io/codecov/c/github/wgtechlabs/log-engine?token=PWRJTBVKQ9&style=flat-square&logo=codecov&labelColor=181717)](https://codecov.io/gh/wgtechlabs/log-engine) [![npm downloads](https://img.shields.io/npm/d18m/%40wgtechlabs%2Flog-engine?style=flat-square&logo=npm&label=installs&labelColor=181717&color=%23CD0000)](https://www.npmjs.com/package/@wgtechlabs/log-engine) [![sponsors](https://img.shields.io/badge/sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=white&labelColor=181717&style=flat-square)](https://github.com/sponsors/wgtechlabs) [![release](https://img.shields.io/github/release/wgtechlabs/log-engine.svg?logo=github&labelColor=181717&color=green&style=flat-square)](https://github.com/wgtechlabs/log-engine/releases) [![star](https://img.shields.io/github/stars/wgtechlabs/log-engine.svg?&logo=github&labelColor=181717&color=yellow&style=flat-square)](https://github.com/wgtechlabs/log-engine/stargazers) [![license](https://img.shields.io/github/license/wgtechlabs/log-engine.svg?&logo=github&labelColor=181717&style=flat-square)](https://github.com/wgtechlabs/log-engine/blob/main/license)
4
-
5
- [![banner](https://raw.githubusercontent.com/wgtechlabs/log-engine/main/.github/assets/repo_banner.jpg)](https://github.com/wgtechlabs/log-engine)
6
-
7
- WG's Log Engine is the **ultimate logging solution for Node.js developers** - a lightweight, battle-tested utility specifically engineered for Discord bots, Telegram bots, web servers, APIs, and server-side applications. Born from real-world development challenges and proven in production environments like the [Unthread Discord Bot](https://github.com/wgtechlabs/unthread-discord-bot/), Log Engine delivers enterprise-grade logging with zero complexity, beautiful color-coded console output, and **advanced automatic data redaction with comprehensive PII protection**.
8
-
9
- **The first logging library with built-in advanced PII protection and comprehensive TypeScript support.** Stop wrestling with logging configurations and start building amazing applications safely. Whether you're creating the next viral Discord community bot, building high-performance APIs, developing microservices, or deploying production servers, Log Engine provides intelligent terminal-based logging with vibrant colors, advanced customizable redaction patterns, and automatic sensitive data protection that scales with your application's growth - from your first "Hello World" to handling millions of requests across distributed systems.
10
-
11
- ## âŖī¸ Motivation
12
-
13
- Picture this: It's 2 AM, your server is crashing in production, and you're staring at a terminal filled with thousands of debug messages mixed with critical errors. Sound familiar? I've been there too many times. I created Log Engine because every developer deserves to sleep peacefully, knowing their logs are working intelligently in the background.
14
-
15
- Log Engine transforms your development experience from chaotic debugging sessions into confident, data-driven problem solving. No more guessing what went wrong, no more drowning in irrelevant logs, no more manual configuration headaches. Just clear, contextual information exactly when and where you need it. Because great applications deserve great logging, and great developers deserve tools that just work.
16
-
17
- ## ✨ Key Features
18
-
19
- - **🔒 Advanced Data Redaction (Enhanced!)**: Built-in PII protection with **custom regex patterns**, **dynamic field management**, and **environment-based configuration** - the first logging library with comprehensive security-first logging by default.
20
- - **⚡ Custom Redaction Patterns**: Add your own regex patterns for advanced field detection and enterprise-specific data protection requirements.
21
- - **đŸŽ¯ Dynamic Field Management**: Runtime configuration of sensitive fields with case-insensitive matching and partial field name detection.
22
- - **đŸ› ī¸ Developer-Friendly API**: Advanced redaction methods including `testFieldRedaction()`, `withoutRedaction()`, and comprehensive configuration management.
23
- - **📊 Comprehensive TypeScript Support**: Full type definitions with 10+ interfaces covering all functionality for maximum developer experience and IDE support.
24
- - **🚀 Lightweight & Fast**: Minimal overhead with maximum performance - designed to enhance your application, not slow it down.
25
- - **📚 No Learning Curve**: Dead simple API that you can master in seconds. No extensive documentation, complex configurations, or setup required - Log Engine works instantly.
26
- - **🌈 Colorized Console Output**: Beautiful ANSI color-coded log levels with intelligent terminal formatting - instantly identify message severity at a glance with color-coded output.
27
- - **đŸŽ›ī¸ Multiple Log Modes**: Support for DEBUG, INFO, WARN, ERROR, SILENT, OFF, and special LOG levels with smart filtering - just set your mode and let it handle the rest.
28
- - **âš™ī¸ Auto-Configuration**: Intelligent environment-based setup using NODE_ENV variables. No config files, initialization scripts, or manual setup - Log Engine works perfectly out of the box.
29
- - **✨ Enhanced Formatting**: Structured log entries with dual timestamps (ISO + human-readable) and colored level indicators for maximum readability.
30
- - **🔗 Zero Dependencies**: No external dependencies for maximum compatibility and security - keeps your bundle clean and your project simple.
31
- - **🔌 Easy Integration**: Simple API that works seamlessly with existing Node.js applications. Just `import` and start logging - no middleware, plugins, or configuration required.
32
-
33
- ## 🤔 How It Works
34
- <!-- markdownlint-disable MD051 -->
35
- 1. Log Engine automatically detects your environment using `NODE_ENV` and sets appropriate log levels for optimal performance
36
- 2. When you call logging methods, messages are filtered based on the configured severity level (only messages at or above the set level are displayed)
37
- 3. Each log message is instantly formatted with precise timestamps in both ISO and human-readable formats
38
- 4. Messages are output to the console with **colorized level indicators and timestamps**, making debugging and monitoring effortless - errors show in red, warnings in yellow, info in blue, and debug in purple
39
- 5. ANSI color codes ensure compatibility across different terminal environments while maintaining beautiful, readable output
40
-
41
- Ready to streamline your application logging? Get started in seconds with our [simple installation](#đŸ“Ļ-installation)!
42
- <!-- markdownlint-enable MD051 -->
43
- ## 🤗 Special Thanks
44
-
45
- <!-- markdownlint-disable MD033 -->
46
- | <div align="center">💎 Platinum Sponsor</div> |
47
- |:-------------------------------------------:|
48
- | <a href="https://unthread.com"><img src="https://raw.githubusercontent.com/wgtechlabs/unthread-discord-bot/main/.github/assets/sponsors/platinum_unthread.png" width="250" alt="Unthread"></a> |
49
- | <div align="center"><a href="https://unthread.com" target="_blank"><b>Unthread</b></a><br/>Streamlined support ticketing for modern teams.</div> |
50
- <!-- markdownlint-enable MD033 -->
51
-
52
- ## 💸 Sponsored Ads
53
-
54
- Open source development is resource-intensive. These **sponsored ads help keep Log Engine free and actively maintained** while connecting you with tools and services that support open-source development.
55
-
56
- [![sponsored ads](https://gitads.dev/v1/ad-serve?source=wgtechlabs/log-engine@github)](https://gitads.dev/v1/ad-track?source=wgtechlabs/log-engine@github)
57
-
58
- ## đŸ“Ļ Installation
59
-
60
- Install the package using npm:
61
-
62
- ```bash
63
- npm install @wgtechlabs/log-engine
64
- ```
65
-
66
- Or using yarn:
67
-
68
- ```bash
69
- yarn add @wgtechlabs/log-engine
70
- ```
71
-
72
- ## đŸ•šī¸ Usage
73
-
74
- ### Quick Start
75
-
76
- ```typescript
77
- import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
78
-
79
- // Basic usage with auto-configuration based on NODE_ENV
80
- LogEngine.debug('This is a debug message');
81
- LogEngine.info('This is an info message');
82
- LogEngine.warn('This is a warning message');
83
- LogEngine.error('This is an error message');
84
- LogEngine.log('This is a critical message that always shows');
85
-
86
- // Advanced automatic data redaction (no configuration needed!)
87
- LogEngine.info('User login', {
88
- username: 'john_doe', // ✅ Visible
89
- password: 'secret123', // ❌ [REDACTED]
90
- email: 'john@example.com', // ❌ [REDACTED]
91
- apiKey: 'apikey123' // ❌ [REDACTED]
92
- });
93
-
94
- // Advanced redaction features - Add custom patterns
95
- LogEngine.addCustomRedactionPatterns([/internal.*/i, /company.*/i]);
96
- LogEngine.addSensitiveFields(['companySecret', 'internalToken']);
97
-
98
- // Test field redaction
99
- console.log(LogEngine.testFieldRedaction('password')); // true
100
- console.log(LogEngine.testFieldRedaction('username')); // false
101
-
102
- // Raw logging for debugging (bypasses redaction)
103
- LogEngine.withoutRedaction().info('Debug data', { password: 'visible-in-debug' });
104
- ```
105
-
106
- ### Mode-Based Configuration (Recommended)
107
-
108
- Log Engine now uses a modern **LogMode** system that separates message severity from output control:
109
-
110
- ```typescript
111
- import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
112
-
113
- // Configure using LogMode (recommended approach)
114
- LogEngine.configure({ mode: LogMode.DEBUG }); // Most verbose
115
- LogEngine.configure({ mode: LogMode.INFO }); // Balanced
116
- LogEngine.configure({ mode: LogMode.WARN }); // Focused
117
- LogEngine.configure({ mode: LogMode.ERROR }); // Minimal
118
- LogEngine.configure({ mode: LogMode.SILENT }); // Critical only
119
- LogEngine.configure({ mode: LogMode.OFF }); // Complete silence
120
-
121
- // Environment-based configuration example
122
- const env = process.env.NODE_ENV || 'development';
123
-
124
- if (env === 'production') {
125
- LogEngine.configure({ mode: LogMode.INFO });
126
- } else if (env === 'staging') {
127
- LogEngine.configure({ mode: LogMode.WARN });
128
- } else {
129
- LogEngine.configure({ mode: LogMode.DEBUG });
130
- }
131
-
132
- // Now use Log Engine - only messages appropriate for the mode will be shown
133
- LogEngine.debug('This will only show in DEBUG mode');
134
- LogEngine.info('General information');
135
- LogEngine.warn('Warning message');
136
- LogEngine.error('Error message');
137
- LogEngine.log('Critical message that always shows');
138
- ```
139
-
140
- ### Legacy Level-Based Configuration (Backwards Compatible)
141
-
142
- For backwards compatibility, the old `LogLevel` API is still supported:
143
-
144
- ```typescript
145
- import { LogEngine, LogLevel } from '@wgtechlabs/log-engine';
146
-
147
- // Legacy configuration (still works but LogMode is recommended)
148
- LogEngine.configure({ level: LogLevel.DEBUG });
149
- LogEngine.configure({ level: LogLevel.INFO });
150
- LogEngine.configure({ level: LogLevel.WARN });
151
- LogEngine.configure({ level: LogLevel.ERROR });
152
- ```
153
-
154
- ### Migration Guide: LogLevel → LogMode
155
-
156
- **Version 1.2.0+** introduces the new LogMode system for better separation of concerns. Here's how to migrate:
157
-
158
- ```typescript
159
- // OLD (v1.1.0 and earlier) - still works but deprecated
160
- import { LogEngine, LogLevel } from '@wgtechlabs/log-engine';
161
- LogEngine.configure({ level: LogLevel.DEBUG });
162
-
163
- // NEW (v1.2.1+) - recommended approach with advanced features
164
- import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
165
- LogEngine.configure({ mode: LogMode.DEBUG });
166
- ```
167
-
168
- **Key Benefits of LogMode:**
169
-
170
- - **Clearer API**: Separates message severity (`LogLevel`) from output control (`LogMode`)
171
- - **Better Environment Defaults**: `development→DEBUG`, `staging→WARN`, `test→ERROR`
172
- - **Advanced Features**: New redaction APIs and TypeScript interfaces work with LogMode
173
- - **Future-Proof**: All new features use the LogMode system
174
- - **100% Backwards Compatible**: Existing code continues to work unchanged
175
-
176
- ### Color-Coded Output 🎨
177
-
178
- Log Engine now features beautiful, color-coded console output that makes debugging and monitoring a breeze:
179
-
180
- ```typescript
181
- import { LogEngine } from '@wgtechlabs/log-engine';
182
-
183
- // Each log level gets its own distinct color for instant recognition
184
- LogEngine.debug('🔍 Debugging user authentication flow'); // Purple/Magenta
185
- LogEngine.info('â„šī¸ User successfully logged in'); // Blue
186
- LogEngine.warn('âš ī¸ API rate limit at 80% capacity'); // Yellow
187
- LogEngine.error('❌ Database connection timeout'); // Red
188
- LogEngine.log('🚀 Application started successfully'); // Green
189
- ```
190
-
191
- **Why Colors Matter:**
192
-
193
- - **Instant Recognition**: Quickly spot errors, warnings, and debug info without reading every line
194
- - **Better Debugging**: Visually separate different types of messages during development
195
- - **Production Monitoring**: Easily scan logs for critical issues in terminal environments
196
- - **Enhanced Readability**: Color-coded timestamps and level indicators reduce eye strain
197
-
198
- ### Log Modes
199
-
200
- Log Engine uses a **LogMode** system that controls output verbosity and filtering:
201
-
202
- - `LogMode.DEBUG` (0) - Most verbose: shows DEBUG, INFO, WARN, ERROR, LOG messages
203
- - `LogMode.INFO` (1) - Balanced: shows INFO, WARN, ERROR, LOG messages
204
- - `LogMode.WARN` (2) - Focused: shows WARN, ERROR, LOG messages
205
- - `LogMode.ERROR` (3) - Minimal: shows ERROR, LOG messages
206
- - `LogMode.SILENT` (4) - Critical only: shows LOG messages only
207
- - `LogMode.OFF` (5) - Complete silence: shows no messages at all
208
-
209
- ### Message Severity Levels
210
-
211
- Individual log messages have severity levels that determine their importance:
212
-
213
- - `LogLevel.DEBUG` (0) - Detailed information for debugging
214
- - `LogLevel.INFO` (1) - General information
215
- - `LogLevel.WARN` (2) - Warning messages
216
- - `LogLevel.ERROR` (3) - Error messages
217
- - `LogLevel.LOG` (99) - Critical messages that always show (except when OFF mode is set)
218
-
219
- ### Auto-Configuration
220
-
221
- Log Engine automatically configures itself based on the `NODE_ENV` environment variable:
222
-
223
- - `development` → `LogMode.DEBUG` (most verbose)
224
- - `production` → `LogMode.INFO` (balanced)
225
- - `staging` → `LogMode.WARN` (focused)
226
- - `test` → `LogMode.ERROR` (minimal)
227
- - `default` → `LogMode.INFO` (balanced)
228
-
229
- ### Special LOG Level
230
-
231
- The `LOG` level is special and behaves differently from other levels:
232
-
233
- - **Always Visible**: LOG messages are always displayed regardless of the configured log mode (except when OFF mode is set)
234
- - **Critical Information**: Perfect for essential system messages, application lifecycle events, and operational information that must never be filtered out
235
- - **Green Color**: Uses green coloring to distinguish it from other levels
236
- - **Use Cases**: Application startup/shutdown, server listening notifications, critical configuration changes, deployment information
237
-
238
- ```typescript
239
- import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
240
-
241
- // Even with SILENT mode, LOG messages still appear
242
- LogEngine.configure({ mode: LogMode.SILENT });
243
-
244
- LogEngine.debug('Debug message'); // Hidden
245
- LogEngine.info('Info message'); // Hidden
246
- LogEngine.warn('Warning message'); // Hidden
247
- LogEngine.error('Error message'); // Hidden
248
- LogEngine.log('Server started on port 3000'); // ✅ Always visible!
249
-
250
- // But with OFF mode, even LOG messages are hidden
251
- LogEngine.configure({ mode: LogMode.OFF });
252
- LogEngine.log('This LOG message is hidden'); // ❌ Hidden with OFF mode
253
- ```
254
-
255
- ### Complete Silence with OFF Mode
256
-
257
- The `OFF` mode provides complete logging silence when you need to disable all output:
258
-
259
- - **Total Silence**: Disables ALL logging including the special LOG level messages
260
- - **Testing & CI/CD**: Perfect for automated testing environments where no console output is desired
261
- - **Performance**: Minimal overhead when logging is completely disabled
262
- - **Use Cases**: Unit tests, CI/CD pipelines, production environments requiring zero log output
263
-
264
- ```typescript
265
- import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
266
-
267
- // Comparison: SILENT vs OFF
268
- LogEngine.configure({ mode: LogMode.SILENT });
269
- LogEngine.info('Info message'); // Hidden
270
- LogEngine.log('Critical message'); // ✅ Still visible with SILENT
271
-
272
- LogEngine.configure({ mode: LogMode.OFF });
273
- LogEngine.info('Info message'); // Hidden
274
- LogEngine.log('Critical message'); // ❌ Hidden with OFF - complete silence!
275
- ```
276
-
277
- ### Log Format
278
-
279
- Log messages are beautifully formatted with colorized timestamps, levels, and smart terminal output:
280
-
281
- ```bash
282
- # Example colorized output (colors visible in terminal)
283
- [2025-05-29T16:57:45.678Z][4:57PM][DEBUG]: Debugging application flow
284
- [2025-05-29T16:57:46.123Z][4:57PM][INFO]: Server started successfully
285
- [2025-05-29T16:57:47.456Z][4:57PM][WARN]: API rate limit approaching
286
- [2025-05-29T16:57:48.789Z][4:57PM][ERROR]: Database connection failed
287
- [2025-05-29T16:57:49.012Z][4:57PM][LOG]: Application startup complete
288
- ```
289
-
290
- **Color Scheme:**
291
-
292
- - đŸŸŖ **DEBUG**: Magenta/Purple - Detailed debugging information
293
- - đŸ”ĩ **INFO**: Blue - General informational messages
294
- - 🟡 **WARN**: Yellow - Warning messages that need attention
295
- - 🔴 **ERROR**: Red - Error messages requiring immediate action
296
- - đŸŸĸ **LOG**: Green - Critical messages that always display
297
- - âšĢ **Timestamps**: Gray (ISO) and Cyan (local time) for easy scanning
298
-
299
- ## 🔒 Advanced Data Redaction
300
-
301
- **LogEngine features comprehensive built-in PII protection with advanced customization capabilities that automatically redacts sensitive information from your logs.** This security-first approach prevents accidental exposure of passwords, tokens, emails, and other sensitive data while maintaining full debugging capabilities with enterprise-grade flexibility.
302
-
303
- ### Zero Configuration Security
304
-
305
- Just use LogEngine normally - **sensitive data is automatically protected**:
306
-
307
- ```typescript
308
- import { LogEngine } from '@wgtechlabs/log-engine';
309
-
310
- // ✅ Automatic redaction - no setup needed!
311
- LogEngine.info('User authentication', {
312
- username: 'john_doe', // ✅ Visible
313
- password: 'secret123', // ❌ [REDACTED]
314
- email: 'john@example.com', // ❌ [REDACTED]
315
- apiKey: 'apikey123', // ❌ [REDACTED]
316
- timestamp: new Date() // ✅ Visible
317
- });
318
-
319
- // Output: [INFO]: User authentication {"username":"john_doe","password":"[REDACTED]","email":"[REDACTED]","apiKey":"[REDACTED]","timestamp":"2025-06-17T..."}
320
- ```
321
-
322
- ### Protected Data Types
323
-
324
- **50+ sensitive patterns automatically detected:**
325
-
326
- - **Authentication**: `password`, `token`, `apiKey`, `secret`, `jwt`, `auth`, `sessionId`
327
- - **Personal Info**: `email`, `phone`, `ssn`, `firstName`, `lastName`, `address`
328
- - **Financial**: `creditCard`, `cvv`, `bankAccount`, `routingNumber`
329
- - **System**: `clientSecret`, `privateKey`, `webhookSecret`
330
-
331
- ### Deep Object Scanning
332
-
333
- Automatically scans nested objects and arrays:
334
-
335
- ```typescript
336
- LogEngine.warn('Payment processing', {
337
- order: {
338
- id: 'order-123', // ✅ Visible
339
- customer: {
340
- username: 'customer1', // ✅ Visible
341
- email: 'user@example.com', // ❌ [REDACTED]
342
- creditCard: '4532-****' // ❌ [REDACTED]
343
- }
344
- },
345
- metadata: {
346
- processor: 'stripe',
347
- apiSecret: 'sk_live_...' // ❌ [REDACTED]
348
- }
349
- });
350
- ```
351
-
352
- ### Content Truncation
353
-
354
- Large content fields are automatically truncated to prevent log bloat:
355
-
356
- ```typescript
357
- LogEngine.debug('Large payload', {
358
- content: 'Very long content...'.repeat(100), // Truncated at 100 chars + "... [TRUNCATED]"
359
- size: 'large',
360
- processed: true
361
- });
362
- ```
363
-
364
- ### Development-Friendly Features
365
-
366
- **Raw Methods for Debugging:**
367
-
368
- ```typescript
369
- // âš ī¸ Use with caution - bypasses redaction
370
- LogEngine.debugRaw('Full debug data', {
371
- password: 'secret123', // âš ī¸ Visible (not redacted)
372
- apiKey: 'full-key' // âš ī¸ Visible (not redacted)
373
- });
374
-
375
- // Or use the helper method
376
- LogEngine.withoutRedaction().info('Debug mode', sensitiveData);
377
- ```
378
-
379
- **Environment-Based Control:**
380
-
381
- ```bash
382
- # Development - show everything (redaction disabled)
383
- NODE_ENV=development
384
-
385
- # Explicitly disable redaction
386
- LOG_REDACTION_DISABLED=true
387
- DEBUG_FULL_PAYLOADS=true
388
-
389
- # Custom redaction configuration
390
- LOG_REDACTION_TEXT="***CONFIDENTIAL***"
391
- LOG_MAX_CONTENT_LENGTH=200
392
- LOG_SENSITIVE_FIELDS="customField,companySecret,internalData"
393
- LOG_TRUNCATION_TEXT="... [CUSTOM_TRUNCATED]"
394
-
395
- # Advanced environment integration
396
- LOG_REDACTION_ENABLED=false # Alternative disable method
397
- ```
398
-
399
- ### Custom Configuration
400
-
401
- **Modify redaction behavior:**
402
-
403
- ```typescript
404
- // Custom redaction settings
405
- LogEngine.configureRedaction({
406
- redactionText: '***HIDDEN***',
407
- maxContentLength: 200,
408
- sensitiveFields: ['myCustomField', 'internalSecret']
409
- });
410
-
411
- // Get current configuration
412
- const config = LogEngine.getRedactionConfig();
413
- console.log(config);
414
- ```
415
-
416
- ### Advanced Redaction Features (v1.2.1+)
417
-
418
- **Custom Patterns & Dynamic Field Management:**
419
-
420
- ```typescript
421
- // Add custom regex patterns for enterprise-specific data protection
422
- LogEngine.addCustomRedactionPatterns([
423
- /internal.*/i, // Matches any field starting with "internal"
424
- /company.*/i, // Matches any field starting with "company"
425
- /^config[A-Z]/ // Matches camelCase config fields
426
- ]);
427
-
428
- // Add custom sensitive field names dynamically
429
- LogEngine.addSensitiveFields(['companySecret', 'internalToken', 'proprietaryData']);
430
-
431
- // Test field redaction before logging
432
- if (LogEngine.testFieldRedaction('myField')) {
433
- console.log('Field will be redacted');
434
- }
435
-
436
- // Advanced configuration management
437
- LogEngine.configureRedaction({
438
- redactionText: '***CONFIDENTIAL***',
439
- maxContentLength: 150,
440
- customPatterns: [/private.*/i, /secret.*/i]
441
- });
442
-
443
- // Configuration utilities
444
- const currentConfig = LogEngine.getRedactionConfig();
445
- LogEngine.refreshRedactionConfig(); // Refresh from environment
446
- LogEngine.resetRedactionConfig(); // Reset to defaults
447
- LogEngine.clearCustomRedactionPatterns(); // Clear custom patterns
448
- ```
449
-
450
- **Enhanced Development Workflow:**
451
-
452
- ```typescript
453
- // Raw logging methods (bypass redaction) - use with caution
454
- LogEngine.debugRaw('Full debug data', { password: 'visible', apiKey: 'full-key' });
455
-
456
- // Temporary redaction bypass using helper method
457
- LogEngine.withoutRedaction().info('Debug mode', sensitiveData);
458
-
459
- // Compare outputs during development
460
- LogEngine.info('With redaction', data); // ❌ [REDACTED]
461
- LogEngine.withoutRedaction().info('Without redaction', data); // âš ī¸ Visible
462
- ```
463
-
464
- ### Environment Behavior
465
-
466
- | Environment | Redaction Status | Use Case |
467
- |-------------|------------------|----------|
468
- | **Production** | 🔒 **Active** | Full protection for live systems |
469
- | **Development** | đŸ› ī¸ **Disabled** | Full data visibility for debugging |
470
- | **Staging** | 🔒 **Active** | Test with production-like security |
471
- | **Test** | 🔒 **Active** | Consistent test environment |
472
-
473
- ### Security Benefits
474
-
475
- ✅ **Advanced Pattern Recognition** - Custom regex patterns for enterprise-specific data protection
476
- ✅ **Dynamic Field Management** - Runtime configuration of sensitive fields with intelligent matching
477
- ✅ **Comprehensive Testing API** - `testFieldRedaction()` for validation and debugging
478
- ✅ **Environment Integration** - Seamless configuration via environment variables
479
- ✅ **Development Workflow** - Raw logging methods and temporary redaction bypass for debugging
480
- ✅ **Prevents Data Leaks** - Automatic protection against accidental exposure with 50+ built-in patterns
481
- ✅ **Compliance Ready** - Helps meet GDPR, HIPAA, and other privacy requirements
482
- ✅ **Zero Configuration** - Secure by default, advanced features when needed
483
- ✅ **Performance Optimized** - Minimal overhead with intelligent processing and depth limiting
484
- ✅ **TypeScript Excellence** - Full type safety with comprehensive interfaces and type definitions
485
-
486
- **Perfect for:** Enterprise applications, compliance requirements, team development environments, production systems requiring both security and debugging flexibility, and any scenario where sensitive data protection is critical.
487
-
488
- ## 📚 Comprehensive TypeScript Support
489
-
490
- **LogEngine v1.2.1+ includes extensive TypeScript definitions with 10+ interfaces for maximum type safety and developer experience:**
491
-
492
- ### Core Interfaces
493
-
494
- ```typescript
495
- import {
496
- LogEngine,
497
- LogMode,
498
- LogLevel,
499
- ILogEngine,
500
- ILogEngineWithoutRedaction,
501
- RedactionConfig,
502
- LoggerConfig,
503
- IDataRedactor
504
- } from '@wgtechlabs/log-engine';
505
-
506
- // Full type safety for all methods
507
- const config: RedactionConfig = {
508
- enabled: true,
509
- sensitiveFields: ['password', 'token'],
510
- redactionText: '[HIDDEN]',
511
- maxContentLength: 100,
512
- // ... fully typed configuration
513
- };
514
-
515
- // Advanced redaction testing with return types
516
- const isRedacted: boolean = LogEngine.testFieldRedaction('password');
517
- const currentConfig: RedactionConfig = LogEngine.getRedactionConfig();
518
-
519
- // Type-safe raw logging
520
- const rawLogger: ILogEngineWithoutRedaction = LogEngine.withoutRedaction();
521
- rawLogger.info('Debug info', sensitiveData); // Fully typed methods
522
- ```
523
-
524
- ### Available Interfaces
525
-
526
- - **`ILogEngine`** - Complete LogEngine API with all methods
527
- - **`ILogEngineWithoutRedaction`** - Raw logging methods interface
528
- - **`IDataRedactor`** - Static DataRedactor class methods
529
- - **`RedactionConfig`** - Comprehensive redaction configuration
530
- - **`LoggerConfig`** - Logger configuration options
531
- - **`LogEntry`** - Structured log entry interface
532
- - **`EnvironmentConfig`** - Environment variable documentation
533
- - **Plus 3+ additional interfaces** for advanced use cases
534
-
535
- **IDE Benefits:** IntelliSense, auto-completion, parameter hints, error detection, and comprehensive documentation tooltips throughout your development workflow.
536
-
537
- ## đŸ’Ŧ Community Discussions
538
-
539
- Join our community discussions to get help, share ideas, and connect with other users:
540
-
541
- - đŸ“Ŗ **[Announcements](https://github.com/wgtechlabs/log-engine/discussions/categories/announcements)**: Official updates from the maintainer
542
- - 📸 **[Showcase](https://github.com/wgtechlabs/log-engine/discussions/categories/showcase)**: Show and tell your implementation
543
- - 💖 **[Wall of Love](https://github.com/wgtechlabs/log-engine/discussions/categories/wall-of-love)**: Share your experience with the library
544
- - 🛟 **[Help & Support](https://github.com/wgtechlabs/log-engine/discussions/categories/help-support)**: Get assistance from the community
545
- - 🧠 **[Ideas](https://github.com/wgtechlabs/log-engine/discussions/categories/ideas)**: Suggest new features and improvements
546
-
547
- ## 🛟 Help & Support
548
-
549
- ### Getting Help
550
-
551
- Need assistance with the library? Here's how to get help:
552
- <!-- markdownlint-disable MD051 -->
553
- - **Community Support**: Check the [Help & Support](https://github.com/wgtechlabs/log-engine/discussions/categories/help-support) category in our GitHub Discussions for answers to common questions.
554
- - **Ask a Question**: Create a [new discussion](https://github.com/wgtechlabs/log-engine/discussions/new?category=help-support) if you can't find answers to your specific issue.
555
- - **Documentation**: Review the [usage instructions](#đŸ•šī¸-usage) in this README for common examples and configurations.
556
- - **Known Issues**: Browse [existing issues](https://github.com/wgtechlabs/log-engine/issues) to see if your problem has already been reported.
557
- <!-- markdownlint-enable MD051 -->
558
-
559
- ### Reporting Issues
560
-
561
- Please report any issues, bugs, or improvement suggestions by [creating a new issue](https://github.com/wgtechlabs/log-engine/issues/new/choose). Before submitting, please check if a similar issue already exists to avoid duplicates.
562
-
563
- ### Security Vulnerabilities
564
-
565
- For security vulnerabilities, please do not report them publicly. Follow the guidelines in our [security policy](./security.md) to responsibly disclose security issues.
566
-
567
- Your contributions to improving this project are greatly appreciated! 🙏✨
568
-
569
- ## đŸŽ¯ Contributing
570
-
571
- Contributions are welcome, create a pull request to this repo and I will review your code. Please consider to submit your pull request to the `dev` branch. Thank you!
572
-
573
- Read the project's [contributing guide](./CONTRIBUTING.md) for more info, including testing guidelines and requirements.
574
-
575
- ## 🙏 Sponsor
576
-
577
- Like this project? **Leave a star**! ⭐⭐⭐⭐⭐
578
-
579
- There are several ways you can support this project:
580
-
581
- - [Become a sponsor](https://github.com/sponsors/wgtechlabs) and get some perks! 💖
582
- - [Buy me a coffee](https://buymeacoffee.com/wgtechlabs) if you just love what I do! ☕
583
-
584
- ## ⭐ GitHub Star Nomination
585
-
586
- Found this project helpful? Consider nominating me **(@warengonzaga)** for the [GitHub Star program](https://stars.github.com/nominate/)! This recognition supports ongoing development of this project and [my other open-source projects](https://github.com/warengonzaga?tab=repositories). GitHub Stars are recognized for their significant contributions to the developer community - your nomination makes a difference and encourages continued innovation!
587
-
588
- ## 📋 Code of Conduct
589
-
590
- I'm committed to providing a welcoming and inclusive environment for all contributors and users. Please review the project's [Code of Conduct](./code_of_conduct.md) to understand the community standards and expectations for participation.
591
-
592
- ## 📃 License
593
-
594
- This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). See the [LICENSE](LICENSE) file for the full license text.
595
-
596
- ## 📝 Author
597
-
598
- This project is created by **[Waren Gonzaga](https://github.com/warengonzaga)** under [WG Technology Labs](https://github.com/wgtechlabs), with the help of awesome [contributors](https://github.com/wgtechlabs/log-engine/graphs/contributors).
599
-
600
- **Latest Version:** v1.3.0 - Enhanced with advanced redaction features, comprehensive TypeScript support, and 95%+ test coverage.
601
-
602
- [![contributors](https://contrib.rocks/image?repo=wgtechlabs/log-engine)](https://github.com/wgtechlabs/log-engine/graphs/contributors)
603
-
604
- ---
605
-
606
- đŸ’ģ with â¤ī¸ by [Waren Gonzaga](https://warengonzaga.com) under [WG Technology Labs](https://wgtechlabs.com), and [Him](https://www.youtube.com/watch?v=HHrxS4diLew&t=44s) 🙏
607
-
608
- <!-- GitAds-Verify: O4MESJK7VTBCELWNTFQAWB5HDX57H9MS -->
1
+ # Log Engine 📜🚂 [![made by](https://img.shields.io/badge/made%20by-WG%20Tech%20Labs-0060a0.svg?logo=github&longCache=true&labelColor=181717&style=flat-square)](https://github.com/wgtechlabs)
2
+
3
+ [![codecov](https://img.shields.io/codecov/c/github/wgtechlabs/log-engine?token=PWRJTBVKQ9&style=flat-square&logo=codecov&labelColor=181717)](https://codecov.io/gh/wgtechlabs/log-engine) [![npm downloads](https://img.shields.io/npm/dm/%40wgtechlabs%2Flog-engine?style=flat-square&logo=npm&label=installs&labelColor=181717&color=%23CD0000)](https://www.npmjs.com/package/@wgtechlabs/log-engine) [![sponsors](https://img.shields.io/badge/sponsor-%E2%9D%A4-%23db61a2.svg?&logo=github&logoColor=white&labelColor=181717&style=flat-square)](https://github.com/sponsors/wgtechlabs) [![release](https://img.shields.io/github/release/wgtechlabs/log-engine.svg?logo=github&labelColor=181717&color=green&style=flat-square)](https://github.com/wgtechlabs/log-engine/releases) [![star](https://img.shields.io/github/stars/wgtechlabs/log-engine.svg?&logo=github&labelColor=181717&color=yellow&style=flat-square)](https://github.com/wgtechlabs/log-engine/stargazers) [![license](https://img.shields.io/github/license/wgtechlabs/log-engine.svg?&logo=github&labelColor=181717&style=flat-square)](https://github.com/wgtechlabs/log-engine/blob/main/license)
4
+
5
+ [![banner](https://raw.githubusercontent.com/wgtechlabs/log-engine/main/.github/assets/repo_banner.jpg)](https://github.com/wgtechlabs/log-engine)
6
+
7
+ WG's Log Engine is the **ultimate logging solution for Node.js developers** - a lightweight, battle-tested utility specifically engineered for Discord bots, Telegram bots, web servers, APIs, and server-side applications. Born from real-world development challenges and proven in production environments like the [Unthread Discord Bot](https://github.com/wgtechlabs/unthread-discord-bot/), Log Engine delivers enterprise-grade logging with zero complexity, beautiful color-coded console output, **revolutionary configurable output routing**, and **advanced automatic data redaction with comprehensive PII protection**.
8
+
9
+ **The first logging library with built-in advanced PII protection, configurable output handlers, and comprehensive TypeScript support.** Stop wrestling with logging configurations and start building amazing applications safely. Whether you're creating the next viral Discord community bot, building high-performance APIs, developing microservices, or deploying production servers, Log Engine provides intelligent logging with vibrant colors, flexible output routing to any destination, advanced customizable redaction patterns, and automatic sensitive data protection that scales with your application's growth - from your first "Hello World" to handling millions of requests across distributed systems.
10
+
11
+ ## âŖī¸ Motivation
12
+
13
+ Picture this: It's 2 AM, your server is crashing in production, and you're staring at a terminal filled with thousands of debug messages mixed with critical errors. Sound familiar? I've been there too many times. I created Log Engine because every developer deserves to sleep peacefully, knowing their logs are working intelligently in the background.
14
+
15
+ Log Engine transforms your development experience from chaotic debugging sessions into confident, data-driven problem solving. No more guessing what went wrong, no more drowning in irrelevant logs, no more manual configuration headaches. Just clear, contextual information exactly when and where you need it. Because great applications deserve great logging, and great developers deserve tools that just work.
16
+
17
+ ## ✨ Key Features
18
+
19
+ - **🔒 Advanced Data Redaction (Enhanced!)**: Built-in PII protection with **custom regex patterns**, **dynamic field management**, and **environment-based configuration** - the first logging library with comprehensive security-first logging by default.
20
+ - **đŸŽ¯ Configurable Output Handlers (New!)**: Revolutionary output routing system supporting **custom destinations**, **multiple simultaneous outputs**, and **production-ready handlers** - redirect logs to files, HTTP endpoints, GUI applications, testing frameworks, or any custom destination with zero configuration complexity.
21
+ - **⚡ Custom Redaction Patterns**: Add your own regex patterns for advanced field detection and enterprise-specific data protection requirements.
22
+ - **đŸŽ¯ Dynamic Field Management**: Runtime configuration of sensitive fields with case-insensitive matching and partial field name detection.
23
+ - **đŸ› ī¸ Developer-Friendly API**: Advanced redaction methods including `testFieldRedaction()`, `withoutRedaction()`, and comprehensive configuration management.
24
+ - **📊 Comprehensive TypeScript Support**: Full type definitions with 15+ interfaces covering all functionality for maximum developer experience and IDE support.
25
+ - **🚀 Lightweight & Fast**: Minimal overhead with maximum performance - designed to enhance your application, not slow it down.
26
+ - **📚 No Learning Curve**: Dead simple API that you can master in seconds. No extensive documentation, complex configurations, or setup required - Log Engine works instantly.
27
+ - **🌈 Colorized Console Output**: Beautiful ANSI color-coded log levels with intelligent terminal formatting - instantly identify message severity at a glance with color-coded output.
28
+ - **đŸŽ›ī¸ Multiple Log Modes**: Support for DEBUG, INFO, WARN, ERROR, SILENT, OFF, and special LOG levels with smart filtering - just set your mode and let it handle the rest.
29
+ - **âš™ī¸ Auto-Configuration**: Intelligent environment-based setup using NODE_ENV variables. No config files, initialization scripts, or manual setup - Log Engine works perfectly out of the box.
30
+ - **✨ Enhanced Formatting**: Structured log entries with dual timestamps (ISO + human-readable) and colored level indicators for maximum readability.
31
+ - **🔗 Zero Dependencies**: No external dependencies for maximum compatibility and security - keeps your bundle clean and your project simple.
32
+ - **🔌 Easy Integration**: Simple API that works seamlessly with existing Node.js applications. Just `import` and start logging - no middleware, plugins, or configuration required.
33
+
34
+ ## âš ī¸ Breaking Changes Notice
35
+
36
+ **v3.0.0 Breaking Change**: The legacy `level` configuration will be removed in v3.0.0. If you're using `LogEngine.configure({ level: LogLevel.DEBUG })`, please migrate to `LogEngine.configure({ mode: LogMode.DEBUG })`. See our [Migration Guide](#migration-guide-loglevel--logmode) for details.
37
+
38
+ ## 🤔 How It Works
39
+ <!-- markdownlint-disable MD051 -->
40
+ 1. Log Engine automatically detects your environment using `NODE_ENV` and sets appropriate log levels for optimal performance
41
+ 2. When you call logging methods, messages are filtered based on the configured severity level (only messages at or above the set level are displayed)
42
+ 3. Each log message is instantly formatted with precise timestamps in both ISO and human-readable formats
43
+ 4. Messages are output to the console with **colorized level indicators and timestamps**, making debugging and monitoring effortless - errors show in red, warnings in yellow, info in blue, and debug in purple
44
+ 5. ANSI color codes ensure compatibility across different terminal environments while maintaining beautiful, readable output
45
+
46
+ Ready to streamline your application logging? Get started in seconds with our [simple installation](#đŸ“Ļ-installation)!
47
+ <!-- markdownlint-enable MD051 -->
48
+ ## 🤗 Special Thanks
49
+
50
+ <!-- markdownlint-disable MD033 -->
51
+ | <div align="center">💎 Platinum Sponsor</div> |
52
+ |:-------------------------------------------:|
53
+ | <a href="https://unthread.com"><img src="https://raw.githubusercontent.com/wgtechlabs/unthread-discord-bot/main/.github/assets/sponsors/platinum_unthread.png" width="250" alt="Unthread"></a> |
54
+ | <div align="center"><a href="https://unthread.com" target="_blank"><b>Unthread</b></a><br/>Streamlined support ticketing for modern teams.</div> |
55
+ <!-- markdownlint-enable MD033 -->
56
+
57
+ ## 💸 Sponsored Ads
58
+
59
+ Open source development is resource-intensive. These **sponsored ads help keep Log Engine free and actively maintained** while connecting you with tools and services that support open-source development.
60
+
61
+ [![sponsored ads](https://gitads.dev/v1/ad-serve?source=wgtechlabs/log-engine@github)](https://gitads.dev/v1/ad-track?source=wgtechlabs/log-engine@github)
62
+
63
+ ## đŸ“Ļ Installation
64
+
65
+ Install the package using yarn (recommended):
66
+
67
+ ```bash
68
+ yarn add @wgtechlabs/log-engine
69
+ ```
70
+
71
+ Or using npm:
72
+
73
+ ```bash
74
+ npm install @wgtechlabs/log-engine
75
+ ```
76
+
77
+ > **Note**: This project uses yarn as the primary package manager for development. If you're contributing to the project, please use yarn to ensure consistency with the development environment.
78
+
79
+ ## đŸ•šī¸ Usage
80
+
81
+ > **âš ī¸ Important**: If you're using the legacy `level` configuration, please migrate to `mode`. The `level` configuration is deprecated and will be removed in v3.0.0. See the [Migration Guide](#migration-guide-loglevel--logmode) below.
82
+
83
+ ### Quick Start
84
+
85
+ ```typescript
86
+ import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
87
+
88
+ // Basic usage with auto-configuration based on NODE_ENV
89
+ LogEngine.debug('This is a debug message');
90
+ LogEngine.info('This is an info message');
91
+ LogEngine.warn('This is a warning message');
92
+ LogEngine.error('This is an error message');
93
+ LogEngine.log('This is a critical message that always shows');
94
+
95
+ // Advanced automatic data redaction (no configuration needed!)
96
+ LogEngine.info('User login', {
97
+ username: 'john_doe', // ✅ Visible
98
+ password: 'secret123', // ❌ [REDACTED]
99
+ email: 'john@example.com', // ❌ [REDACTED]
100
+ apiKey: 'apikey123' // ❌ [REDACTED]
101
+ });
102
+
103
+ // Advanced redaction features - Add custom patterns
104
+ LogEngine.addCustomRedactionPatterns([/internal.*/i, /company.*/i]);
105
+ LogEngine.addSensitiveFields(['companySecret', 'internalToken']);
106
+
107
+ // Test field redaction
108
+ console.log(LogEngine.testFieldRedaction('password')); // true
109
+ console.log(LogEngine.testFieldRedaction('username')); // false
110
+
111
+ // Raw logging for debugging (bypasses redaction)
112
+ LogEngine.withoutRedaction().info('Debug data', { password: 'visible-in-debug' });
113
+
114
+ // NEW: Custom output destinations (v2.0+)
115
+ LogEngine.configure({
116
+ outputHandler: (level, message, data) => {
117
+ // Send logs anywhere: GUI apps, files, APIs, databases
118
+ myCustomHandler(level, message, data);
119
+ },
120
+ suppressConsoleOutput: true // Optional: disable console
121
+ });
122
+
123
+ // NEW: Multiple outputs simultaneously
124
+ LogEngine.configure({
125
+ outputs: [
126
+ 'console', // Built-in console
127
+ myFileHandler, // Custom file handler
128
+ myMonitoringHandler // Custom monitoring
129
+ ]
130
+ });
131
+ ```
132
+
133
+ ### Mode-Based Configuration (Recommended)
134
+
135
+ Log Engine now uses a modern **LogMode** system that separates message severity from output control:
136
+
137
+ ```typescript
138
+ import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
139
+
140
+ // Configure using LogMode (recommended approach)
141
+ LogEngine.configure({ mode: LogMode.DEBUG }); // Most verbose
142
+ LogEngine.configure({ mode: LogMode.INFO }); // Balanced
143
+ LogEngine.configure({ mode: LogMode.WARN }); // Focused
144
+ LogEngine.configure({ mode: LogMode.ERROR }); // Minimal
145
+ LogEngine.configure({ mode: LogMode.SILENT }); // Critical only
146
+ LogEngine.configure({ mode: LogMode.OFF }); // Complete silence
147
+
148
+ // Environment-based configuration example
149
+ const env = process.env.NODE_ENV || 'development';
150
+
151
+ if (env === 'production') {
152
+ LogEngine.configure({ mode: LogMode.INFO });
153
+ } else if (env === 'staging') {
154
+ LogEngine.configure({ mode: LogMode.WARN });
155
+ } else {
156
+ LogEngine.configure({ mode: LogMode.DEBUG });
157
+ }
158
+
159
+ // Now use Log Engine - only messages appropriate for the mode will be shown
160
+ LogEngine.debug('This will only show in DEBUG mode');
161
+ LogEngine.info('General information');
162
+ LogEngine.warn('Warning message');
163
+ LogEngine.error('Error message');
164
+ LogEngine.log('Critical message that always shows');
165
+ ```
166
+
167
+ ### Legacy Level-Based Configuration (âš ī¸ Deprecated)
168
+
169
+ **âš ī¸ DEPRECATION WARNING**: The `level` configuration is deprecated and will be removed in **v3.0.0**. Please use `mode` instead.
170
+
171
+ For backwards compatibility, the old `LogLevel` API is still supported but shows deprecation warnings:
172
+
173
+ ```typescript
174
+ import { LogEngine, LogLevel } from '@wgtechlabs/log-engine';
175
+
176
+ // âš ī¸ DEPRECATED: Legacy configuration (shows warning, will be removed in v3.0.0)
177
+ LogEngine.configure({ level: LogLevel.DEBUG }); // Triggers deprecation warning
178
+ LogEngine.configure({ level: LogLevel.INFO }); // Triggers deprecation warning
179
+ LogEngine.configure({ level: LogLevel.WARN }); // Triggers deprecation warning
180
+ LogEngine.configure({ level: LogLevel.ERROR }); // Triggers deprecation warning
181
+
182
+ // ✅ RECOMMENDED: Use the modern LogMode API instead
183
+ LogEngine.configure({ mode: LogMode.DEBUG }); // No warnings, future-proof
184
+ ```
185
+
186
+ **Why migrate to LogMode?**
187
+
188
+ - No deprecation warnings
189
+ - Future-proof API that won't be removed
190
+ - Better separation of concerns
191
+ - Access to all v2.0+ features including output handlers
192
+ - Clearer, more intuitive configuration
193
+
194
+ ### Migration Guide: LogLevel → LogMode
195
+
196
+ **âš ī¸ IMPORTANT DEPRECATION NOTICE**: The `level` configuration is **deprecated as of v2.0.0** and will be **removed in v3.0.0**. Please migrate to the new `mode` configuration.
197
+
198
+ **Version 1.2.0+** introduces the new LogMode system for better separation of concerns. Here's how to migrate:
199
+
200
+ ```typescript
201
+ // ❌ OLD (v1.1.0 and earlier) - DEPRECATED, will be removed in v3.0.0
202
+ import { LogEngine, LogLevel } from '@wgtechlabs/log-engine';
203
+ LogEngine.configure({ level: LogLevel.DEBUG }); // Shows deprecation warning
204
+
205
+ // ✅ NEW (v2.0.0+) - recommended approach with advanced features
206
+ import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
207
+ LogEngine.configure({ mode: LogMode.DEBUG }); // Modern, future-proof API
208
+ ```
209
+
210
+ **Migration Benefits:**
211
+
212
+ **Key Benefits of LogMode:**
213
+
214
+ - **Clearer API**: Separates message severity (`LogLevel`) from output control (`LogMode`)
215
+ - **Better Environment Defaults**: `development→DEBUG`, `staging→WARN`, `test→ERROR`
216
+ - **Advanced Features**: New redaction APIs and TypeScript interfaces work with LogMode
217
+ - **Future-Proof**: All new features use the LogMode system
218
+ - **100% Backwards Compatible**: Existing code continues to work unchanged (with deprecation warnings)
219
+ - **No Breaking Changes in v2.0**: Legacy `level` support maintained until v3.0.0
220
+
221
+ ### Color-Coded Output 🎨
222
+
223
+ Log Engine now features beautiful, color-coded console output that makes debugging and monitoring a breeze:
224
+
225
+ ```typescript
226
+ import { LogEngine } from '@wgtechlabs/log-engine';
227
+
228
+ // Each log level gets its own distinct color for instant recognition
229
+ LogEngine.debug('🔍 Debugging user authentication flow'); // Purple/Magenta
230
+ LogEngine.info('â„šī¸ User successfully logged in'); // Blue
231
+ LogEngine.warn('âš ī¸ API rate limit at 80% capacity'); // Yellow
232
+ LogEngine.error('❌ Database connection timeout'); // Red
233
+ LogEngine.log('🚀 Application started successfully'); // Green
234
+ ```
235
+
236
+ **Why Colors Matter:**
237
+
238
+ - **Instant Recognition**: Quickly spot errors, warnings, and debug info without reading every line
239
+ - **Better Debugging**: Visually separate different types of messages during development
240
+ - **Production Monitoring**: Easily scan logs for critical issues in terminal environments
241
+ - **Enhanced Readability**: Color-coded timestamps and level indicators reduce eye strain
242
+
243
+ ### Log Modes
244
+
245
+ Log Engine uses a **LogMode** system that controls output verbosity and filtering:
246
+
247
+ - `LogMode.DEBUG` (0) - Most verbose: shows DEBUG, INFO, WARN, ERROR, LOG messages
248
+ - `LogMode.INFO` (1) - Balanced: shows INFO, WARN, ERROR, LOG messages
249
+ - `LogMode.WARN` (2) - Focused: shows WARN, ERROR, LOG messages
250
+ - `LogMode.ERROR` (3) - Minimal: shows ERROR, LOG messages
251
+ - `LogMode.SILENT` (4) - Critical only: shows LOG messages only
252
+ - `LogMode.OFF` (5) - Complete silence: shows no messages at all
253
+
254
+ ### Message Severity Levels
255
+
256
+ Individual log messages have severity levels that determine their importance:
257
+
258
+ - `LogLevel.DEBUG` (0) - Detailed information for debugging
259
+ - `LogLevel.INFO` (1) - General information
260
+ - `LogLevel.WARN` (2) - Warning messages
261
+ - `LogLevel.ERROR` (3) - Error messages
262
+ - `LogLevel.LOG` (99) - Critical messages that always show (except when OFF mode is set)
263
+
264
+ ### Auto-Configuration
265
+
266
+ Log Engine automatically configures itself based on the `NODE_ENV` environment variable:
267
+
268
+ - `development` → `LogMode.DEBUG` (most verbose)
269
+ - `production` → `LogMode.INFO` (balanced)
270
+ - `staging` → `LogMode.WARN` (focused)
271
+ - `test` → `LogMode.ERROR` (minimal)
272
+ - `default` → `LogMode.INFO` (balanced)
273
+
274
+ ### Special LOG Level
275
+
276
+ The `LOG` level is special and behaves differently from other levels:
277
+
278
+ - **Always Visible**: LOG messages are always displayed regardless of the configured log mode (except when OFF mode is set)
279
+ - **Critical Information**: Perfect for essential system messages, application lifecycle events, and operational information that must never be filtered out
280
+ - **Green Color**: Uses green coloring to distinguish it from other levels
281
+ - **Use Cases**: Application startup/shutdown, server listening notifications, critical configuration changes, deployment information
282
+
283
+ ```typescript
284
+ import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
285
+
286
+ // Even with SILENT mode, LOG messages still appear
287
+ LogEngine.configure({ mode: LogMode.SILENT });
288
+
289
+ LogEngine.debug('Debug message'); // Hidden
290
+ LogEngine.info('Info message'); // Hidden
291
+ LogEngine.warn('Warning message'); // Hidden
292
+ LogEngine.error('Error message'); // Hidden
293
+ LogEngine.log('Server started on port 3000'); // ✅ Always visible!
294
+
295
+ // But with OFF mode, even LOG messages are hidden
296
+ LogEngine.configure({ mode: LogMode.OFF });
297
+ LogEngine.log('This LOG message is hidden'); // ❌ Hidden with OFF mode
298
+ ```
299
+
300
+ ### Complete Silence with OFF Mode
301
+
302
+ The `OFF` mode provides complete logging silence when you need to disable all output:
303
+
304
+ - **Total Silence**: Disables ALL logging including the special LOG level messages
305
+ - **Testing & CI/CD**: Perfect for automated testing environments where no console output is desired
306
+ - **Performance**: Minimal overhead when logging is completely disabled
307
+ - **Use Cases**: Unit tests, CI/CD pipelines, production environments requiring zero log output
308
+
309
+ ```typescript
310
+ import { LogEngine, LogMode } from '@wgtechlabs/log-engine';
311
+
312
+ // Comparison: SILENT vs OFF
313
+ LogEngine.configure({ mode: LogMode.SILENT });
314
+ LogEngine.info('Info message'); // Hidden
315
+ LogEngine.log('Critical message'); // ✅ Still visible with SILENT
316
+
317
+ LogEngine.configure({ mode: LogMode.OFF });
318
+ LogEngine.info('Info message'); // Hidden
319
+ LogEngine.log('Critical message'); // ❌ Hidden with OFF - complete silence!
320
+ ```
321
+
322
+ ### Log Format
323
+
324
+ Log messages are beautifully formatted with colorized timestamps, levels, and smart terminal output:
325
+
326
+ ```bash
327
+ # Example colorized output (colors visible in terminal)
328
+ [2025-05-29T16:57:45.678Z][4:57PM][DEBUG]: Debugging application flow
329
+ [2025-05-29T16:57:46.123Z][4:57PM][INFO]: Server started successfully
330
+ [2025-05-29T16:57:47.456Z][4:57PM][WARN]: API rate limit approaching
331
+ [2025-05-29T16:57:48.789Z][4:57PM][ERROR]: Database connection failed
332
+ [2025-05-29T16:57:49.012Z][4:57PM][LOG]: Application startup complete
333
+ ```
334
+
335
+ **Color Scheme:**
336
+
337
+ - đŸŸŖ **DEBUG**: Magenta/Purple - Detailed debugging information
338
+ - đŸ”ĩ **INFO**: Blue - General informational messages
339
+ - 🟡 **WARN**: Yellow - Warning messages that need attention
340
+ - 🔴 **ERROR**: Red - Error messages requiring immediate action
341
+ - đŸŸĸ **LOG**: Green - Critical messages that always display
342
+ - âšĢ **Timestamps**: Gray (ISO) and Cyan (local time) for easy scanning
343
+
344
+ ## 🔒 Advanced Data Redaction
345
+
346
+ **LogEngine features comprehensive built-in PII protection with advanced customization capabilities that automatically redacts sensitive information from your logs.** This security-first approach prevents accidental exposure of passwords, tokens, emails, and other sensitive data while maintaining full debugging capabilities with enterprise-grade flexibility.
347
+
348
+ ### Zero Configuration Security
349
+
350
+ Just use LogEngine normally - **sensitive data is automatically protected**:
351
+
352
+ ```typescript
353
+ import { LogEngine } from '@wgtechlabs/log-engine';
354
+
355
+ // ✅ Automatic redaction - no setup needed!
356
+ LogEngine.info('User authentication', {
357
+ username: 'john_doe', // ✅ Visible
358
+ password: 'secret123', // ❌ [REDACTED]
359
+ email: 'john@example.com', // ❌ [REDACTED]
360
+ apiKey: 'apikey123', // ❌ [REDACTED]
361
+ timestamp: new Date() // ✅ Visible
362
+ });
363
+
364
+ // Output: [INFO]: User authentication {"username":"john_doe","password":"[REDACTED]","email":"[REDACTED]","apiKey":"[REDACTED]","timestamp":"2025-06-17T..."}
365
+ ```
366
+
367
+ ### Protected Data Types
368
+
369
+ **50+ sensitive patterns automatically detected:**
370
+
371
+ - **Authentication**: `password`, `token`, `apiKey`, `secret`, `jwt`, `auth`, `sessionId`
372
+ - **Personal Info**: `email`, `phone`, `ssn`, `firstName`, `lastName`, `address`
373
+ - **Financial**: `creditCard`, `cvv`, `bankAccount`, `routingNumber`
374
+ - **System**: `clientSecret`, `privateKey`, `webhookSecret`
375
+
376
+ ### Deep Object Scanning
377
+
378
+ Automatically scans nested objects and arrays:
379
+
380
+ ```typescript
381
+ LogEngine.warn('Payment processing', {
382
+ order: {
383
+ id: 'order-123', // ✅ Visible
384
+ customer: {
385
+ username: 'customer1', // ✅ Visible
386
+ email: 'user@example.com', // ❌ [REDACTED]
387
+ creditCard: '4532-****' // ❌ [REDACTED]
388
+ }
389
+ },
390
+ metadata: {
391
+ processor: 'stripe',
392
+ apiSecret: 'sk_live_...' // ❌ [REDACTED]
393
+ }
394
+ });
395
+ ```
396
+
397
+ ### Content Truncation
398
+
399
+ Large content fields are automatically truncated to prevent log bloat:
400
+
401
+ ```typescript
402
+ LogEngine.debug('Large payload', {
403
+ content: 'Very long content...'.repeat(100), // Truncated at 100 chars + "... [TRUNCATED]"
404
+ size: 'large',
405
+ processed: true
406
+ });
407
+ ```
408
+
409
+ ### Development-Friendly Features
410
+
411
+ **Raw Methods for Debugging:**
412
+
413
+ ```typescript
414
+ // âš ī¸ Use with caution - bypasses redaction
415
+ LogEngine.debugRaw('Full debug data', {
416
+ password: 'secret123', // âš ī¸ Visible (not redacted)
417
+ apiKey: 'full-key' // âš ī¸ Visible (not redacted)
418
+ });
419
+
420
+ // Or use the helper method
421
+ LogEngine.withoutRedaction().info('Debug mode', sensitiveData);
422
+ ```
423
+
424
+ **Environment-Based Control:**
425
+
426
+ ```bash
427
+ # Development - show everything (redaction disabled)
428
+ NODE_ENV=development
429
+
430
+ # Explicitly disable redaction
431
+ LOG_REDACTION_DISABLED=true
432
+ DEBUG_FULL_PAYLOADS=true
433
+
434
+ # Custom redaction configuration
435
+ LOG_REDACTION_TEXT="***CONFIDENTIAL***"
436
+ LOG_MAX_CONTENT_LENGTH=200
437
+ LOG_SENSITIVE_FIELDS="customField,companySecret,internalData"
438
+ LOG_TRUNCATION_TEXT="... [CUSTOM_TRUNCATED]"
439
+
440
+ # Advanced environment integration
441
+ LOG_REDACTION_ENABLED=false # Alternative disable method
442
+ ```
443
+
444
+ ### Custom Configuration
445
+
446
+ **Modify redaction behavior:**
447
+
448
+ ```typescript
449
+ // Custom redaction settings
450
+ LogEngine.configureRedaction({
451
+ redactionText: '***HIDDEN***',
452
+ maxContentLength: 200,
453
+ sensitiveFields: ['myCustomField', 'internalSecret']
454
+ });
455
+
456
+ // Get current configuration
457
+ const config = LogEngine.getRedactionConfig();
458
+ console.log(config);
459
+ ```
460
+
461
+ ### Advanced Redaction Features (v1.2.1+)
462
+
463
+ **Custom Patterns & Dynamic Field Management:**
464
+
465
+ ```typescript
466
+ // Add custom regex patterns for enterprise-specific data protection
467
+ LogEngine.addCustomRedactionPatterns([
468
+ /internal.*/i, // Matches any field starting with "internal"
469
+ /company.*/i, // Matches any field starting with "company"
470
+ /^config[A-Z]/ // Matches camelCase config fields
471
+ ]);
472
+
473
+ // Add custom sensitive field names dynamically
474
+ LogEngine.addSensitiveFields(['companySecret', 'internalToken', 'proprietaryData']);
475
+
476
+ // Test field redaction before logging
477
+ if (LogEngine.testFieldRedaction('myField')) {
478
+ console.log('Field will be redacted');
479
+ }
480
+
481
+ // Advanced configuration management
482
+ LogEngine.configureRedaction({
483
+ redactionText: '***CONFIDENTIAL***',
484
+ maxContentLength: 150,
485
+ customPatterns: [/private.*/i, /secret.*/i]
486
+ });
487
+
488
+ // Configuration utilities
489
+ const currentConfig = LogEngine.getRedactionConfig();
490
+ LogEngine.refreshRedactionConfig(); // Refresh from environment
491
+ LogEngine.resetRedactionConfig(); // Reset to defaults
492
+ LogEngine.clearCustomRedactionPatterns(); // Clear custom patterns
493
+ ```
494
+
495
+ **Enhanced Development Workflow:**
496
+
497
+ ```typescript
498
+ // Raw logging methods (bypass redaction) - use with caution
499
+ LogEngine.debugRaw('Full debug data', { password: 'visible', apiKey: 'full-key' });
500
+
501
+ // Temporary redaction bypass using helper method
502
+ LogEngine.withoutRedaction().info('Debug mode', sensitiveData);
503
+
504
+ // Compare outputs during development
505
+ LogEngine.info('With redaction', data); // ❌ [REDACTED]
506
+ LogEngine.withoutRedaction().info('Without redaction', data); // âš ī¸ Visible
507
+ ```
508
+
509
+ ### Environment Behavior
510
+
511
+ | Environment | Redaction Status | Use Case |
512
+ |-------------|------------------|----------|
513
+ | **Production** | 🔒 **Active** | Full protection for live systems |
514
+ | **Development** | đŸ› ī¸ **Disabled** | Full data visibility for debugging |
515
+ | **Staging** | 🔒 **Active** | Test with production-like security |
516
+ | **Test** | 🔒 **Active** | Consistent test environment |
517
+
518
+ ### Security Benefits
519
+
520
+ ✅ **Advanced Pattern Recognition** - Custom regex patterns for enterprise-specific data protection
521
+ ✅ **Dynamic Field Management** - Runtime configuration of sensitive fields with intelligent matching
522
+ ✅ **Comprehensive Testing API** - `testFieldRedaction()` for validation and debugging
523
+ ✅ **Environment Integration** - Seamless configuration via environment variables
524
+ ✅ **Development Workflow** - Raw logging methods and temporary redaction bypass for debugging
525
+ ✅ **Prevents Data Leaks** - Automatic protection against accidental exposure with 50+ built-in patterns
526
+ ✅ **Compliance Ready** - Helps meet GDPR, HIPAA, and other privacy requirements
527
+ ✅ **Zero Configuration** - Secure by default, advanced features when needed
528
+ ✅ **Performance Optimized** - Minimal overhead with intelligent processing and depth limiting
529
+ ✅ **TypeScript Excellence** - Full type safety with comprehensive interfaces and type definitions
530
+
531
+ **Perfect for:** Enterprise applications, compliance requirements, team development environments, production systems requiring both security and debugging flexibility, and any scenario where sensitive data protection is critical.
532
+
533
+ ## đŸŽ¯ Configurable Output Handlers
534
+
535
+ **LogEngine v2.0+ introduces revolutionary output routing capabilities that transform how and where your logs are delivered.** This powerful system enables custom log destinations, multiple simultaneous outputs, and production-ready handlers while maintaining the same simple API you know and love.
536
+
537
+ ### Zero-Configuration Custom Routing
538
+
539
+ **Redirect logs anywhere with a single configuration:**
540
+
541
+ ```typescript
542
+ import { LogEngine } from '@wgtechlabs/log-engine';
543
+
544
+ // Redirect to GUI application
545
+ LogEngine.configure({
546
+ outputHandler: (level, message, data) => {
547
+ updateReactUI({ level, message, timestamp: new Date() });
548
+ },
549
+ suppressConsoleOutput: true // Optional: disable console output
550
+ });
551
+
552
+ // Testing framework integration
553
+ const capturedLogs = [];
554
+ LogEngine.configure({
555
+ outputHandler: (level, message, data) => {
556
+ capturedLogs.push({ level, message, data });
557
+ },
558
+ suppressConsoleOutput: true
559
+ });
560
+
561
+ // Now use LogEngine normally - output goes to your custom handler
562
+ LogEngine.info('User logged in', { userId: 123 });
563
+ ```
564
+
565
+ ### Multiple Simultaneous Outputs
566
+
567
+ **Log to multiple destinations at once with built-in handlers:**
568
+
569
+ ```typescript
570
+ LogEngine.configure({
571
+ outputs: [
572
+ 'console', // Built-in console handler
573
+ 'silent', // Built-in silent handler (no output)
574
+ (level, message, data) => {
575
+ // Custom file handler
576
+ fs.appendFileSync('./app.log', `${new Date().toISOString()} [${level}] ${message}\n`);
577
+ },
578
+ (level, message, data) => {
579
+ // Custom network handler
580
+ if (level === 'error') {
581
+ sendToMonitoringService({ level, message, data });
582
+ }
583
+ }
584
+ ]
585
+ });
586
+
587
+ // Single log call outputs to all configured destinations
588
+ LogEngine.error('Database connection failed', { retries: 3 });
589
+ ```
590
+
591
+ ### Production-Ready Advanced Handlers
592
+
593
+ **Enterprise-grade file and HTTP outputs with advanced features:**
594
+
595
+ ```typescript
596
+ LogEngine.configure({
597
+ enhancedOutputs: [
598
+ 'console',
599
+ {
600
+ type: 'file',
601
+ config: {
602
+ filePath: './logs/app.log',
603
+ maxFileSize: 10485760, // 10MB rotation
604
+ maxBackupFiles: 5, // Keep 5 backup files
605
+ append: true, // Append mode
606
+ formatter: (level, message, data) => {
607
+ const timestamp = new Date().toISOString();
608
+ const dataStr = data ? ` | ${JSON.stringify(data)}` : '';
609
+ return `[${timestamp}] ${level.toUpperCase()}: ${message}${dataStr}\n`;
610
+ }
611
+ }
612
+ },
613
+ {
614
+ type: 'http',
615
+ config: {
616
+ url: 'https://api.datadog.com/v1/logs',
617
+ method: 'POST',
618
+ batchSize: 10, // Batch requests for performance
619
+ timeout: 5000, // 5-second timeout
620
+ headers: {
621
+ 'Authorization': 'Bearer your-api-key',
622
+ 'Content-Type': 'application/json'
623
+ },
624
+ formatter: (logs) => ({
625
+ service: 'my-app',
626
+ environment: process.env.NODE_ENV,
627
+ logs: logs.map(log => ({
628
+ timestamp: log.timestamp,
629
+ level: log.level,
630
+ message: log.message,
631
+ metadata: log.data
632
+ }))
633
+ })
634
+ }
635
+ }
636
+ ]
637
+ });
638
+ ```
639
+
640
+ ### Configuration Priority System
641
+
642
+ **Flexible configuration with intelligent priority handling:**
643
+
644
+ ```typescript
645
+ // Priority: outputs > enhancedOutputs > outputHandler > default console
646
+
647
+ // Single handler (legacy compatibility)
648
+ LogEngine.configure({
649
+ outputHandler: myHandler,
650
+ suppressConsoleOutput: true
651
+ });
652
+
653
+ // Multiple basic outputs - takes priority over outputHandler
654
+ LogEngine.configure({
655
+ outputs: ['console', myFileHandler, myNetworkHandler]
656
+ });
657
+
658
+ // Advanced outputs - used when outputs not specified
659
+ LogEngine.configure({
660
+ enhancedOutputs: [
661
+ 'console',
662
+ { type: 'file', config: { filePath: './app.log' } }
663
+ ]
664
+ });
665
+ ```
666
+
667
+ ### Error Handling & Resilience
668
+
669
+ **Robust error handling ensures logging never breaks your application:**
670
+
671
+ ```typescript
672
+ LogEngine.configure({
673
+ outputs: [
674
+ 'console', // Always works
675
+ (level, message) => {
676
+ throw new Error('Handler failed'); // This failure won't break other outputs
677
+ },
678
+ (level, message) => {
679
+ fs.writeFileSync('./logs/app.log', message); // This still works
680
+ }
681
+ ]
682
+ });
683
+
684
+ // If any handler fails, others continue working + fallback to console
685
+ LogEngine.error('Critical error'); // Logs to console + working file handler
686
+ ```
687
+
688
+ ### Output Handler Benefits
689
+
690
+ ✅ **GUI Integration** - Perfect for desktop applications, web dashboards, and real-time monitoring
691
+ ✅ **Testing Support** - Capture and assert on log output in automated tests
692
+ ✅ **Production Monitoring** - Send logs to Datadog, New Relic, CloudWatch, or custom endpoints
693
+ ✅ **File Logging** - Persistent logs with automatic rotation and backup management
694
+ ✅ **Silent Operation** - Disable console output for clean CLI tools and background services
695
+ ✅ **Multi-Destination** - Log to console + file + network simultaneously with zero overhead
696
+ ✅ **Error Isolation** - Failed outputs don't break other outputs or your application
697
+ ✅ **Backward Compatible** - Existing code works unchanged, new features are opt-in only
698
+ ✅ **TypeScript Ready** - Full type safety with comprehensive interfaces and IntelliSense
699
+ ✅ **Zero Dependencies** - Built-in handlers use only Node.js standard library
700
+
701
+ **Use Cases:** Desktop applications, testing frameworks, production monitoring, CI/CD pipelines, microservices, IoT devices, and any scenario requiring flexible log routing with enterprise-grade reliability.
702
+
703
+ ## 📚 Comprehensive TypeScript Support
704
+
705
+ **LogEngine v2.0+ includes extensive TypeScript definitions with 15+ interfaces for maximum type safety and developer experience:**
706
+
707
+ ### Core Interfaces
708
+
709
+ ```typescript
710
+ import {
711
+ LogEngine,
712
+ LogMode,
713
+ LogLevel,
714
+ ILogEngine,
715
+ ILogEngineWithoutRedaction,
716
+ RedactionConfig,
717
+ LoggerConfig,
718
+ LogOutputHandler,
719
+ FileOutputConfig,
720
+ HttpOutputConfig,
721
+ IDataRedactor
722
+ } from '@wgtechlabs/log-engine';
723
+
724
+ // Full type safety for all methods
725
+ const config: RedactionConfig = {
726
+ enabled: true,
727
+ sensitiveFields: ['password', 'token'],
728
+ redactionText: '[HIDDEN]',
729
+ maxContentLength: 100,
730
+ // ... fully typed configuration
731
+ };
732
+
733
+ // Type-safe output handler configuration
734
+ const outputHandler: LogOutputHandler = (level, message, data) => {
735
+ console.log(`[${level}] ${message}`, data);
736
+ };
737
+
738
+ const fileConfig: FileOutputConfig = {
739
+ filePath: './app.log',
740
+ maxFileSize: 1048576,
741
+ maxBackupFiles: 3,
742
+ formatter: (level, message, data) => `${level}: ${message}\n`
743
+ };
744
+
745
+ // Advanced redaction testing with return types
746
+ const isRedacted: boolean = LogEngine.testFieldRedaction('password');
747
+ const currentConfig: RedactionConfig = LogEngine.getRedactionConfig();
748
+
749
+ // Type-safe raw logging
750
+ const rawLogger: ILogEngineWithoutRedaction = LogEngine.withoutRedaction();
751
+ rawLogger.info('Debug info', sensitiveData); // Fully typed methods
752
+
753
+ // âš ī¸ Legacy (deprecated) - will be removed in v3.0.0
754
+ import { LogLevel } from '@wgtechlabs/log-engine';
755
+ LogEngine.configure({ level: LogLevel.DEBUG }); // Shows deprecation warning
756
+ ```
757
+
758
+ ### Available Interfaces
759
+
760
+ - **`ILogEngine`** - Complete LogEngine API with all methods
761
+ - **`ILogEngineWithoutRedaction`** - Raw logging methods interface
762
+ - **`IDataRedactor`** - Static DataRedactor class methods
763
+ - **`LogOutputHandler`** - Custom output handler function interface
764
+ - **`FileOutputConfig`** - File output handler configuration
765
+ - **`HttpOutputConfig`** - HTTP output handler configuration
766
+ - **`RedactionConfig`** - Comprehensive redaction configuration
767
+ - **`LoggerConfig`** - Logger configuration options (including output handlers)
768
+ - **`LogEntry`** - Structured log entry interface
769
+ - **`LogLevel`** - âš ī¸ **Deprecated**: Legacy level enumeration (use `LogMode` instead)
770
+ - **`LogMode`** - ✅ **Recommended**: Modern mode enumeration
771
+ - **`EnvironmentConfig`** - Environment variable documentation
772
+ - **`EnvironmentConfig`** - Environment variable documentation
773
+ - **Plus 5+ additional interfaces** for advanced output handling and configuration
774
+
775
+ **IDE Benefits:** IntelliSense, auto-completion, parameter hints, error detection, and comprehensive documentation tooltips throughout your development workflow.
776
+
777
+ ## đŸ’Ŧ Community Discussions
778
+
779
+ Join our community discussions to get help, share ideas, and connect with other users:
780
+
781
+ - đŸ“Ŗ **[Announcements](https://github.com/wgtechlabs/log-engine/discussions/categories/announcements)**: Official updates from the maintainer
782
+ - 📸 **[Showcase](https://github.com/wgtechlabs/log-engine/discussions/categories/showcase)**: Show and tell your implementation
783
+ - 💖 **[Wall of Love](https://github.com/wgtechlabs/log-engine/discussions/categories/wall-of-love)**: Share your experience with the library
784
+ - 🛟 **[Help & Support](https://github.com/wgtechlabs/log-engine/discussions/categories/help-support)**: Get assistance from the community
785
+ - 🧠 **[Ideas](https://github.com/wgtechlabs/log-engine/discussions/categories/ideas)**: Suggest new features and improvements
786
+
787
+ ## 🛟 Help & Support
788
+
789
+ ### Getting Help
790
+
791
+ Need assistance with the library? Here's how to get help:
792
+ <!-- markdownlint-disable MD051 -->
793
+ - **Community Support**: Check the [Help & Support](https://github.com/wgtechlabs/log-engine/discussions/categories/help-support) category in our GitHub Discussions for answers to common questions.
794
+ - **Ask a Question**: Create a [new discussion](https://github.com/wgtechlabs/log-engine/discussions/new?category=help-support) if you can't find answers to your specific issue.
795
+ - **Documentation**: Review the [usage instructions](#đŸ•šī¸-usage) in this README for common examples and configurations.
796
+ - **Known Issues**: Browse [existing issues](https://github.com/wgtechlabs/log-engine/issues) to see if your problem has already been reported.
797
+ <!-- markdownlint-enable MD051 -->
798
+
799
+ ### Reporting Issues
800
+
801
+ Please report any issues, bugs, or improvement suggestions by [creating a new issue](https://github.com/wgtechlabs/log-engine/issues/new/choose). Before submitting, please check if a similar issue already exists to avoid duplicates.
802
+
803
+ ### Security Vulnerabilities
804
+
805
+ For security vulnerabilities, please do not report them publicly. Follow the guidelines in our [security policy](./security.md) to responsibly disclose security issues.
806
+
807
+ Your contributions to improving this project are greatly appreciated! 🙏✨
808
+
809
+ ## đŸŽ¯ Contributing
810
+
811
+ Contributions are welcome, create a pull request to this repo and I will review your code. Please consider to submit your pull request to the `dev` branch. Thank you!
812
+
813
+ **Development Environment:**
814
+
815
+ - This project is configured for **local development workflows only** - no CI/CD setup required
816
+ - Uses **yarn** as the primary package manager for consistency
817
+ - Simple, cross-platform development setup with TypeScript, Jest, and ESLint
818
+ - Clean test output maintained using `jest.setup.js` to suppress console noise during testing
819
+ - All error logging functionality remains intact in production code
820
+ - Security scanning available via Snyk for dependency vulnerability checking
821
+
822
+ **Available Scripts:**
823
+
824
+ - `yarn test` - Run all tests
825
+ - `yarn test:watch` - Run tests in watch mode
826
+ - `yarn test:coverage` - Run tests with coverage reporting
827
+ - `yarn lint` - Run TypeScript and code quality checks
828
+ - `yarn lint:fix` - Automatically fix linting issues
829
+ - `yarn lint:security` - Run security-focused linting
830
+ - `yarn secure` - Run comprehensive security checks
831
+ - `yarn build` - Build the TypeScript project
832
+ - `yarn validate` - Run full validation (lint + test + build)
833
+
834
+ Read the project's [contributing guide](./CONTRIBUTING.md) for detailed development setup, testing guidelines, and contribution requirements.
835
+
836
+ ## 🙏 Sponsor
837
+
838
+ Like this project? **Leave a star**! ⭐⭐⭐⭐⭐
839
+
840
+ There are several ways you can support this project:
841
+
842
+ - [Become a sponsor](https://github.com/sponsors/wgtechlabs) and get some perks! 💖
843
+ - [Buy me a coffee](https://buymeacoffee.com/wgtechlabs) if you just love what I do! ☕
844
+
845
+ ## ⭐ GitHub Star Nomination
846
+
847
+ Found this project helpful? Consider nominating me **(@warengonzaga)** for the [GitHub Star program](https://stars.github.com/nominate/)! This recognition supports ongoing development of this project and [my other open-source projects](https://github.com/warengonzaga?tab=repositories). GitHub Stars are recognized for their significant contributions to the developer community - your nomination makes a difference and encourages continued innovation!
848
+
849
+ ## 📋 Code of Conduct
850
+
851
+ I'm committed to providing a welcoming and inclusive environment for all contributors and users. Please review the project's [Code of Conduct](./code_of_conduct.md) to understand the community standards and expectations for participation.
852
+
853
+ ## 📃 License
854
+
855
+ This project is licensed under the [MIT License](https://opensource.org/licenses/MIT). See the [LICENSE](LICENSE) file for the full license text.
856
+
857
+ ## 📝 Author
858
+
859
+ This project is created by **[Waren Gonzaga](https://github.com/warengonzaga)** under [WG Technology Labs](https://github.com/wgtechlabs), with the help of awesome [contributors](https://github.com/wgtechlabs/log-engine/graphs/contributors).
860
+
861
+ **Latest Version:** v2.1.0 - Enhanced with advanced output handlers, comprehensive security-first logging, complete TypeScript support, and 95%+ test coverage for local development workflows.
862
+
863
+ [![contributors](https://contrib.rocks/image?repo=wgtechlabs/log-engine)](https://github.com/wgtechlabs/log-engine/graphs/contributors)
864
+
865
+ ---
866
+
867
+ đŸ’ģ with â¤ī¸ by [Waren Gonzaga](https://warengonzaga.com) under [WG Technology Labs](https://wgtechlabs.com), and [Him](https://www.youtube.com/watch?v=HHrxS4diLew&t=44s) 🙏
868
+
869
+ <!-- GitAds-Verify: O4MESJK7VTBCELWNTFQAWB5HDX57H9MS -->