@geekmidas/logger 0.2.0 → 0.4.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 (40) hide show
  1. package/dist/console.cjs.map +1 -1
  2. package/dist/console.d.cts +2 -1
  3. package/dist/console.d.cts.map +1 -0
  4. package/dist/console.d.mts +2 -1
  5. package/dist/console.d.mts.map +1 -0
  6. package/dist/console.mjs.map +1 -1
  7. package/dist/index.d.cts +1 -1
  8. package/dist/index.d.mts +1 -1
  9. package/dist/pino.cjs.map +1 -1
  10. package/dist/pino.d.cts +3 -2
  11. package/dist/pino.d.cts.map +1 -0
  12. package/dist/pino.d.mts +3 -2
  13. package/dist/pino.d.mts.map +1 -0
  14. package/dist/pino.mjs.map +1 -1
  15. package/dist/{redact-paths-Br-tI2GZ.d.cts → redact-paths-CsK0_uz-.d.cts} +2 -1
  16. package/dist/redact-paths-CsK0_uz-.d.cts.map +1 -0
  17. package/dist/{redact-paths-CIsuxHH7.d.mts → redact-paths-D07eTMlH.d.mts} +2 -1
  18. package/dist/redact-paths-D07eTMlH.d.mts.map +1 -0
  19. package/dist/redact-paths-D0m0DIuQ.cjs.map +1 -1
  20. package/dist/redact-paths-DQoIXhkS.mjs.map +1 -1
  21. package/dist/redact-paths.d.cts +1 -1
  22. package/dist/redact-paths.d.mts +1 -1
  23. package/dist/{types-Bga8WDuP.d.mts → types-BDdpcrpy.d.mts} +2 -1
  24. package/dist/types-BDdpcrpy.d.mts.map +1 -0
  25. package/dist/{types-JxCFymH0.d.cts → types-Dk_k2-f_.d.cts} +2 -1
  26. package/dist/types-Dk_k2-f_.d.cts.map +1 -0
  27. package/dist/types-ag_0Cvbg.cjs.map +1 -1
  28. package/dist/types-yQ6XOihF.mjs.map +1 -1
  29. package/dist/types.d.cts +1 -1
  30. package/dist/types.d.mts +1 -1
  31. package/package.json +1 -1
  32. package/src/__tests__/console.spec.ts +648 -648
  33. package/src/__tests__/pino-redaction.integration.spec.ts +270 -270
  34. package/src/__tests__/pino.spec.ts +305 -305
  35. package/src/console.ts +100 -100
  36. package/src/index.ts +5 -5
  37. package/src/pino.ts +50 -50
  38. package/src/redact-paths.ts +52 -52
  39. package/src/types.ts +87 -87
  40. package/tsconfig.json +9 -0
package/src/types.ts CHANGED
@@ -12,10 +12,10 @@
12
12
  * ```
13
13
  */
14
14
  export type LogFn = {
15
- /** Structured logging with context object, optional message, and additional arguments */
16
- <T extends object>(obj: T, msg?: string, ...args: any[]): void;
17
- /** Simple string logging */
18
- (msg: string): void;
15
+ /** Structured logging with context object, optional message, and additional arguments */
16
+ <T extends object>(obj: T, msg?: string, ...args: any[]): void;
17
+ /** Simple string logging */
18
+ (msg: string): void;
19
19
  };
20
20
 
21
21
  /**
@@ -25,26 +25,26 @@ export type LogFn = {
25
25
  * @interface Logger
26
26
  */
27
27
  export interface Logger {
28
- /** Debug level logging - verbose information for debugging */
29
- debug: LogFn;
30
- /** Info level logging - general informational messages */
31
- info: LogFn;
32
- /** Warning level logging - potentially harmful situations */
33
- warn: LogFn;
34
- /** Error level logging - error events that might still allow the application to continue */
35
- error: LogFn;
36
- /** Fatal level logging - severe errors that will likely cause the application to abort */
37
- fatal: LogFn;
38
- /** Trace level logging - most detailed information */
39
- trace: LogFn;
40
- /**
41
- * Creates a child logger with additional context.
42
- * Child loggers inherit parent context and add their own.
43
- *
44
- * @param obj - Additional context to include in all child logger calls
45
- * @returns A new Logger instance with merged context
46
- */
47
- child: (obj: object) => Logger;
28
+ /** Debug level logging - verbose information for debugging */
29
+ debug: LogFn;
30
+ /** Info level logging - general informational messages */
31
+ info: LogFn;
32
+ /** Warning level logging - potentially harmful situations */
33
+ warn: LogFn;
34
+ /** Error level logging - error events that might still allow the application to continue */
35
+ error: LogFn;
36
+ /** Fatal level logging - severe errors that will likely cause the application to abort */
37
+ fatal: LogFn;
38
+ /** Trace level logging - most detailed information */
39
+ trace: LogFn;
40
+ /**
41
+ * Creates a child logger with additional context.
42
+ * Child loggers inherit parent context and add their own.
43
+ *
44
+ * @param obj - Additional context to include in all child logger calls
45
+ * @returns A new Logger instance with merged context
46
+ */
47
+ child: (obj: object) => Logger;
48
48
  }
49
49
 
50
50
  /**
@@ -65,13 +65,13 @@ export interface Logger {
65
65
  * ```
66
66
  */
67
67
  export enum LogLevel {
68
- Trace = 'trace',
69
- Debug = 'debug',
70
- Info = 'info',
71
- Warn = 'warn',
72
- Error = 'error',
73
- Fatal = 'fatal',
74
- Silent = 'silent',
68
+ Trace = 'trace',
69
+ Debug = 'debug',
70
+ Info = 'info',
71
+ Warn = 'warn',
72
+ Error = 'error',
73
+ Fatal = 'fatal',
74
+ Silent = 'silent',
75
75
  }
76
76
 
77
77
  /**
@@ -106,62 +106,62 @@ export enum LogLevel {
106
106
  * ```
107
107
  */
108
108
  export type RedactOptions =
109
- | string[]
110
- | {
111
- /** Paths to redact using dot notation or bracket notation for special chars */
112
- paths: string[];
113
- /** Custom replacement text (default: '[REDACTED]') */
114
- censor?: string | ((value: unknown, path: string[]) => unknown);
115
- /** Remove the field entirely instead of replacing (default: false) */
116
- remove?: boolean;
117
- /**
118
- * How to combine custom paths with default sensitive paths.
119
- * - 'merge': Custom paths are added to default paths (default)
120
- * - 'override': Only custom paths are used, defaults are ignored
121
- */
122
- resolution?: 'merge' | 'override';
123
- };
109
+ | string[]
110
+ | {
111
+ /** Paths to redact using dot notation or bracket notation for special chars */
112
+ paths: string[];
113
+ /** Custom replacement text (default: '[REDACTED]') */
114
+ censor?: string | ((value: unknown, path: string[]) => unknown);
115
+ /** Remove the field entirely instead of replacing (default: false) */
116
+ remove?: boolean;
117
+ /**
118
+ * How to combine custom paths with default sensitive paths.
119
+ * - 'merge': Custom paths are added to default paths (default)
120
+ * - 'override': Only custom paths are used, defaults are ignored
121
+ */
122
+ resolution?: 'merge' | 'override';
123
+ };
124
124
 
125
125
  export type CreateLoggerOptions = {
126
- /** Enable pretty printing with colors (disabled in production) */
127
- pretty?: boolean;
128
- /** Minimum log level to output */
129
- level?: LogLevel;
130
- /**
131
- * Redaction configuration for masking sensitive data.
132
- *
133
- * - `true`: Uses default sensitive paths (password, token, secret, etc.)
134
- * - `false` or `undefined`: No redaction applied
135
- * - `string[]`: Custom paths merged with defaults
136
- * - `object`: Advanced config with paths, censor, remove, and resolution options
137
- *
138
- * By default, custom paths are **merged** with the default sensitive paths.
139
- * Use `resolution: 'override'` to disable defaults and use only your paths.
140
- *
141
- * @example
142
- * ```typescript
143
- * // Use defaults only
144
- * createLogger({ redact: true });
145
- *
146
- * // Add custom paths (merged with defaults)
147
- * createLogger({ redact: ['user.ssn', 'custom.field'] });
148
- *
149
- * // Override defaults completely
150
- * createLogger({
151
- * redact: {
152
- * paths: ['only.these.paths'],
153
- * resolution: 'override',
154
- * }
155
- * });
156
- *
157
- * // Merge with custom censor
158
- * createLogger({
159
- * redact: {
160
- * paths: ['extra.secret'],
161
- * censor: '***',
162
- * }
163
- * });
164
- * ```
165
- */
166
- redact?: boolean | RedactOptions;
126
+ /** Enable pretty printing with colors (disabled in production) */
127
+ pretty?: boolean;
128
+ /** Minimum log level to output */
129
+ level?: LogLevel;
130
+ /**
131
+ * Redaction configuration for masking sensitive data.
132
+ *
133
+ * - `true`: Uses default sensitive paths (password, token, secret, etc.)
134
+ * - `false` or `undefined`: No redaction applied
135
+ * - `string[]`: Custom paths merged with defaults
136
+ * - `object`: Advanced config with paths, censor, remove, and resolution options
137
+ *
138
+ * By default, custom paths are **merged** with the default sensitive paths.
139
+ * Use `resolution: 'override'` to disable defaults and use only your paths.
140
+ *
141
+ * @example
142
+ * ```typescript
143
+ * // Use defaults only
144
+ * createLogger({ redact: true });
145
+ *
146
+ * // Add custom paths (merged with defaults)
147
+ * createLogger({ redact: ['user.ssn', 'custom.field'] });
148
+ *
149
+ * // Override defaults completely
150
+ * createLogger({
151
+ * redact: {
152
+ * paths: ['only.these.paths'],
153
+ * resolution: 'override',
154
+ * }
155
+ * });
156
+ *
157
+ * // Merge with custom censor
158
+ * createLogger({
159
+ * redact: {
160
+ * paths: ['extra.secret'],
161
+ * censor: '***',
162
+ * }
163
+ * });
164
+ * ```
165
+ */
166
+ redact?: boolean | RedactOptions;
167
167
  };
package/tsconfig.json ADDED
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "rootDir": "./src",
6
+ "composite": true
7
+ },
8
+ "include": ["src/**/*"]
9
+ }