@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.
- package/dist/console.cjs.map +1 -1
- package/dist/console.d.cts +2 -1
- package/dist/console.d.cts.map +1 -0
- package/dist/console.d.mts +2 -1
- package/dist/console.d.mts.map +1 -0
- package/dist/console.mjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/pino.cjs.map +1 -1
- package/dist/pino.d.cts +3 -2
- package/dist/pino.d.cts.map +1 -0
- package/dist/pino.d.mts +3 -2
- package/dist/pino.d.mts.map +1 -0
- package/dist/pino.mjs.map +1 -1
- package/dist/{redact-paths-Br-tI2GZ.d.cts → redact-paths-CsK0_uz-.d.cts} +2 -1
- package/dist/redact-paths-CsK0_uz-.d.cts.map +1 -0
- package/dist/{redact-paths-CIsuxHH7.d.mts → redact-paths-D07eTMlH.d.mts} +2 -1
- package/dist/redact-paths-D07eTMlH.d.mts.map +1 -0
- package/dist/redact-paths-D0m0DIuQ.cjs.map +1 -1
- package/dist/redact-paths-DQoIXhkS.mjs.map +1 -1
- package/dist/redact-paths.d.cts +1 -1
- package/dist/redact-paths.d.mts +1 -1
- package/dist/{types-Bga8WDuP.d.mts → types-BDdpcrpy.d.mts} +2 -1
- package/dist/types-BDdpcrpy.d.mts.map +1 -0
- package/dist/{types-JxCFymH0.d.cts → types-Dk_k2-f_.d.cts} +2 -1
- package/dist/types-Dk_k2-f_.d.cts.map +1 -0
- package/dist/types-ag_0Cvbg.cjs.map +1 -1
- package/dist/types-yQ6XOihF.mjs.map +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +1 -1
- package/src/__tests__/console.spec.ts +648 -648
- package/src/__tests__/pino-redaction.integration.spec.ts +270 -270
- package/src/__tests__/pino.spec.ts +305 -305
- package/src/console.ts +100 -100
- package/src/index.ts +5 -5
- package/src/pino.ts +50 -50
- package/src/redact-paths.ts +52 -52
- package/src/types.ts +87 -87
- package/tsconfig.json +9 -0
package/src/types.ts
CHANGED
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
14
|
export type LogFn = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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
|
};
|