@wgtechlabs/log-engine 1.3.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 (42) hide show
  1. package/LICENSE +21 -661
  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 -63
  37. package/dist/formatter.d.ts +0 -49
  38. package/dist/formatter.d.ts.map +0 -1
  39. package/dist/formatter.js +0 -140
  40. package/dist/logger.d.ts +0 -128
  41. package/dist/logger.d.ts.map +0 -1
  42. package/dist/logger.js +0 -265
@@ -2,6 +2,11 @@
2
2
  * Type definitions for the Log Engine library
3
3
  * Provides strongly-typed interfaces for configuration and log levels
4
4
  */
5
+ /**
6
+ * Type for log data - accepts any value since logs can contain literally anything
7
+ * This is intentionally `any` rather than `unknown` for maximum usability in a logging context
8
+ */
9
+ export type LogData = any;
5
10
  /**
6
11
  * Log levels representing message severity (lowest to highest)
7
12
  * Used for filtering messages based on importance
@@ -48,6 +53,73 @@ export interface LogEntry {
48
53
  /** The actual log message content */
49
54
  message: string;
50
55
  }
56
+ /**
57
+ * Output handler function type for custom log output
58
+ * Receives the log level, formatted message, and optional data
59
+ */
60
+ export type LogOutputHandler = (level: string, message: string, data?: LogData) => void;
61
+ /**
62
+ * Built-in output handler types
63
+ */
64
+ export type BuiltInOutputHandler = 'console' | 'silent' | 'file' | 'http';
65
+ /**
66
+ * Configuration for file output handler
67
+ */
68
+ export interface FileOutputConfig {
69
+ /** File path to write logs to */
70
+ filePath: string;
71
+ /** Whether to append to existing file (default: true) */
72
+ append?: boolean;
73
+ /** Maximum file size before rotation in bytes (optional) */
74
+ maxFileSize?: number;
75
+ /** Number of backup files to keep during rotation (default: 3) */
76
+ maxBackupFiles?: number;
77
+ /** Custom format function for file output */
78
+ formatter?: (level: string, message: string, data?: LogData) => string;
79
+ }
80
+ /**
81
+ * Configuration for HTTP output handler
82
+ */
83
+ export interface HttpOutputConfig {
84
+ /** HTTP endpoint URL to send logs to */
85
+ url: string;
86
+ /** HTTP method (default: 'POST') */
87
+ method?: 'POST' | 'PUT' | 'PATCH';
88
+ /** Custom headers to include with requests */
89
+ headers?: Record<string, string>;
90
+ /** Batch size for sending multiple logs (default: 1) */
91
+ batchSize?: number;
92
+ /** Timeout for HTTP requests in ms (default: 5000) */
93
+ timeout?: number;
94
+ /** Custom format function for HTTP payload */
95
+ formatter?: (logs: Array<{
96
+ level: string;
97
+ message: string;
98
+ data?: LogData;
99
+ timestamp: string;
100
+ }>) => LogData;
101
+ }
102
+ /**
103
+ * Configuration object for advanced built-in handlers
104
+ */
105
+ export interface AdvancedOutputConfig {
106
+ file?: FileOutputConfig;
107
+ http?: HttpOutputConfig;
108
+ }
109
+ /**
110
+ * Enhanced output target - can be built-in handler, custom function, or configured handler object
111
+ */
112
+ export type EnhancedOutputTarget = BuiltInOutputHandler | LogOutputHandler | {
113
+ type: 'file';
114
+ config: FileOutputConfig;
115
+ } | {
116
+ type: 'http';
117
+ config: HttpOutputConfig;
118
+ };
119
+ /**
120
+ * Output target - can be a built-in handler string or custom function
121
+ */
122
+ export type OutputTarget = BuiltInOutputHandler | LogOutputHandler;
51
123
  /**
52
124
  * Configuration options for the logger
53
125
  * Supports both legacy level-based and new mode-based configuration
@@ -60,6 +132,16 @@ export interface LoggerConfig {
60
132
  level?: LogLevel;
61
133
  /** Optional environment identifier for context (e.g., 'production', 'staging') */
62
134
  environment?: string;
135
+ /** Custom output handler function to replace console output (backward compatibility) */
136
+ outputHandler?: LogOutputHandler;
137
+ /** Array of output targets for multiple simultaneous outputs */
138
+ outputs?: OutputTarget[];
139
+ /** Enhanced outputs with advanced configuration support */
140
+ enhancedOutputs?: EnhancedOutputTarget[];
141
+ /** Whether to suppress default console output (useful with custom outputHandler) */
142
+ suppressConsoleOutput?: boolean;
143
+ /** Advanced configuration for built-in handlers */
144
+ advancedOutputConfig?: AdvancedOutputConfig;
63
145
  }
64
146
  /**
65
147
  * Configuration options for automatic data redaction
@@ -91,25 +173,25 @@ export interface ILogEngine {
91
173
  /** Configure the logger with new settings */
92
174
  configure(config: Partial<LoggerConfig>): void;
93
175
  /** Log a debug message with automatic data redaction */
94
- debug(message: string, data?: any): void;
176
+ debug(message: string, data?: LogData): void;
95
177
  /** Log an info message with automatic data redaction */
96
- info(message: string, data?: any): void;
178
+ info(message: string, data?: LogData): void;
97
179
  /** Log a warn message with automatic data redaction */
98
- warn(message: string, data?: any): void;
180
+ warn(message: string, data?: LogData): void;
99
181
  /** Log an error message with automatic data redaction */
100
- error(message: string, data?: any): void;
182
+ error(message: string, data?: LogData): void;
101
183
  /** Log a message with automatic data redaction */
102
- log(message: string, data?: any): void;
184
+ log(message: string, data?: LogData): void;
103
185
  /** Log a debug message without redaction */
104
- debugRaw(message: string, data?: any): void;
186
+ debugRaw(message: string, data?: LogData): void;
105
187
  /** Log an info message without redaction */
106
- infoRaw(message: string, data?: any): void;
188
+ infoRaw(message: string, data?: LogData): void;
107
189
  /** Log a warn message without redaction */
108
- warnRaw(message: string, data?: any): void;
190
+ warnRaw(message: string, data?: LogData): void;
109
191
  /** Log an error message without redaction */
110
- errorRaw(message: string, data?: any): void;
192
+ errorRaw(message: string, data?: LogData): void;
111
193
  /** Log a message without redaction */
112
- logRaw(message: string, data?: any): void;
194
+ logRaw(message: string, data?: LogData): void;
113
195
  /** Configure redaction settings */
114
196
  configureRedaction(config: Partial<RedactionConfig>): void;
115
197
  /** Reset redaction configuration to defaults */
@@ -135,15 +217,15 @@ export interface ILogEngine {
135
217
  */
136
218
  export interface ILogEngineWithoutRedaction {
137
219
  /** Log a debug message without redaction */
138
- debug(message: string, data?: any): void;
220
+ debug(message: string, data?: LogData): void;
139
221
  /** Log an info message without redaction */
140
- info(message: string, data?: any): void;
222
+ info(message: string, data?: LogData): void;
141
223
  /** Log a warn message without redaction */
142
- warn(message: string, data?: any): void;
224
+ warn(message: string, data?: LogData): void;
143
225
  /** Log an error message without redaction */
144
- error(message: string, data?: any): void;
226
+ error(message: string, data?: LogData): void;
145
227
  /** Log a message without redaction */
146
- log(message: string, data?: any): void;
228
+ log(message: string, data?: LogData): void;
147
229
  }
148
230
  /**
149
231
  * Interface for the DataRedactor static class methods
@@ -165,7 +247,7 @@ export interface IDataRedactor {
165
247
  /** Test if a field name would be redacted */
166
248
  testFieldRedaction(fieldName: string): boolean;
167
249
  /** Redact sensitive data from any value */
168
- redactData(data: any): any;
250
+ redactData(data: LogData): LogData;
169
251
  }
170
252
  /**
171
253
  * Interface for the RedactionController methods
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,oBAAY,QAAQ;IAChB,qFAAqF;IACrF,KAAK,IAAI;IACT,2DAA2D;IAC3D,IAAI,IAAI;IACR,kEAAkE;IAClE,IAAI,IAAI;IACR,sEAAsE;IACtE,KAAK,IAAI;IACT,kGAAkG;IAClG,GAAG,KAAK;CACX;AAED;;;GAGG;AACH,oBAAY,OAAO;IACf,kEAAkE;IAClE,KAAK,IAAI;IACT,uDAAuD;IACvD,IAAI,IAAI;IACR,gDAAgD;IAChD,IAAI,IAAI;IACR,0CAA0C;IAC1C,KAAK,IAAI;IACT,8CAA8C;IAC9C,MAAM,IAAI;IACV,kDAAkD;IAClD,GAAG,IAAI;CACV;AAED;;;GAGG;AACH,MAAM,WAAW,QAAQ;IACrB,qCAAqC;IACrC,SAAS,EAAE,IAAI,CAAC;IAChB,2CAA2C;IAC3C,KAAK,EAAE,QAAQ,CAAC;IAChB,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;CACnB;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,qDAAqD;IACrD,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;0EACsE;IACtE,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,4CAA4C;IAC5C,OAAO,EAAE,OAAO,CAAC;IACjB,sFAAsF;IACtF,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,mFAAmF;IACnF,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,iEAAiE;IACjE,gBAAgB,EAAE,MAAM,CAAC;IACzB,kDAAkD;IAClD,aAAa,EAAE,MAAM,CAAC;IACtB,+CAA+C;IAC/C,c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iEAAiE;IACjE,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,iDAAiD;IACjD,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B"}
package/package.json CHANGED
@@ -1,63 +1,80 @@
1
- {
2
- "name": "@wgtechlabs/log-engine",
3
- "version": "1.3.0",
4
- "description": "A lightweight, security-first logging utility with automatic data redaction for Node.js applications - the first logging library with built-in PII protection.",
5
- "keywords": [
6
- "logging",
7
- "security",
8
- "redaction",
9
- "pii-protection",
10
- "data-redaction",
11
- "typescript",
12
- "nodejs",
13
- "bot",
14
- "discord",
15
- "telegram",
16
- "privacy",
17
- "gdpr",
18
- "compliance"
19
- ],
20
- "license": "AGPL-3.0",
21
- "author": "WG Tech Labs <opensource@wgtechlabs.com> (https://wgtechlabs.com)",
22
- "contributors": [
23
- "Waren Gonzaga <opensource@warengonzaga.com> (https://warengonzaga.com)"
24
- ],
25
- "main": "dist/index.js",
26
- "types": "dist/index.d.ts",
27
- "files": [
28
- "dist/**/*",
29
- "README.md",
30
- "LICENSE"
31
- ],
32
- "repository": {
33
- "type": "git",
34
- "url": "https://github.com/wgtechlabs/log-engine.git"
35
- },
36
- "scripts": {
37
- "build": "tsc",
38
- "start": "node dist/index.js",
39
- "prepublishOnly": "npm run build",
40
- "test": "jest",
41
- "test:watch": "jest --watch",
42
- "test:coverage": "jest --coverage",
43
- "test:coverage:watch": "jest --coverage --watch",
44
- "test:ci": "jest --ci --coverage --watchAll=false",
45
- "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
46
- "test:unit": "jest --testNamePattern=\"^((?!integration).)*$\"",
47
- "test:integration": "jest integration.test.ts",
48
- "clean": "rm -rf dist coverage",
49
- "coverage:open": "open coverage/lcov-report/index.html"
50
- },
51
- "dependencies": {},
52
- "devDependencies": {
53
- "typescript": "^5.0.0",
54
- "ts-node": "^10.0.0",
55
- "@types/node": "^18.0.0",
56
- "jest": "^29.0.0",
57
- "@types/jest": "^29.0.0",
58
- "ts-jest": "^29.0.0"
59
- },
60
- "engines": {
61
- "node": ">=16.0.0"
62
- }
63
- }
1
+ {
2
+ "name": "@wgtechlabs/log-engine",
3
+ "version": "2.1.0",
4
+ "description": "A lightweight, security-first logging utility with automatic data redaction for Node.js applications - the first logging library with built-in PII protection.",
5
+ "type": "module",
6
+ "keywords": [
7
+ "logging",
8
+ "security",
9
+ "redaction",
10
+ "pii-protection",
11
+ "data-redaction",
12
+ "typescript",
13
+ "nodejs",
14
+ "bot",
15
+ "discord",
16
+ "telegram",
17
+ "privacy",
18
+ "gdpr",
19
+ "compliance"
20
+ ],
21
+ "packageManager": "yarn@4.9.2",
22
+ "license": "MIT",
23
+ "author": "WG Tech Labs <opensource@wgtechlabs.com> (https://wgtechlabs.com)",
24
+ "contributors": [
25
+ "Waren Gonzaga <opensource@warengonzaga.com> (https://warengonzaga.com)"
26
+ ],
27
+ "main": "dist/index.js",
28
+ "types": "dist/index.d.ts",
29
+ "files": [
30
+ "dist/**/*",
31
+ "README.md",
32
+ "LICENSE"
33
+ ],
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/wgtechlabs/log-engine.git"
37
+ },
38
+ "scripts": {
39
+ "build": "tsc",
40
+ "start": "node dist/index.js",
41
+ "prepublishOnly": "yarn build",
42
+ "test": "jest",
43
+ "test:watch": "jest --watch",
44
+ "test:coverage": "jest --coverage",
45
+ "test:coverage:watch": "jest --coverage --watch",
46
+ "test:debug": "node --inspect-brk node_modules/.bin/jest --runInBand",
47
+ "test:unit": "jest --testNamePattern=\"^((?!integration).)*$\"",
48
+ "test:integration": "jest integration.test.ts",
49
+ "test:redaction": "jest --testPathPattern=\"redaction/\"",
50
+ "lint": "eslint src/**/*.ts",
51
+ "lint:fix": "eslint src/**/*.ts --fix",
52
+ "lint:security": "eslint src/**/*.ts --config eslint.security.config.js",
53
+ "secure:scan": "snyk code test",
54
+ "secure:test": "snyk test --org=wgtechlabs",
55
+ "secure:code": "snyk code test --org=wgtechlabs",
56
+ "secure": "run-s lint:security secure:test secure:code",
57
+ "validate": "run-s lint test build",
58
+ "clean": "rm -rf dist coverage",
59
+ "coverage:open": "open coverage/lcov-report/index.html",
60
+ "coverage:upload": "curl -Os https://uploader.codecov.io/latest/windows/codecov.exe && codecov.exe"
61
+ },
62
+ "devDependencies": {
63
+ "@types/eslint-plugin-security": "^3",
64
+ "@types/jest": "^29.0.0",
65
+ "@types/node": "^18.0.0",
66
+ "@typescript-eslint/eslint-plugin": "^8.35.0",
67
+ "@typescript-eslint/parser": "^8.35.0",
68
+ "eslint": "^8.45.0",
69
+ "eslint-plugin-security": "^2.0.0",
70
+ "jest": "^29.0.0",
71
+ "npm-run-all": "^4.1.5",
72
+ "snyk": "^1.1000.0",
73
+ "ts-jest": "^29.0.0",
74
+ "ts-node": "^10.0.0",
75
+ "typescript": "^5.8.3"
76
+ },
77
+ "engines": {
78
+ "node": ">=16.0.0"
79
+ }
80
+ }
@@ -1,49 +0,0 @@
1
- /**
2
- * Log message formatter that provides colorized console output with timestamps
3
- * Handles ANSI color codes and structured log message formatting
4
- */
5
- import { LogLevel } from './types';
6
- /**
7
- * LogFormatter class responsible for formatting log messages with colors and timestamps
8
- * Creates readable, colored console output with ISO timestamps and local time
9
- */
10
- export declare class LogFormatter {
11
- private static readonly colors;
12
- /**
13
- * Formats a log message with timestamp, level indicator, and appropriate coloring
14
- * Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message [data]
15
- * @param level - The log level to format for
16
- * @param message - The message content to format
17
- * @param data - Optional data object to include in the log output
18
- * @returns Formatted string with ANSI colors and timestamps
19
- */
20
- static format(level: LogLevel, message: string, data?: any): string;
21
- /**
22
- * Formats a Log Engine system message with [LOG ENGINE] prefix instead of log levels
23
- * Used for internal messages like deprecation warnings that should be distinguished from user logs
24
- * @param message - The system message content to format
25
- * @returns Formatted string with ANSI colors, timestamps, and LOG ENGINE prefix
26
- */
27
- static formatSystemMessage(message: string): string;
28
- /**
29
- * Formats data objects for log output
30
- * Converts objects to readable JSON string format
31
- * @param data - Data to format
32
- * @returns Formatted string representation of the data
33
- */
34
- private static formatData;
35
- /**
36
- * Converts LogLevel enum to human-readable string
37
- * @param level - The LogLevel to convert
38
- * @returns String representation of the log level
39
- */
40
- private static getLevelName;
41
- /**
42
- * Maps LogLevel to appropriate ANSI color code
43
- * Colors help quickly identify message severity in console output
44
- * @param level - The LogLevel to get color for
45
- * @returns ANSI color escape sequence
46
- */
47
- private static getLevelColor;
48
- }
49
- //# sourceMappingURL=formatter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"formatter.d.ts","sourceRoot":"","sources":["../src/formatter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC;;;GAGG;AACH,qBAAa,YAAY;IAErB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAW5B;IAEF;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,MAAM;IA+BnE;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAkBnD;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAyBzB;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAW3B;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;CAU/B"}
package/dist/formatter.js DELETED
@@ -1,140 +0,0 @@
1
- "use strict";
2
- /**
3
- * Log message formatter that provides colorized console output with timestamps
4
- * Handles ANSI color codes and structured log message formatting
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.LogFormatter = void 0;
8
- const types_1 = require("./types");
9
- /**
10
- * LogFormatter class responsible for formatting log messages with colors and timestamps
11
- * Creates readable, colored console output with ISO timestamps and local time
12
- */
13
- class LogFormatter {
14
- /**
15
- * Formats a log message with timestamp, level indicator, and appropriate coloring
16
- * Creates a structured log entry: [ISO_TIMESTAMP][LOCAL_TIME][LEVEL]: message [data]
17
- * @param level - The log level to format for
18
- * @param message - The message content to format
19
- * @param data - Optional data object to include in the log output
20
- * @returns Formatted string with ANSI colors and timestamps
21
- */
22
- static format(level, message, data) {
23
- const now = new Date();
24
- const isoTimestamp = now.toISOString();
25
- const timeString = now.toLocaleTimeString('en-US', {
26
- hour: 'numeric',
27
- minute: '2-digit',
28
- hour12: true
29
- }).replace(/\s+/g, '');
30
- const levelName = this.getLevelName(level);
31
- const levelColor = this.getLevelColor(level);
32
- // Apply colors to each component for better readability
33
- const coloredTimestamp = `${this.colors.gray}[${isoTimestamp}]${this.colors.reset}`;
34
- const coloredTimeString = `${this.colors.cyan}[${timeString}]${this.colors.reset}`;
35
- const coloredLevel = `${levelColor}[${levelName}]${this.colors.reset}`;
36
- // Format the base message
37
- let formattedMessage = `${coloredTimestamp}${coloredTimeString}${coloredLevel}: ${message}`;
38
- // Append data if provided
39
- if (data !== undefined) {
40
- const dataString = this.formatData(data);
41
- if (dataString) {
42
- formattedMessage += ` ${this.colors.dim}${dataString}${this.colors.reset}`;
43
- }
44
- }
45
- return formattedMessage;
46
- }
47
- /**
48
- * Formats a Log Engine system message with [LOG ENGINE] prefix instead of log levels
49
- * Used for internal messages like deprecation warnings that should be distinguished from user logs
50
- * @param message - The system message content to format
51
- * @returns Formatted string with ANSI colors, timestamps, and LOG ENGINE prefix
52
- */
53
- static formatSystemMessage(message) {
54
- const now = new Date();
55
- const isoTimestamp = now.toISOString();
56
- const timeString = now.toLocaleTimeString('en-US', {
57
- hour: 'numeric',
58
- minute: '2-digit',
59
- hour12: true
60
- }).replace(/\s+/g, '');
61
- // Apply colors to each component for better readability
62
- const coloredTimestamp = `${LogFormatter.colors.gray}[${isoTimestamp}]${LogFormatter.colors.reset}`;
63
- const coloredTimeString = `${LogFormatter.colors.cyan}[${timeString}]${LogFormatter.colors.reset}`;
64
- const coloredLogEngine = `${LogFormatter.colors.yellow}[LOG ENGINE]${LogFormatter.colors.reset}`;
65
- const coloredMessage = `${LogFormatter.colors.yellow}${message}${LogFormatter.colors.reset}`;
66
- return `${coloredTimestamp}${coloredTimeString}${coloredLogEngine}: ${coloredMessage}`;
67
- }
68
- /**
69
- * Formats data objects for log output
70
- * Converts objects to readable JSON string format
71
- * @param data - Data to format
72
- * @returns Formatted string representation of the data
73
- */
74
- static formatData(data) {
75
- if (data === null) {
76
- return 'null';
77
- }
78
- if (data === undefined) {
79
- return '';
80
- }
81
- if (typeof data === 'string') {
82
- return data;
83
- }
84
- if (typeof data === 'number' || typeof data === 'boolean') {
85
- return String(data);
86
- }
87
- try {
88
- return JSON.stringify(data, null, 0);
89
- }
90
- catch (error) {
91
- // Fallback for objects that can't be stringified (e.g., circular references)
92
- return '[Object]';
93
- }
94
- }
95
- /**
96
- * Converts LogLevel enum to human-readable string
97
- * @param level - The LogLevel to convert
98
- * @returns String representation of the log level
99
- */
100
- static getLevelName(level) {
101
- switch (level) {
102
- case types_1.LogLevel.DEBUG: return 'DEBUG';
103
- case types_1.LogLevel.INFO: return 'INFO';
104
- case types_1.LogLevel.WARN: return 'WARN';
105
- case types_1.LogLevel.ERROR: return 'ERROR';
106
- case types_1.LogLevel.LOG: return 'LOG';
107
- default: return 'UNKNOWN';
108
- }
109
- }
110
- /**
111
- * Maps LogLevel to appropriate ANSI color code
112
- * Colors help quickly identify message severity in console output
113
- * @param level - The LogLevel to get color for
114
- * @returns ANSI color escape sequence
115
- */
116
- static getLevelColor(level) {
117
- switch (level) {
118
- case types_1.LogLevel.DEBUG: return this.colors.magenta; // Purple for debug info
119
- case types_1.LogLevel.INFO: return this.colors.blue; // Blue for general info
120
- case types_1.LogLevel.WARN: return this.colors.yellow; // Yellow for warnings
121
- case types_1.LogLevel.ERROR: return this.colors.red; // Red for errors
122
- case types_1.LogLevel.LOG: return this.colors.green; // Green for always-on log messages
123
- default: return this.colors.white; // White for unknown levels
124
- }
125
- }
126
- }
127
- exports.LogFormatter = LogFormatter;
128
- // ANSI color codes for terminal output styling
129
- LogFormatter.colors = {
130
- reset: '\x1b[0m', // Reset all formatting
131
- dim: '\x1b[2m', // Dim/faded text
132
- red: '\x1b[31m', // Red text (errors)
133
- yellow: '\x1b[33m', // Yellow text (warnings)
134
- blue: '\x1b[34m', // Blue text (info)
135
- magenta: '\x1b[35m', // Magenta text (debug)
136
- cyan: '\x1b[36m', // Cyan text (timestamps)
137
- white: '\x1b[37m', // White text (default)
138
- gray: '\x1b[90m', // Gray text (timestamps)
139
- green: '\x1b[32m' // Green text (log level)
140
- };
package/dist/logger.d.ts DELETED
@@ -1,128 +0,0 @@
1
- /**
2
- * Core Logger class that handles log message output with configurable levels
3
- * Supports DEBUG, INFO, WARN, ERROR, and LOG levels with intelligent filtering
4
- * LOG level always outputs regardless of configuration
5
- * Uses colorized console output with timestamps for better readability
6
- * Includes automatic data redaction for sensitive information
7
- */
8
- import { LoggerConfig } from './types';
9
- /**
10
- * Logger class responsible for managing log output and configuration
11
- * Provides mode-based filtering and formatted console output
12
- */
13
- export declare class Logger {
14
- private config;
15
- /**
16
- * Logger constructor - sets up environment-based auto-configuration
17
- */
18
- constructor();
19
- /**
20
- * Determines the appropriate log mode based on NODE_ENV
21
- * @returns LogMode appropriate for current environment
22
- */
23
- private getEnvironmentMode;
24
- /**
25
- * Updates logger configuration with new settings
26
- * Merges provided config with existing settings (partial update)
27
- * Supports backwards compatibility by mapping level to mode with deprecation warnings
28
- * Also updates redaction configuration based on environment
29
- * @param config - Partial configuration object to apply
30
- */
31
- configure(config: Partial<LoggerConfig>): void;
32
- /**
33
- * Maps LogLevel values to severity ranks for consistent comparison
34
- * This prevents issues if enum numeric values change in the future
35
- */
36
- private static readonly SEVERITY_RANKS;
37
- /**
38
- * Maps LogMode values to minimum severity rank required for output
39
- * This defines the filtering threshold for each mode
40
- */
41
- private static readonly MODE_THRESHOLDS;
42
- /**
43
- * Determines if a message should be logged based on current log mode
44
- * Messages are shown only if their level is appropriate for the configured mode
45
- * LOG level is special - it always outputs regardless of configured mode (except when OFF is set)
46
- * OFF mode disables all logging including LOG level messages
47
- * @param level - The log level of the message to check
48
- * @returns true if message should be logged, false otherwise
49
- */
50
- private shouldLog;
51
- /**
52
- * Log a debug message with DEBUG level formatting
53
- * Uses console.log for output with purple/magenta coloring
54
- * Automatically redacts sensitive data when provided
55
- * @param message - The debug message to log
56
- * @param data - Optional data object to log (will be redacted)
57
- */
58
- debug(message: string, data?: any): void;
59
- /**
60
- * Log an informational message with INFO level formatting
61
- * Uses console.log for output with blue coloring
62
- * Automatically redacts sensitive data when provided
63
- * @param message - The info message to log
64
- * @param data - Optional data object to log (will be redacted)
65
- */
66
- info(message: string, data?: any): void;
67
- /**
68
- * Log a warning message with WARN level formatting
69
- * Uses console.warn for output with yellow coloring
70
- * Automatically redacts sensitive data when provided
71
- * @param message - The warning message to log
72
- * @param data - Optional data object to log (will be redacted)
73
- */
74
- warn(message: string, data?: any): void;
75
- /**
76
- * Log an error message with ERROR level formatting
77
- * Uses console.error for output with red coloring
78
- * Automatically redacts sensitive data when provided
79
- * @param message - The error message to log
80
- * @param data - Optional data object to log (will be redacted)
81
- */
82
- error(message: string, data?: any): void;
83
- /**
84
- * Log a critical message that always outputs (LOG level)
85
- * Uses console.log for output with green coloring
86
- * Always shown regardless of configured log level
87
- * Automatically redacts sensitive data when provided
88
- * @param message - The critical log message to log
89
- * @param data - Optional data object to log (will be redacted)
90
- */
91
- log(message: string, data?: any): void;
92
- /**
93
- * Log a debug message without redaction (use with caution)
94
- * Bypasses automatic data redaction for debugging purposes
95
- * @param message - The debug message to log
96
- * @param data - Optional data object to log (no redaction applied)
97
- */
98
- debugRaw(message: string, data?: any): void;
99
- /**
100
- * Log an info message without redaction (use with caution)
101
- * Bypasses automatic data redaction for debugging purposes
102
- * @param message - The info message to log
103
- * @param data - Optional data object to log (no redaction applied)
104
- */
105
- infoRaw(message: string, data?: any): void;
106
- /**
107
- * Log a warning message without redaction (use with caution)
108
- * Bypasses automatic data redaction for debugging purposes
109
- * @param message - The warning message to log
110
- * @param data - Optional data object to log (no redaction applied)
111
- */
112
- warnRaw(message: string, data?: any): void;
113
- /**
114
- * Log an error message without redaction (use with caution)
115
- * Bypasses automatic data redaction for debugging purposes
116
- * @param message - The error message to log
117
- * @param data - Optional data object to log (no redaction applied)
118
- */
119
- errorRaw(message: string, data?: any): void;
120
- /**
121
- * Log a critical message without redaction (use with caution)
122
- * Bypasses automatic data redaction for debugging purposes
123
- * @param message - The critical log message to log
124
- * @param data - Optional data object to log (no redaction applied)
125
- */
126
- logRaw(message: string, data?: any): void;
127
- }
128
- //# sourceMappingURL=logger.d.ts.map