@geekmidas/logger 0.0.1 → 0.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.
- package/README.md +114 -7
- package/dist/console.cjs +28 -2
- package/dist/console.cjs.map +1 -1
- package/dist/console.d.cts +17 -2
- package/dist/console.d.mts +17 -2
- package/dist/console.mjs +28 -3
- package/dist/console.mjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/pino.cjs +103 -1
- package/dist/pino.cjs.map +1 -1
- package/dist/pino.d.cts +36 -3
- package/dist/pino.d.mts +36 -3
- package/dist/pino.mjs +103 -2
- package/dist/pino.mjs.map +1 -1
- package/dist/{types-C1RfRbo6.d.mts → types-BFiJzL9N.d.mts} +86 -2
- package/dist/{types-DXdmn7h5.d.cts → types-JxCFymH0.d.cts} +86 -2
- package/dist/types-ag_0Cvbg.cjs.map +1 -1
- package/dist/types-yQ6XOihF.mjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.mts +2 -2
- package/package.json +5 -1
- package/src/__tests__/console.spec.ts +30 -3
- package/src/__tests__/pino-redaction.integration.spec.ts +307 -0
- package/src/__tests__/pino.spec.ts +199 -0
- package/src/console.ts +33 -4
- package/src/index.ts +1 -0
- package/src/pino.ts +173 -2
- package/src/types.ts +87 -0
package/README.md
CHANGED
|
@@ -4,13 +4,12 @@ A simple and flexible structured logging library for Node.js and browsers with c
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
- ✅ **Zero Dependencies**: No external dependencies
|
|
7
|
+
- **Standard Interface**: Common logger interface with multiple log levels (debug, info, warn, error, fatal, trace)
|
|
8
|
+
- **Structured Logging**: Support for both structured (object + message) and simple (message only) logging
|
|
9
|
+
- **Child Loggers**: Create child loggers with inherited context
|
|
10
|
+
- **Multiple Implementations**: ConsoleLogger for simple use, PinoLogger for production
|
|
11
|
+
- **Sensitive Data Redaction**: Built-in redaction for passwords, tokens, API keys, and more
|
|
12
|
+
- **TypeScript**: Full TypeScript support with type-safe logging
|
|
14
13
|
|
|
15
14
|
## Installation
|
|
16
15
|
|
|
@@ -38,6 +37,114 @@ logger.info('Application started');
|
|
|
38
37
|
logger.error({ error, operation: 'fetchUser' }, 'Failed to fetch user');
|
|
39
38
|
```
|
|
40
39
|
|
|
40
|
+
## Pino Logger
|
|
41
|
+
|
|
42
|
+
For production use, the package provides a Pino-based logger with high performance and built-in redaction support.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { createLogger } from '@geekmidas/logger/pino';
|
|
46
|
+
|
|
47
|
+
const logger = createLogger({
|
|
48
|
+
level: 'info',
|
|
49
|
+
pretty: true, // Pretty printing in development
|
|
50
|
+
redact: true, // Enable sensitive data redaction
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
logger.info({ userId: 123 }, 'User logged in');
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Sensitive Data Redaction
|
|
57
|
+
|
|
58
|
+
The Pino logger includes built-in redaction to automatically mask sensitive data like passwords, tokens, and API keys.
|
|
59
|
+
|
|
60
|
+
### Enable with Defaults
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
import { createLogger } from '@geekmidas/logger/pino';
|
|
64
|
+
|
|
65
|
+
const logger = createLogger({ redact: true });
|
|
66
|
+
|
|
67
|
+
// Sensitive data is automatically masked
|
|
68
|
+
logger.info({ password: 'secret123', user: 'john' }, 'Login attempt');
|
|
69
|
+
// Output: { password: '[Redacted]', user: 'john' } Login attempt
|
|
70
|
+
|
|
71
|
+
logger.info({ headers: { authorization: 'Bearer xyz' } }, 'Request');
|
|
72
|
+
// Output: { headers: { authorization: '[Redacted]' } } Request
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Default Redacted Fields
|
|
76
|
+
|
|
77
|
+
When `redact: true`, the following fields are automatically masked:
|
|
78
|
+
|
|
79
|
+
- **Authentication**: `password`, `pass`, `passwd`, `secret`, `token`, `accessToken`, `refreshToken`, `apiKey`, `api_key`, `authorization`, `credentials`
|
|
80
|
+
- **Headers**: `headers.authorization`, `headers.cookie`, `headers["x-api-key"]`
|
|
81
|
+
- **Personal Data**: `ssn`, `creditCard`, `cardNumber`, `cvv`, `pin`
|
|
82
|
+
- **Secrets**: `connectionString`, `databaseUrl`
|
|
83
|
+
- **Wildcards**: `*.password`, `*.secret`, `*.token` (catches nested fields)
|
|
84
|
+
|
|
85
|
+
### Add Custom Paths (Merged with Defaults)
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const logger = createLogger({
|
|
89
|
+
redact: ['user.ssn', 'payment.cardNumber'],
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Both custom paths AND defaults are redacted
|
|
93
|
+
logger.info({ password: 'secret', user: { ssn: '123-45-6789' } }, 'Data');
|
|
94
|
+
// Output: { password: '[Redacted]', user: { ssn: '[Redacted]' } } Data
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Override Defaults
|
|
98
|
+
|
|
99
|
+
Use `resolution: 'override'` to disable default paths and use only your custom paths:
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
const logger = createLogger({
|
|
103
|
+
redact: {
|
|
104
|
+
paths: ['myCustomSecret'],
|
|
105
|
+
resolution: 'override',
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// Only 'myCustomSecret' is redacted, defaults are ignored
|
|
110
|
+
logger.info({ password: 'visible', myCustomSecret: 'hidden' }, 'Data');
|
|
111
|
+
// Output: { password: 'visible', myCustomSecret: '[Redacted]' } Data
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Custom Censor and Remove
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
// Custom censor string
|
|
118
|
+
const logger = createLogger({
|
|
119
|
+
redact: {
|
|
120
|
+
paths: ['secret'],
|
|
121
|
+
censor: '***HIDDEN***',
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Remove fields entirely instead of masking
|
|
126
|
+
const logger2 = createLogger({
|
|
127
|
+
redact: {
|
|
128
|
+
paths: ['temporaryData'],
|
|
129
|
+
remove: true,
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Path Syntax
|
|
135
|
+
|
|
136
|
+
Redaction paths support dot notation and wildcards:
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
redact: [
|
|
140
|
+
'password', // Top-level field
|
|
141
|
+
'user.password', // Nested field
|
|
142
|
+
'users[*].password', // Array wildcard
|
|
143
|
+
'*.secret', // Any object's 'secret' field
|
|
144
|
+
'headers["x-api-key"]', // Bracket notation for special chars
|
|
145
|
+
]
|
|
146
|
+
```
|
|
147
|
+
|
|
41
148
|
## API Reference
|
|
42
149
|
|
|
43
150
|
### Logger Interface
|
package/dist/console.cjs
CHANGED
|
@@ -17,11 +17,19 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
17
17
|
* @private
|
|
18
18
|
*/
|
|
19
19
|
createLogFn(logMethod) {
|
|
20
|
-
return (
|
|
20
|
+
return (objOrMsg, msg, ...args) => {
|
|
21
21
|
const ts = Date.now();
|
|
22
|
+
if (typeof objOrMsg === "string") {
|
|
23
|
+
const mergedData$1 = {
|
|
24
|
+
...this.data,
|
|
25
|
+
ts
|
|
26
|
+
};
|
|
27
|
+
logMethod(mergedData$1, objOrMsg, ...args);
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
22
30
|
const mergedData = {
|
|
23
31
|
...this.data,
|
|
24
|
-
...
|
|
32
|
+
...objOrMsg,
|
|
25
33
|
ts
|
|
26
34
|
};
|
|
27
35
|
if (msg) logMethod(mergedData, msg, ...args);
|
|
@@ -87,8 +95,26 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
87
95
|
* ```
|
|
88
96
|
*/
|
|
89
97
|
const DEFAULT_LOGGER = new ConsoleLogger();
|
|
98
|
+
/**
|
|
99
|
+
* Creates a console logger with the same API as pino's createLogger.
|
|
100
|
+
*
|
|
101
|
+
* @param options - Logger configuration options
|
|
102
|
+
* @returns A ConsoleLogger instance
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* import { createLogger } from '@geekmidas/logger/console';
|
|
107
|
+
*
|
|
108
|
+
* const logger = createLogger({ level: LogLevel.Debug });
|
|
109
|
+
* logger.info({ action: 'start' }, 'Application starting');
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
function createLogger(options = {}) {
|
|
113
|
+
return new ConsoleLogger();
|
|
114
|
+
}
|
|
90
115
|
|
|
91
116
|
//#endregion
|
|
92
117
|
exports.ConsoleLogger = ConsoleLogger;
|
|
93
118
|
exports.DEFAULT_LOGGER = DEFAULT_LOGGER;
|
|
119
|
+
exports.createLogger = createLogger;
|
|
94
120
|
//# sourceMappingURL=console.cjs.map
|
package/dist/console.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.cjs","names":["data: object","logMethod: (...args: any[]) => void","
|
|
1
|
+
{"version":3,"file":"console.cjs","names":["data: object","logMethod: (...args: any[]) => void","objOrMsg: T | string","msg?: string","mergedData","obj: object","options: CreateLoggerOptions"],"sources":["../src/console.ts"],"sourcesContent":["import type { CreateLoggerOptions, LogFn, Logger } from './types';\n\nexport class ConsoleLogger implements Logger {\n /**\n * Creates a new ConsoleLogger instance.\n *\n * @param data - Initial context data to include in all log messages\n */\n constructor(readonly data: object = {}) {}\n\n /**\n * Creates a logging function that merges context data and adds timestamps.\n *\n * @param logMethod - The console method to use (e.g., console.log, console.error)\n * @returns A LogFn that handles both structured and simple logging\n * @private\n */\n private createLogFn(logMethod: (...args: any[]) => void): LogFn {\n return <T extends object>(\n objOrMsg: T | string,\n msg?: string,\n ...args: any[]\n ): void => {\n const ts = Date.now();\n\n // Handle simple string logging: logger.info('message')\n if (typeof objOrMsg === 'string') {\n const mergedData = { ...this.data, ts };\n logMethod(mergedData, objOrMsg, ...args);\n return;\n }\n\n // Handle structured logging: logger.info({ data }, 'message')\n const mergedData = { ...this.data, ...objOrMsg, ts };\n if (msg) {\n logMethod(mergedData, msg, ...args);\n } else {\n logMethod(mergedData, ...args);\n }\n };\n }\n\n /** Debug level logging function */\n debug: LogFn = this.createLogFn(console.debug.bind(console));\n /** Info level logging function */\n info: LogFn = this.createLogFn(console.info.bind(console));\n /** Warning level logging function */\n warn: LogFn = this.createLogFn(console.warn.bind(console));\n /** Error level logging function */\n error: LogFn = this.createLogFn(console.error.bind(console));\n /** Fatal level logging function (uses console.error) */\n fatal: LogFn = this.createLogFn(console.error.bind(console));\n /** Trace level logging function */\n trace: LogFn = this.createLogFn(console.trace.bind(console));\n\n /**\n * Creates a child logger with additional context data.\n * The child logger inherits all context from the parent and adds its own.\n *\n * @param obj - Additional context data for the child logger\n * @returns A new ConsoleLogger instance with merged context\n *\n * @example\n * ```typescript\n * const parentLogger = new ConsoleLogger({ app: 'myApp' });\n * const childLogger = parentLogger.child({ module: 'database' });\n * childLogger.info({ query: 'SELECT * FROM users' }, 'Query executed');\n * // Context includes both { app: 'myApp' } and { module: 'database' }\n * ```\n */\n child(obj: object): Logger {\n return new ConsoleLogger({\n ...this.data,\n ...obj,\n });\n }\n}\n\n/**\n * @example Basic usage\n * ```typescript\n * const logger = new ConsoleLogger({ app: 'myApp' });\n * logger.info({ action: 'start' }, 'Application starting');\n * // Logs: { app: 'myApp', action: 'start', ts: 1234567890 } Application starting\n * ```\n *\n * @example Child logger usage\n * ```typescript\n * const childLogger = logger.child({ module: 'auth' });\n * childLogger.debug({ userId: 123 }, 'User authenticated');\n * // Logs: { app: 'myApp', module: 'auth', userId: 123, ts: 1234567891 } User authenticated\n * ```\n *\n * @example Error logging with context\n * ```typescript\n * try {\n * await someOperation();\n * } catch (error) {\n * logger.error({ error, operation: 'someOperation' }, 'Operation failed');\n * }\n * ```\n */\n\nexport const DEFAULT_LOGGER = new ConsoleLogger() as any;\n\n/**\n * Creates a console logger with the same API as pino's createLogger.\n *\n * @param options - Logger configuration options\n * @returns A ConsoleLogger instance\n *\n * @example\n * ```typescript\n * import { createLogger } from '@geekmidas/logger/console';\n *\n * const logger = createLogger({ level: LogLevel.Debug });\n * logger.info({ action: 'start' }, 'Application starting');\n * ```\n */\nexport function createLogger(options: CreateLoggerOptions = {}): Logger {\n return new ConsoleLogger();\n}\n"],"mappings":";;AAEA,IAAa,gBAAb,MAAa,cAAgC;;;;;;CAM3C,YAAqBA,OAAe,CAAE,GAAE;EAAnB;CAAqB;;;;;;;;CAS1C,AAAQ,YAAYC,WAA4C;AAC9D,SAAO,CACLC,UACAC,KACA,GAAG,SACM;GACT,MAAM,KAAK,KAAK,KAAK;AAGrB,cAAW,aAAa,UAAU;IAChC,MAAMC,eAAa;KAAE,GAAG,KAAK;KAAM;IAAI;AACvC,cAAUA,cAAY,UAAU,GAAG,KAAK;AACxC;GACD;GAGD,MAAM,aAAa;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;GAAI;AACpD,OAAI,IACF,WAAU,YAAY,KAAK,GAAG,KAAK;OAEnC,WAAU,YAAY,GAAG,KAAK;EAEjC;CACF;;CAGD,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;CAE5D,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,CAAC;;CAE1D,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,CAAC;;CAE1D,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;CAE5D,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;CAE5D,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;;;;;;;;;;;;;;;CAiB5D,MAAMC,KAAqB;AACzB,SAAO,IAAI,cAAc;GACvB,GAAG,KAAK;GACR,GAAG;EACJ;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA2BD,MAAa,iBAAiB,IAAI;;;;;;;;;;;;;;;AAgBlC,SAAgB,aAAaC,UAA+B,CAAE,GAAU;AACtE,QAAO,IAAI;AACZ"}
|
package/dist/console.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogFn, Logger } from "./types-
|
|
1
|
+
import { CreateLoggerOptions, LogFn, Logger } from "./types-JxCFymH0.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/console.d.ts
|
|
4
4
|
declare class ConsoleLogger implements Logger {
|
|
@@ -71,6 +71,21 @@ declare class ConsoleLogger implements Logger {
|
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
declare const DEFAULT_LOGGER: any;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a console logger with the same API as pino's createLogger.
|
|
76
|
+
*
|
|
77
|
+
* @param options - Logger configuration options
|
|
78
|
+
* @returns A ConsoleLogger instance
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import { createLogger } from '@geekmidas/logger/console';
|
|
83
|
+
*
|
|
84
|
+
* const logger = createLogger({ level: LogLevel.Debug });
|
|
85
|
+
* logger.info({ action: 'start' }, 'Application starting');
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
74
89
|
//#endregion
|
|
75
|
-
export { ConsoleLogger, DEFAULT_LOGGER };
|
|
90
|
+
export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
|
|
76
91
|
//# sourceMappingURL=console.d.cts.map
|
package/dist/console.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LogFn, Logger } from "./types-
|
|
1
|
+
import { CreateLoggerOptions, LogFn, Logger } from "./types-BFiJzL9N.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/console.d.ts
|
|
4
4
|
declare class ConsoleLogger implements Logger {
|
|
@@ -71,6 +71,21 @@ declare class ConsoleLogger implements Logger {
|
|
|
71
71
|
* ```
|
|
72
72
|
*/
|
|
73
73
|
declare const DEFAULT_LOGGER: any;
|
|
74
|
+
/**
|
|
75
|
+
* Creates a console logger with the same API as pino's createLogger.
|
|
76
|
+
*
|
|
77
|
+
* @param options - Logger configuration options
|
|
78
|
+
* @returns A ConsoleLogger instance
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* ```typescript
|
|
82
|
+
* import { createLogger } from '@geekmidas/logger/console';
|
|
83
|
+
*
|
|
84
|
+
* const logger = createLogger({ level: LogLevel.Debug });
|
|
85
|
+
* logger.info({ action: 'start' }, 'Application starting');
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
74
89
|
//#endregion
|
|
75
|
-
export { ConsoleLogger, DEFAULT_LOGGER };
|
|
90
|
+
export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
|
|
76
91
|
//# sourceMappingURL=console.d.mts.map
|
package/dist/console.mjs
CHANGED
|
@@ -16,11 +16,19 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
16
16
|
* @private
|
|
17
17
|
*/
|
|
18
18
|
createLogFn(logMethod) {
|
|
19
|
-
return (
|
|
19
|
+
return (objOrMsg, msg, ...args) => {
|
|
20
20
|
const ts = Date.now();
|
|
21
|
+
if (typeof objOrMsg === "string") {
|
|
22
|
+
const mergedData$1 = {
|
|
23
|
+
...this.data,
|
|
24
|
+
ts
|
|
25
|
+
};
|
|
26
|
+
logMethod(mergedData$1, objOrMsg, ...args);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
21
29
|
const mergedData = {
|
|
22
30
|
...this.data,
|
|
23
|
-
...
|
|
31
|
+
...objOrMsg,
|
|
24
32
|
ts
|
|
25
33
|
};
|
|
26
34
|
if (msg) logMethod(mergedData, msg, ...args);
|
|
@@ -86,7 +94,24 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
86
94
|
* ```
|
|
87
95
|
*/
|
|
88
96
|
const DEFAULT_LOGGER = new ConsoleLogger();
|
|
97
|
+
/**
|
|
98
|
+
* Creates a console logger with the same API as pino's createLogger.
|
|
99
|
+
*
|
|
100
|
+
* @param options - Logger configuration options
|
|
101
|
+
* @returns A ConsoleLogger instance
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* import { createLogger } from '@geekmidas/logger/console';
|
|
106
|
+
*
|
|
107
|
+
* const logger = createLogger({ level: LogLevel.Debug });
|
|
108
|
+
* logger.info({ action: 'start' }, 'Application starting');
|
|
109
|
+
* ```
|
|
110
|
+
*/
|
|
111
|
+
function createLogger(options = {}) {
|
|
112
|
+
return new ConsoleLogger();
|
|
113
|
+
}
|
|
89
114
|
|
|
90
115
|
//#endregion
|
|
91
|
-
export { ConsoleLogger, DEFAULT_LOGGER };
|
|
116
|
+
export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
|
|
92
117
|
//# sourceMappingURL=console.mjs.map
|
package/dist/console.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.mjs","names":["data: object","logMethod: (...args: any[]) => void","
|
|
1
|
+
{"version":3,"file":"console.mjs","names":["data: object","logMethod: (...args: any[]) => void","objOrMsg: T | string","msg?: string","mergedData","obj: object","options: CreateLoggerOptions"],"sources":["../src/console.ts"],"sourcesContent":["import type { CreateLoggerOptions, LogFn, Logger } from './types';\n\nexport class ConsoleLogger implements Logger {\n /**\n * Creates a new ConsoleLogger instance.\n *\n * @param data - Initial context data to include in all log messages\n */\n constructor(readonly data: object = {}) {}\n\n /**\n * Creates a logging function that merges context data and adds timestamps.\n *\n * @param logMethod - The console method to use (e.g., console.log, console.error)\n * @returns A LogFn that handles both structured and simple logging\n * @private\n */\n private createLogFn(logMethod: (...args: any[]) => void): LogFn {\n return <T extends object>(\n objOrMsg: T | string,\n msg?: string,\n ...args: any[]\n ): void => {\n const ts = Date.now();\n\n // Handle simple string logging: logger.info('message')\n if (typeof objOrMsg === 'string') {\n const mergedData = { ...this.data, ts };\n logMethod(mergedData, objOrMsg, ...args);\n return;\n }\n\n // Handle structured logging: logger.info({ data }, 'message')\n const mergedData = { ...this.data, ...objOrMsg, ts };\n if (msg) {\n logMethod(mergedData, msg, ...args);\n } else {\n logMethod(mergedData, ...args);\n }\n };\n }\n\n /** Debug level logging function */\n debug: LogFn = this.createLogFn(console.debug.bind(console));\n /** Info level logging function */\n info: LogFn = this.createLogFn(console.info.bind(console));\n /** Warning level logging function */\n warn: LogFn = this.createLogFn(console.warn.bind(console));\n /** Error level logging function */\n error: LogFn = this.createLogFn(console.error.bind(console));\n /** Fatal level logging function (uses console.error) */\n fatal: LogFn = this.createLogFn(console.error.bind(console));\n /** Trace level logging function */\n trace: LogFn = this.createLogFn(console.trace.bind(console));\n\n /**\n * Creates a child logger with additional context data.\n * The child logger inherits all context from the parent and adds its own.\n *\n * @param obj - Additional context data for the child logger\n * @returns A new ConsoleLogger instance with merged context\n *\n * @example\n * ```typescript\n * const parentLogger = new ConsoleLogger({ app: 'myApp' });\n * const childLogger = parentLogger.child({ module: 'database' });\n * childLogger.info({ query: 'SELECT * FROM users' }, 'Query executed');\n * // Context includes both { app: 'myApp' } and { module: 'database' }\n * ```\n */\n child(obj: object): Logger {\n return new ConsoleLogger({\n ...this.data,\n ...obj,\n });\n }\n}\n\n/**\n * @example Basic usage\n * ```typescript\n * const logger = new ConsoleLogger({ app: 'myApp' });\n * logger.info({ action: 'start' }, 'Application starting');\n * // Logs: { app: 'myApp', action: 'start', ts: 1234567890 } Application starting\n * ```\n *\n * @example Child logger usage\n * ```typescript\n * const childLogger = logger.child({ module: 'auth' });\n * childLogger.debug({ userId: 123 }, 'User authenticated');\n * // Logs: { app: 'myApp', module: 'auth', userId: 123, ts: 1234567891 } User authenticated\n * ```\n *\n * @example Error logging with context\n * ```typescript\n * try {\n * await someOperation();\n * } catch (error) {\n * logger.error({ error, operation: 'someOperation' }, 'Operation failed');\n * }\n * ```\n */\n\nexport const DEFAULT_LOGGER = new ConsoleLogger() as any;\n\n/**\n * Creates a console logger with the same API as pino's createLogger.\n *\n * @param options - Logger configuration options\n * @returns A ConsoleLogger instance\n *\n * @example\n * ```typescript\n * import { createLogger } from '@geekmidas/logger/console';\n *\n * const logger = createLogger({ level: LogLevel.Debug });\n * logger.info({ action: 'start' }, 'Application starting');\n * ```\n */\nexport function createLogger(options: CreateLoggerOptions = {}): Logger {\n return new ConsoleLogger();\n}\n"],"mappings":";AAEA,IAAa,gBAAb,MAAa,cAAgC;;;;;;CAM3C,YAAqBA,OAAe,CAAE,GAAE;EAAnB;CAAqB;;;;;;;;CAS1C,AAAQ,YAAYC,WAA4C;AAC9D,SAAO,CACLC,UACAC,KACA,GAAG,SACM;GACT,MAAM,KAAK,KAAK,KAAK;AAGrB,cAAW,aAAa,UAAU;IAChC,MAAMC,eAAa;KAAE,GAAG,KAAK;KAAM;IAAI;AACvC,cAAUA,cAAY,UAAU,GAAG,KAAK;AACxC;GACD;GAGD,MAAM,aAAa;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;GAAI;AACpD,OAAI,IACF,WAAU,YAAY,KAAK,GAAG,KAAK;OAEnC,WAAU,YAAY,GAAG,KAAK;EAEjC;CACF;;CAGD,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;CAE5D,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,CAAC;;CAE1D,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,CAAC;;CAE1D,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;CAE5D,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;CAE5D,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,CAAC;;;;;;;;;;;;;;;;CAiB5D,MAAMC,KAAqB;AACzB,SAAO,IAAI,cAAc;GACvB,GAAG,KAAK;GACR,GAAG;EACJ;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA2BD,MAAa,iBAAiB,IAAI;;;;;;;;;;;;;;;AAgBlC,SAAgB,aAAaC,UAA+B,CAAE,GAAU;AACtE,QAAO,IAAI;AACZ"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-
|
|
2
|
-
export { CreateLoggerOptions, LogFn, LogLevel, Logger };
|
|
1
|
+
import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-JxCFymH0.cjs";
|
|
2
|
+
export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-
|
|
2
|
-
export { CreateLoggerOptions, LogFn, LogLevel, Logger };
|
|
1
|
+
import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-BFiJzL9N.mjs";
|
|
2
|
+
export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
|
package/dist/pino.cjs
CHANGED
|
@@ -24,14 +24,115 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
24
24
|
const pino = __toESM(require("pino"));
|
|
25
25
|
|
|
26
26
|
//#region src/pino.ts
|
|
27
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Default sensitive field paths for redaction.
|
|
29
|
+
*
|
|
30
|
+
* These paths are automatically used when `redact: true` is set,
|
|
31
|
+
* and merged with custom paths unless `resolution: 'override'` is specified.
|
|
32
|
+
*
|
|
33
|
+
* Includes:
|
|
34
|
+
* - Authentication: password, token, apiKey, authorization, credentials
|
|
35
|
+
* - Headers: authorization, cookie, x-api-key, x-auth-token
|
|
36
|
+
* - Personal data: ssn, creditCard, cvv, pin
|
|
37
|
+
* - Secrets: secret, connectionString, databaseUrl
|
|
38
|
+
* - Wildcards: *.password, *.secret, *.token (catches nested fields)
|
|
39
|
+
*/
|
|
40
|
+
const DEFAULT_REDACT_PATHS = [
|
|
41
|
+
"password",
|
|
42
|
+
"pass",
|
|
43
|
+
"passwd",
|
|
44
|
+
"secret",
|
|
45
|
+
"token",
|
|
46
|
+
"accessToken",
|
|
47
|
+
"refreshToken",
|
|
48
|
+
"idToken",
|
|
49
|
+
"apiKey",
|
|
50
|
+
"api_key",
|
|
51
|
+
"apikey",
|
|
52
|
+
"auth",
|
|
53
|
+
"authorization",
|
|
54
|
+
"credential",
|
|
55
|
+
"credentials",
|
|
56
|
+
"*.password",
|
|
57
|
+
"*.secret",
|
|
58
|
+
"*.token",
|
|
59
|
+
"*.apiKey",
|
|
60
|
+
"*.api_key",
|
|
61
|
+
"*.authorization",
|
|
62
|
+
"*.accessToken",
|
|
63
|
+
"*.refreshToken",
|
|
64
|
+
"headers.authorization",
|
|
65
|
+
"headers.Authorization",
|
|
66
|
+
"headers[\"authorization\"]",
|
|
67
|
+
"headers[\"Authorization\"]",
|
|
68
|
+
"headers.cookie",
|
|
69
|
+
"headers.Cookie",
|
|
70
|
+
"headers[\"x-api-key\"]",
|
|
71
|
+
"headers[\"X-Api-Key\"]",
|
|
72
|
+
"headers[\"x-auth-token\"]",
|
|
73
|
+
"headers[\"X-Auth-Token\"]",
|
|
74
|
+
"ssn",
|
|
75
|
+
"socialSecurityNumber",
|
|
76
|
+
"social_security_number",
|
|
77
|
+
"creditCard",
|
|
78
|
+
"credit_card",
|
|
79
|
+
"cardNumber",
|
|
80
|
+
"card_number",
|
|
81
|
+
"cvv",
|
|
82
|
+
"cvc",
|
|
83
|
+
"pin",
|
|
84
|
+
"connectionString",
|
|
85
|
+
"connection_string",
|
|
86
|
+
"databaseUrl",
|
|
87
|
+
"database_url"
|
|
88
|
+
];
|
|
89
|
+
/**
|
|
90
|
+
* Resolves redaction configuration from options.
|
|
91
|
+
* Returns undefined if redaction is disabled, or a pino-compatible redact config.
|
|
92
|
+
*
|
|
93
|
+
* By default (resolution: 'merge'), custom paths are merged with DEFAULT_REDACT_PATHS.
|
|
94
|
+
* With resolution: 'override', only the custom paths are used.
|
|
95
|
+
*/
|
|
96
|
+
function resolveRedactConfig(redact) {
|
|
97
|
+
if (redact === void 0 || redact === false) return void 0;
|
|
98
|
+
if (redact === true) return DEFAULT_REDACT_PATHS;
|
|
99
|
+
if (Array.isArray(redact)) return [...DEFAULT_REDACT_PATHS, ...redact];
|
|
100
|
+
const { resolution = "merge", paths, censor, remove } = redact;
|
|
101
|
+
const resolvedPaths = resolution === "override" ? paths : [...DEFAULT_REDACT_PATHS, ...paths];
|
|
102
|
+
const config = { paths: resolvedPaths };
|
|
103
|
+
if (censor !== void 0) config.censor = censor;
|
|
104
|
+
if (remove !== void 0) config.remove = remove;
|
|
105
|
+
return config;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates a pino logger instance with optional redaction support.
|
|
109
|
+
*
|
|
110
|
+
* @param options - Logger configuration options
|
|
111
|
+
* @returns A configured pino logger instance
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```typescript
|
|
115
|
+
* // Basic logger
|
|
116
|
+
* const logger = createLogger({ level: 'debug' });
|
|
117
|
+
*
|
|
118
|
+
* // With redaction enabled
|
|
119
|
+
* const secureLogger = createLogger({ redact: true });
|
|
120
|
+
*
|
|
121
|
+
* // Pretty printing in development
|
|
122
|
+
* const devLogger = createLogger({ pretty: true, redact: true });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
function createLogger(options = {}) {
|
|
28
126
|
const pretty = options?.pretty && process.NODE_ENV !== "production";
|
|
29
127
|
const baseOptions = pretty ? { transport: {
|
|
30
128
|
target: "pino-pretty",
|
|
31
129
|
options: { colorize: true }
|
|
32
130
|
} } : {};
|
|
131
|
+
const redact = resolveRedactConfig(options.redact);
|
|
33
132
|
return (0, pino.pino)({
|
|
34
133
|
...baseOptions,
|
|
134
|
+
...options.level && { level: options.level },
|
|
135
|
+
...redact && { redact },
|
|
35
136
|
formatters: {
|
|
36
137
|
bindings() {
|
|
37
138
|
return { nodeVersion: process.version };
|
|
@@ -44,5 +145,6 @@ function createLogger(options) {
|
|
|
44
145
|
}
|
|
45
146
|
|
|
46
147
|
//#endregion
|
|
148
|
+
exports.DEFAULT_REDACT_PATHS = DEFAULT_REDACT_PATHS;
|
|
47
149
|
exports.createLogger = createLogger;
|
|
48
150
|
//# sourceMappingURL=pino.cjs.map
|
package/dist/pino.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pino.cjs","names":["options: CreateLoggerOptions"],"sources":["../src/pino.ts"],"sourcesContent":["import { pino } from 'pino';\nimport type { CreateLoggerOptions } from './types';\n\nexport function createLogger(options: CreateLoggerOptions) {\n // @ts-ignore\n const pretty = options?.pretty && process.NODE_ENV !== 'production';\n const baseOptions = pretty\n ? {\n transport: {\n target: 'pino-pretty',\n options: { colorize: true },\n },\n }\n : {};\n return pino({\n ...baseOptions,\n formatters: {\n bindings() {\n return { nodeVersion: process.version };\n },\n level: (label) => {\n return { level: label.toUpperCase() };\n },\n },\n });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"pino.cjs","names":["DEFAULT_REDACT_PATHS: string[]","redact: boolean | RedactOptions | undefined","config: PinoRedactConfig","options: CreateLoggerOptions"],"sources":["../src/pino.ts"],"sourcesContent":["/**\n * Pino logger with built-in redaction support for sensitive data.\n *\n * @example\n * ```typescript\n * import { createLogger, DEFAULT_REDACT_PATHS } from '@geekmidas/logger/pino';\n *\n * // Enable redaction with sensible defaults\n * const logger = createLogger({ redact: true });\n *\n * // Sensitive data is automatically masked\n * logger.info({ password: 'secret123', user: 'john' }, 'Login');\n * // Output: { password: '[Redacted]', user: 'john' } Login\n *\n * // Add custom paths (merged with defaults)\n * const logger2 = createLogger({ redact: ['user.ssn'] });\n *\n * // Override defaults for full control\n * const logger3 = createLogger({\n * redact: {\n * paths: ['onlyThis'],\n * resolution: 'override',\n * }\n * });\n * ```\n *\n * @module\n */\nimport { pino } from 'pino';\nimport type { CreateLoggerOptions, RedactOptions } from './types';\n\n/**\n * Default sensitive field paths for redaction.\n *\n * These paths are automatically used when `redact: true` is set,\n * and merged with custom paths unless `resolution: 'override'` is specified.\n *\n * Includes:\n * - Authentication: password, token, apiKey, authorization, credentials\n * - Headers: authorization, cookie, x-api-key, x-auth-token\n * - Personal data: ssn, creditCard, cvv, pin\n * - Secrets: secret, connectionString, databaseUrl\n * - Wildcards: *.password, *.secret, *.token (catches nested fields)\n */\nexport const DEFAULT_REDACT_PATHS: string[] = [\n // Authentication & authorization\n 'password',\n 'pass',\n 'passwd',\n 'secret',\n 'token',\n 'accessToken',\n 'refreshToken',\n 'idToken',\n 'apiKey',\n 'api_key',\n 'apikey',\n 'auth',\n 'authorization',\n 'credential',\n 'credentials',\n\n // Common nested patterns (headers, body, etc.)\n '*.password',\n '*.secret',\n '*.token',\n '*.apiKey',\n '*.api_key',\n '*.authorization',\n '*.accessToken',\n '*.refreshToken',\n\n // HTTP headers (case variations)\n 'headers.authorization',\n 'headers.Authorization',\n 'headers[\"authorization\"]',\n 'headers[\"Authorization\"]',\n 'headers.cookie',\n 'headers.Cookie',\n 'headers[\"x-api-key\"]',\n 'headers[\"X-Api-Key\"]',\n 'headers[\"x-auth-token\"]',\n 'headers[\"X-Auth-Token\"]',\n\n // Common sensitive data fields\n 'ssn',\n 'socialSecurityNumber',\n 'social_security_number',\n 'creditCard',\n 'credit_card',\n 'cardNumber',\n 'card_number',\n 'cvv',\n 'cvc',\n 'pin',\n\n // Database & connection strings\n 'connectionString',\n 'connection_string',\n 'databaseUrl',\n 'database_url',\n];\n\n/**\n * Type for the resolved pino redact config (without our custom resolution field).\n */\ntype PinoRedactConfig =\n | string[]\n | {\n paths: string[];\n censor?: string | ((value: unknown, path: string[]) => unknown);\n remove?: boolean;\n };\n\n/**\n * Resolves redaction configuration from options.\n * Returns undefined if redaction is disabled, or a pino-compatible redact config.\n *\n * By default (resolution: 'merge'), custom paths are merged with DEFAULT_REDACT_PATHS.\n * With resolution: 'override', only the custom paths are used.\n */\nfunction resolveRedactConfig(\n redact: boolean | RedactOptions | undefined,\n): PinoRedactConfig | undefined {\n if (redact === undefined || redact === false) {\n return undefined;\n }\n\n if (redact === true) {\n return DEFAULT_REDACT_PATHS;\n }\n\n // Array syntax - merge with defaults\n if (Array.isArray(redact)) {\n return [...DEFAULT_REDACT_PATHS, ...redact];\n }\n\n // Object syntax - check resolution mode\n const { resolution = 'merge', paths, censor, remove } = redact;\n\n const resolvedPaths =\n resolution === 'override' ? paths : [...DEFAULT_REDACT_PATHS, ...paths];\n\n // Return clean pino config without our resolution field\n const config: PinoRedactConfig = { paths: resolvedPaths };\n if (censor !== undefined) config.censor = censor;\n if (remove !== undefined) config.remove = remove;\n\n return config;\n}\n\n/**\n * Creates a pino logger instance with optional redaction support.\n *\n * @param options - Logger configuration options\n * @returns A configured pino logger instance\n *\n * @example\n * ```typescript\n * // Basic logger\n * const logger = createLogger({ level: 'debug' });\n *\n * // With redaction enabled\n * const secureLogger = createLogger({ redact: true });\n *\n * // Pretty printing in development\n * const devLogger = createLogger({ pretty: true, redact: true });\n * ```\n */\nexport function createLogger(options: CreateLoggerOptions = {}) {\n // @ts-ignore\n const pretty = options?.pretty && process.NODE_ENV !== 'production';\n const baseOptions = pretty\n ? {\n transport: {\n target: 'pino-pretty',\n options: { colorize: true },\n },\n }\n : {};\n\n const redact = resolveRedactConfig(options.redact);\n\n return pino({\n ...baseOptions,\n ...(options.level && { level: options.level }),\n ...(redact && { redact }),\n formatters: {\n bindings() {\n return { nodeVersion: process.version };\n },\n level: (label) => {\n return { level: label.toUpperCase() };\n },\n },\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAaA,uBAAiC;CAE5C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;CACA;CACA;AACD;;;;;;;;AAoBD,SAAS,oBACPC,QAC8B;AAC9B,KAAI,qBAAwB,WAAW,MACrC;AAGF,KAAI,WAAW,KACb,QAAO;AAIT,KAAI,MAAM,QAAQ,OAAO,CACvB,QAAO,CAAC,GAAG,sBAAsB,GAAG,MAAO;CAI7C,MAAM,EAAE,aAAa,SAAS,OAAO,QAAQ,QAAQ,GAAG;CAExD,MAAM,gBACJ,eAAe,aAAa,QAAQ,CAAC,GAAG,sBAAsB,GAAG,KAAM;CAGzE,MAAMC,SAA2B,EAAE,OAAO,cAAe;AACzD,KAAI,kBAAsB,QAAO,SAAS;AAC1C,KAAI,kBAAsB,QAAO,SAAS;AAE1C,QAAO;AACR;;;;;;;;;;;;;;;;;;;AAoBD,SAAgB,aAAaC,UAA+B,CAAE,GAAE;CAE9D,MAAM,SAAS,SAAS,UAAU,QAAQ,aAAa;CACvD,MAAM,cAAc,SAChB,EACE,WAAW;EACT,QAAQ;EACR,SAAS,EAAE,UAAU,KAAM;CAC5B,EACF,IACD,CAAE;CAEN,MAAM,SAAS,oBAAoB,QAAQ,OAAO;AAElD,QAAO,eAAK;EACV,GAAG;EACH,GAAI,QAAQ,SAAS,EAAE,OAAO,QAAQ,MAAO;EAC7C,GAAI,UAAU,EAAE,OAAQ;EACxB,YAAY;GACV,WAAW;AACT,WAAO,EAAE,aAAa,QAAQ,QAAS;GACxC;GACD,OAAO,CAAC,UAAU;AAChB,WAAO,EAAE,OAAO,MAAM,aAAa,CAAE;GACtC;EACF;CACF,EAAC;AACH"}
|
package/dist/pino.d.cts
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
import { CreateLoggerOptions } from "./types-
|
|
1
|
+
import { CreateLoggerOptions } from "./types-JxCFymH0.cjs";
|
|
2
2
|
import * as pino0 from "pino";
|
|
3
3
|
|
|
4
4
|
//#region src/pino.d.ts
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default sensitive field paths for redaction.
|
|
8
|
+
*
|
|
9
|
+
* These paths are automatically used when `redact: true` is set,
|
|
10
|
+
* and merged with custom paths unless `resolution: 'override'` is specified.
|
|
11
|
+
*
|
|
12
|
+
* Includes:
|
|
13
|
+
* - Authentication: password, token, apiKey, authorization, credentials
|
|
14
|
+
* - Headers: authorization, cookie, x-api-key, x-auth-token
|
|
15
|
+
* - Personal data: ssn, creditCard, cvv, pin
|
|
16
|
+
* - Secrets: secret, connectionString, databaseUrl
|
|
17
|
+
* - Wildcards: *.password, *.secret, *.token (catches nested fields)
|
|
18
|
+
*/
|
|
19
|
+
declare const DEFAULT_REDACT_PATHS: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Creates a pino logger instance with optional redaction support.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Logger configuration options
|
|
24
|
+
* @returns A configured pino logger instance
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Basic logger
|
|
29
|
+
* const logger = createLogger({ level: 'debug' });
|
|
30
|
+
*
|
|
31
|
+
* // With redaction enabled
|
|
32
|
+
* const secureLogger = createLogger({ redact: true });
|
|
33
|
+
*
|
|
34
|
+
* // Pretty printing in development
|
|
35
|
+
* const devLogger = createLogger({ pretty: true, redact: true });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function createLogger(options?: CreateLoggerOptions): pino0.Logger<never, boolean>;
|
|
6
39
|
//#endregion
|
|
7
|
-
export { createLogger };
|
|
40
|
+
export { DEFAULT_REDACT_PATHS, createLogger };
|
|
8
41
|
//# sourceMappingURL=pino.d.cts.map
|
package/dist/pino.d.mts
CHANGED
|
@@ -1,8 +1,41 @@
|
|
|
1
|
-
import { CreateLoggerOptions } from "./types-
|
|
1
|
+
import { CreateLoggerOptions } from "./types-BFiJzL9N.mjs";
|
|
2
2
|
import * as pino0 from "pino";
|
|
3
3
|
|
|
4
4
|
//#region src/pino.d.ts
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Default sensitive field paths for redaction.
|
|
8
|
+
*
|
|
9
|
+
* These paths are automatically used when `redact: true` is set,
|
|
10
|
+
* and merged with custom paths unless `resolution: 'override'` is specified.
|
|
11
|
+
*
|
|
12
|
+
* Includes:
|
|
13
|
+
* - Authentication: password, token, apiKey, authorization, credentials
|
|
14
|
+
* - Headers: authorization, cookie, x-api-key, x-auth-token
|
|
15
|
+
* - Personal data: ssn, creditCard, cvv, pin
|
|
16
|
+
* - Secrets: secret, connectionString, databaseUrl
|
|
17
|
+
* - Wildcards: *.password, *.secret, *.token (catches nested fields)
|
|
18
|
+
*/
|
|
19
|
+
declare const DEFAULT_REDACT_PATHS: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Creates a pino logger instance with optional redaction support.
|
|
22
|
+
*
|
|
23
|
+
* @param options - Logger configuration options
|
|
24
|
+
* @returns A configured pino logger instance
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* // Basic logger
|
|
29
|
+
* const logger = createLogger({ level: 'debug' });
|
|
30
|
+
*
|
|
31
|
+
* // With redaction enabled
|
|
32
|
+
* const secureLogger = createLogger({ redact: true });
|
|
33
|
+
*
|
|
34
|
+
* // Pretty printing in development
|
|
35
|
+
* const devLogger = createLogger({ pretty: true, redact: true });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare function createLogger(options?: CreateLoggerOptions): pino0.Logger<never, boolean>;
|
|
6
39
|
//#endregion
|
|
7
|
-
export { createLogger };
|
|
40
|
+
export { DEFAULT_REDACT_PATHS, createLogger };
|
|
8
41
|
//# sourceMappingURL=pino.d.mts.map
|