@geekmidas/logger 10.0.0-alpha.98 → 10.0.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 (72) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/dist/console.cjs +25 -24
  3. package/dist/console.cjs.map +1 -1
  4. package/dist/console.d.cts +7 -4
  5. package/dist/console.d.cts.map +1 -1
  6. package/dist/console.d.mts +7 -4
  7. package/dist/console.d.mts.map +1 -1
  8. package/dist/console.mjs +25 -23
  9. package/dist/console.mjs.map +1 -1
  10. package/dist/index.cjs +3 -3
  11. package/dist/index.d.cts +2 -2
  12. package/dist/index.d.mts +2 -2
  13. package/dist/index.mjs +3 -2
  14. package/dist/pino.cjs +39 -67
  15. package/dist/pino.cjs.map +1 -1
  16. package/dist/pino.d.cts +12 -9
  17. package/dist/pino.d.cts.map +1 -1
  18. package/dist/pino.d.mts +12 -9
  19. package/dist/pino.d.mts.map +1 -1
  20. package/dist/pino.mjs +16 -66
  21. package/dist/pino.mjs.map +1 -1
  22. package/dist/redact-paths-CsK0_uz-.d.cts +19 -0
  23. package/dist/redact-paths-CsK0_uz-.d.cts.map +1 -0
  24. package/dist/redact-paths-D07eTMlH.d.mts +19 -0
  25. package/dist/redact-paths-D07eTMlH.d.mts.map +1 -0
  26. package/dist/redact-paths-D0m0DIuQ.cjs +73 -0
  27. package/dist/redact-paths-D0m0DIuQ.cjs.map +1 -0
  28. package/dist/redact-paths-DQoIXhkS.mjs +67 -0
  29. package/dist/redact-paths-DQoIXhkS.mjs.map +1 -0
  30. package/dist/redact-paths.cjs +2 -116
  31. package/dist/redact-paths.d.cts +2 -31
  32. package/dist/redact-paths.d.mts +2 -31
  33. package/dist/redact-paths.mjs +2 -113
  34. package/dist/types-BDdpcrpy.d.mts +166 -0
  35. package/dist/types-BDdpcrpy.d.mts.map +1 -0
  36. package/dist/types-Dk_k2-f_.d.cts +166 -0
  37. package/dist/types-Dk_k2-f_.d.cts.map +1 -0
  38. package/dist/types-ag_0Cvbg.cjs +38 -0
  39. package/dist/types-ag_0Cvbg.cjs.map +1 -0
  40. package/dist/types-yQ6XOihF.mjs +32 -0
  41. package/dist/types-yQ6XOihF.mjs.map +1 -0
  42. package/dist/types.cjs +2 -32
  43. package/dist/types.d.cts +2 -175
  44. package/dist/types.d.mts +2 -175
  45. package/dist/types.mjs +2 -31
  46. package/package.json +5 -35
  47. package/src/__tests__/console.spec.ts +661 -0
  48. package/src/__tests__/pino-redaction.integration.spec.ts +307 -0
  49. package/src/__tests__/pino.spec.ts +355 -0
  50. package/src/console.ts +165 -0
  51. package/src/index.ts +7 -0
  52. package/src/pino.ts +129 -0
  53. package/src/redact-paths.ts +71 -0
  54. package/src/types.ts +167 -0
  55. package/tsconfig.json +9 -0
  56. package/tsdown.config.ts +3 -0
  57. package/dist/otel.cjs +0 -113
  58. package/dist/otel.cjs.map +0 -1
  59. package/dist/otel.d.cts +0 -31
  60. package/dist/otel.d.cts.map +0 -1
  61. package/dist/otel.d.mts +0 -31
  62. package/dist/otel.d.mts.map +0 -1
  63. package/dist/otel.mjs +0 -110
  64. package/dist/otel.mjs.map +0 -1
  65. package/dist/redact-paths.cjs.map +0 -1
  66. package/dist/redact-paths.d.cts.map +0 -1
  67. package/dist/redact-paths.d.mts.map +0 -1
  68. package/dist/redact-paths.mjs.map +0 -1
  69. package/dist/types.cjs.map +0 -1
  70. package/dist/types.d.cts.map +0 -1
  71. package/dist/types.d.mts.map +0 -1
  72. package/dist/types.mjs.map +0 -1
package/dist/types.d.cts CHANGED
@@ -1,175 +1,2 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Logging function type that supports both structured and simple logging.
4
- * Can be called with an object for structured logging or just a message string.
5
- *
6
- * @example
7
- * ```typescript
8
- * // Structured logging with context object
9
- * logger.info({ userId: 123, action: 'login' }, 'User logged in');
10
- *
11
- * // Simple string logging
12
- * logger.info('Application started');
13
- * ```
14
- */
15
- export type LogFn = {
16
- /** Structured logging with context object, optional message, and additional arguments */
17
- <T extends object>(obj: T, msg?: string, ...args: any[]): void;
18
- /** Simple string logging */
19
- (msg: string): void;
20
- };
21
- /**
22
- * Standard logger interface with multiple log levels and child logger support.
23
- * Follows common logging patterns with structured logging capabilities.
24
- *
25
- * @interface Logger
26
- */
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;
48
- }
49
- /**
50
- * Console-based logger implementation that outputs to standard console methods.
51
- * Supports structured logging with automatic timestamp injection and context inheritance.
52
- *
53
- * @implements {Logger}
54
- *
55
- * @example
56
- * ```typescript
57
- * const logger = new ConsoleLogger({ app: 'myApp', version: '1.0.0' });
58
- * logger.info({ userId: 123 }, 'User action performed');
59
- * // Output: { app: 'myApp', version: '1.0.0', userId: 123, ts: 1234567890 } User action performed
60
- *
61
- * const childLogger = logger.child({ module: 'auth' });
62
- * childLogger.debug({ action: 'validate' }, 'Validating token');
63
- * // Output: { app: 'myApp', version: '1.0.0', module: 'auth', action: 'validate', ts: 1234567891 } Validating token
64
- * ```
65
- */
66
- export declare enum LogLevel {
67
- Trace = "trace",
68
- Debug = "debug",
69
- Info = "info",
70
- Warn = "warn",
71
- Error = "error",
72
- Fatal = "fatal",
73
- Silent = "silent"
74
- }
75
- /**
76
- * Redaction configuration for masking sensitive data in logs.
77
- * Uses pino's fast-redact library under the hood.
78
- *
79
- * By default, custom paths are merged with the default sensitive paths.
80
- * Use `resolution: 'override'` to use only your custom paths.
81
- *
82
- * @example
83
- * ```typescript
84
- * // Simple path array (merges with defaults)
85
- * redact: ['user.ssn', 'custom.field']
86
- *
87
- * // Override defaults completely
88
- * redact: {
89
- * paths: ['only.these.paths'],
90
- * resolution: 'override',
91
- * }
92
- *
93
- * // With custom censor
94
- * redact: {
95
- * paths: ['extra.secret'],
96
- * censor: '***',
97
- * }
98
- *
99
- * // Remove fields entirely
100
- * redact: {
101
- * paths: ['temporary.data'],
102
- * remove: true,
103
- * }
104
- * ```
105
- */
106
- export type RedactOptions = string[] | {
107
- /** Paths to redact using dot notation or bracket notation for special chars */
108
- paths: string[];
109
- /** Custom replacement text (default: '[REDACTED]') */
110
- censor?: string | ((value: unknown, path: string[]) => unknown);
111
- /** Remove the field entirely instead of replacing (default: false) */
112
- remove?: boolean;
113
- /**
114
- * How to combine custom paths with default sensitive paths.
115
- * - 'merge': Custom paths are added to default paths (default)
116
- * - 'override': Only custom paths are used, defaults are ignored
117
- */
118
- resolution?: 'merge' | 'override';
119
- };
120
- export type CreateLoggerOptions = {
121
- /** Enable pretty printing with colors (disabled in production) */
122
- pretty?: boolean;
123
- /** Minimum log level to output */
124
- level?: LogLevel;
125
- /**
126
- * Redaction configuration for masking sensitive data.
127
- *
128
- * - `true` or `undefined` (the default): Uses default sensitive paths
129
- * (password, token, secret, etc.)
130
- * - `false`: No redaction applied — the explicit opt-out
131
- * - `string[]`: Custom paths merged with defaults
132
- * - `object`: Advanced config with paths, censor, remove, and resolution options
133
- *
134
- * By default, custom paths are **merged** with the default sensitive paths.
135
- * Use `resolution: 'override'` to disable defaults and use only your paths.
136
- *
137
- * @example
138
- * ```typescript
139
- * // Use defaults only (the same as leaving `redact` out)
140
- * createLogger({ redact: true });
141
- *
142
- * // Opt out
143
- * createLogger({ redact: false });
144
- *
145
- * // Add custom paths (merged with defaults)
146
- * createLogger({ redact: ['user.ssn', 'custom.field'] });
147
- *
148
- * // Override defaults completely
149
- * createLogger({
150
- * redact: {
151
- * paths: ['only.these.paths'],
152
- * resolution: 'override',
153
- * }
154
- * });
155
- *
156
- * // Merge with custom censor
157
- * createLogger({
158
- * redact: {
159
- * paths: ['extra.secret'],
160
- * censor: '***',
161
- * }
162
- * });
163
- * ```
164
- */
165
- redact?: boolean | RedactOptions;
166
- /**
167
- * Where log lines are written (pino logger only). Defaults to stdout.
168
- * Ignored when `pretty` is on, since the pretty transport owns its output.
169
- */
170
- destination?: {
171
- write(line: string): unknown;
172
- };
173
- };
174
- //#endregion
175
- //# sourceMappingURL=types.d.cts.map
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-Dk_k2-f_.cjs";
2
+ export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
package/dist/types.d.mts CHANGED
@@ -1,175 +1,2 @@
1
- //#region src/types.d.ts
2
- /**
3
- * Logging function type that supports both structured and simple logging.
4
- * Can be called with an object for structured logging or just a message string.
5
- *
6
- * @example
7
- * ```typescript
8
- * // Structured logging with context object
9
- * logger.info({ userId: 123, action: 'login' }, 'User logged in');
10
- *
11
- * // Simple string logging
12
- * logger.info('Application started');
13
- * ```
14
- */
15
- export type LogFn = {
16
- /** Structured logging with context object, optional message, and additional arguments */
17
- <T extends object>(obj: T, msg?: string, ...args: any[]): void;
18
- /** Simple string logging */
19
- (msg: string): void;
20
- };
21
- /**
22
- * Standard logger interface with multiple log levels and child logger support.
23
- * Follows common logging patterns with structured logging capabilities.
24
- *
25
- * @interface Logger
26
- */
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;
48
- }
49
- /**
50
- * Console-based logger implementation that outputs to standard console methods.
51
- * Supports structured logging with automatic timestamp injection and context inheritance.
52
- *
53
- * @implements {Logger}
54
- *
55
- * @example
56
- * ```typescript
57
- * const logger = new ConsoleLogger({ app: 'myApp', version: '1.0.0' });
58
- * logger.info({ userId: 123 }, 'User action performed');
59
- * // Output: { app: 'myApp', version: '1.0.0', userId: 123, ts: 1234567890 } User action performed
60
- *
61
- * const childLogger = logger.child({ module: 'auth' });
62
- * childLogger.debug({ action: 'validate' }, 'Validating token');
63
- * // Output: { app: 'myApp', version: '1.0.0', module: 'auth', action: 'validate', ts: 1234567891 } Validating token
64
- * ```
65
- */
66
- export declare enum LogLevel {
67
- Trace = "trace",
68
- Debug = "debug",
69
- Info = "info",
70
- Warn = "warn",
71
- Error = "error",
72
- Fatal = "fatal",
73
- Silent = "silent"
74
- }
75
- /**
76
- * Redaction configuration for masking sensitive data in logs.
77
- * Uses pino's fast-redact library under the hood.
78
- *
79
- * By default, custom paths are merged with the default sensitive paths.
80
- * Use `resolution: 'override'` to use only your custom paths.
81
- *
82
- * @example
83
- * ```typescript
84
- * // Simple path array (merges with defaults)
85
- * redact: ['user.ssn', 'custom.field']
86
- *
87
- * // Override defaults completely
88
- * redact: {
89
- * paths: ['only.these.paths'],
90
- * resolution: 'override',
91
- * }
92
- *
93
- * // With custom censor
94
- * redact: {
95
- * paths: ['extra.secret'],
96
- * censor: '***',
97
- * }
98
- *
99
- * // Remove fields entirely
100
- * redact: {
101
- * paths: ['temporary.data'],
102
- * remove: true,
103
- * }
104
- * ```
105
- */
106
- export type RedactOptions = string[] | {
107
- /** Paths to redact using dot notation or bracket notation for special chars */
108
- paths: string[];
109
- /** Custom replacement text (default: '[REDACTED]') */
110
- censor?: string | ((value: unknown, path: string[]) => unknown);
111
- /** Remove the field entirely instead of replacing (default: false) */
112
- remove?: boolean;
113
- /**
114
- * How to combine custom paths with default sensitive paths.
115
- * - 'merge': Custom paths are added to default paths (default)
116
- * - 'override': Only custom paths are used, defaults are ignored
117
- */
118
- resolution?: 'merge' | 'override';
119
- };
120
- export type CreateLoggerOptions = {
121
- /** Enable pretty printing with colors (disabled in production) */
122
- pretty?: boolean;
123
- /** Minimum log level to output */
124
- level?: LogLevel;
125
- /**
126
- * Redaction configuration for masking sensitive data.
127
- *
128
- * - `true` or `undefined` (the default): Uses default sensitive paths
129
- * (password, token, secret, etc.)
130
- * - `false`: No redaction applied — the explicit opt-out
131
- * - `string[]`: Custom paths merged with defaults
132
- * - `object`: Advanced config with paths, censor, remove, and resolution options
133
- *
134
- * By default, custom paths are **merged** with the default sensitive paths.
135
- * Use `resolution: 'override'` to disable defaults and use only your paths.
136
- *
137
- * @example
138
- * ```typescript
139
- * // Use defaults only (the same as leaving `redact` out)
140
- * createLogger({ redact: true });
141
- *
142
- * // Opt out
143
- * createLogger({ redact: false });
144
- *
145
- * // Add custom paths (merged with defaults)
146
- * createLogger({ redact: ['user.ssn', 'custom.field'] });
147
- *
148
- * // Override defaults completely
149
- * createLogger({
150
- * redact: {
151
- * paths: ['only.these.paths'],
152
- * resolution: 'override',
153
- * }
154
- * });
155
- *
156
- * // Merge with custom censor
157
- * createLogger({
158
- * redact: {
159
- * paths: ['extra.secret'],
160
- * censor: '***',
161
- * }
162
- * });
163
- * ```
164
- */
165
- redact?: boolean | RedactOptions;
166
- /**
167
- * Where log lines are written (pino logger only). Defaults to stdout.
168
- * Ignored when `pretty` is on, since the pretty transport owns its output.
169
- */
170
- destination?: {
171
- write(line: string): unknown;
172
- };
173
- };
174
- //#endregion
175
- //# sourceMappingURL=types.d.mts.map
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-BDdpcrpy.mjs";
2
+ export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
package/dist/types.mjs CHANGED
@@ -1,32 +1,3 @@
1
- //#region src/types.ts
2
- /**
3
- * Console-based logger implementation that outputs to standard console methods.
4
- * Supports structured logging with automatic timestamp injection and context inheritance.
5
- *
6
- * @implements {Logger}
7
- *
8
- * @example
9
- * ```typescript
10
- * const logger = new ConsoleLogger({ app: 'myApp', version: '1.0.0' });
11
- * logger.info({ userId: 123 }, 'User action performed');
12
- * // Output: { app: 'myApp', version: '1.0.0', userId: 123, ts: 1234567890 } User action performed
13
- *
14
- * const childLogger = logger.child({ module: 'auth' });
15
- * childLogger.debug({ action: 'validate' }, 'Validating token');
16
- * // Output: { app: 'myApp', version: '1.0.0', module: 'auth', action: 'validate', ts: 1234567891 } Validating token
17
- * ```
18
- */
19
- let LogLevel = /* @__PURE__ */ function(LogLevel) {
20
- LogLevel["Trace"] = "trace";
21
- LogLevel["Debug"] = "debug";
22
- LogLevel["Info"] = "info";
23
- LogLevel["Warn"] = "warn";
24
- LogLevel["Error"] = "error";
25
- LogLevel["Fatal"] = "fatal";
26
- LogLevel["Silent"] = "silent";
27
- return LogLevel;
28
- }({});
29
- //#endregion
30
- export { LogLevel };
1
+ import { LogLevel } from "./types-yQ6XOihF.mjs";
31
2
 
32
- //# sourceMappingURL=types.mjs.map
3
+ export { LogLevel };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geekmidas/logger",
3
- "version": "10.0.0-alpha.98",
3
+ "version": "10.0.0",
4
4
  "description": "A simple and flexible logging library for Node.js and the browser",
5
5
  "private": false,
6
6
  "type": "module",
@@ -35,16 +35,6 @@
35
35
  "default": "./dist/console.cjs"
36
36
  }
37
37
  },
38
- "./otel": {
39
- "import": {
40
- "types": "./dist/otel.d.mts",
41
- "default": "./dist/otel.mjs"
42
- },
43
- "require": {
44
- "types": "./dist/otel.d.cts",
45
- "default": "./dist/otel.cjs"
46
- }
47
- },
48
38
  "./redact": {
49
39
  "import": {
50
40
  "types": "./dist/redact-paths.d.mts",
@@ -56,9 +46,6 @@
56
46
  }
57
47
  }
58
48
  },
59
- "files": [
60
- "dist"
61
- ],
62
49
  "repository": {
63
50
  "type": "git",
64
51
  "url": "https://github.com/geekmidas/toolbox"
@@ -67,27 +54,10 @@
67
54
  "registry": "https://registry.npmjs.org/",
68
55
  "access": "public"
69
56
  },
70
- "dependencies": {
71
- "@opentelemetry/api-logs": "~0.222.0"
72
- },
73
- "devDependencies": {
74
- "@opentelemetry/api": "~1.9.1",
75
- "@opentelemetry/sdk-logs": "~0.222.0",
76
- "@opentelemetry/sdk-trace-node": "~2.11.0"
77
- },
57
+ "dependencies": {},
58
+ "devDependencies": {},
78
59
  "peerDependencies": {
79
- "pino-pretty": ">=13.1.3",
80
- "pino": ">=10.3.1"
81
- },
82
- "peerDependenciesMeta": {
83
- "pino": {
84
- "optional": true
85
- },
86
- "pino-pretty": {
87
- "optional": true
88
- }
89
- },
90
- "scripts": {
91
- "build": "tsdown --config ../../tsdown.config.ts --filter ."
60
+ "pino-pretty": "~13.1.2",
61
+ "pino": "~10.0.0"
92
62
  }
93
63
  }