@geekmidas/logger 10.0.0-alpha.6 → 10.0.0-alpha.61
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 +24 -25
- package/dist/console.cjs.map +1 -1
- package/dist/console.d.cts +4 -7
- package/dist/console.d.cts.map +1 -1
- package/dist/console.d.mts +4 -7
- package/dist/console.d.mts.map +1 -1
- package/dist/console.mjs +23 -25
- package/dist/console.mjs.map +1 -1
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +2 -3
- package/dist/pino.cjs +49 -39
- package/dist/pino.cjs.map +1 -1
- package/dist/pino.d.cts +8 -12
- package/dist/pino.d.cts.map +1 -1
- package/dist/pino.d.mts +8 -12
- package/dist/pino.d.mts.map +1 -1
- package/dist/pino.mjs +47 -15
- package/dist/pino.mjs.map +1 -1
- package/dist/redact-paths.cjs +67 -2
- package/dist/redact-paths.cjs.map +1 -0
- package/dist/redact-paths.d.cts +17 -2
- package/dist/redact-paths.d.cts.map +1 -0
- package/dist/redact-paths.d.mts +17 -2
- package/dist/redact-paths.d.mts.map +1 -0
- package/dist/redact-paths.mjs +66 -2
- package/dist/redact-paths.mjs.map +1 -0
- package/dist/types.cjs +32 -2
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +175 -2
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +175 -2
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +31 -2
- package/dist/types.mjs.map +1 -0
- package/package.json +1 -1
- package/dist/redact-paths-CsK0_uz-.d.cts +0 -19
- package/dist/redact-paths-CsK0_uz-.d.cts.map +0 -1
- package/dist/redact-paths-D07eTMlH.d.mts +0 -19
- package/dist/redact-paths-D07eTMlH.d.mts.map +0 -1
- package/dist/redact-paths-D0m0DIuQ.cjs +0 -73
- package/dist/redact-paths-D0m0DIuQ.cjs.map +0 -1
- package/dist/redact-paths-DQoIXhkS.mjs +0 -67
- package/dist/redact-paths-DQoIXhkS.mjs.map +0 -1
- package/dist/types-BDdpcrpy.d.mts +0 -166
- package/dist/types-BDdpcrpy.d.mts.map +0 -1
- package/dist/types-Dk_k2-f_.d.cts +0 -166
- package/dist/types-Dk_k2-f_.d.cts.map +0 -1
- package/dist/types-ag_0Cvbg.cjs +0 -38
- package/dist/types-ag_0Cvbg.cjs.map +0 -1
- package/dist/types-yQ6XOihF.mjs +0 -32
- package/dist/types-yQ6XOihF.mjs.map +0 -1
package/dist/console.cjs
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("./types.cjs");
|
|
3
3
|
//#region src/console.ts
|
|
4
4
|
/**
|
|
5
5
|
* Numeric priority for log levels (higher = more severe)
|
|
6
6
|
*/
|
|
7
7
|
const LOG_LEVEL_PRIORITY = {
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
8
|
+
["trace"]: 10,
|
|
9
|
+
["debug"]: 20,
|
|
10
|
+
["info"]: 30,
|
|
11
|
+
["warn"]: 40,
|
|
12
|
+
["error"]: 50,
|
|
13
|
+
["fatal"]: 60,
|
|
14
|
+
["silent"]: 70
|
|
15
15
|
};
|
|
16
16
|
var ConsoleLogger = class ConsoleLogger {
|
|
17
|
+
data;
|
|
17
18
|
level;
|
|
18
19
|
/**
|
|
19
20
|
* Creates a new ConsoleLogger instance.
|
|
@@ -21,7 +22,7 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
21
22
|
* @param data - Initial context data to include in all log messages
|
|
22
23
|
* @param level - Minimum log level to output (default: Info)
|
|
23
24
|
*/
|
|
24
|
-
constructor(data = {}, level =
|
|
25
|
+
constructor(data = {}, level = "info") {
|
|
25
26
|
this.data = data;
|
|
26
27
|
this.level = level;
|
|
27
28
|
}
|
|
@@ -29,7 +30,7 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
29
30
|
* Checks if a log level should be output based on the configured minimum level.
|
|
30
31
|
*/
|
|
31
32
|
shouldLog(level) {
|
|
32
|
-
if (this.level ===
|
|
33
|
+
if (this.level === "silent") return false;
|
|
33
34
|
return LOG_LEVEL_PRIORITY[level] >= LOG_LEVEL_PRIORITY[this.level];
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
@@ -45,15 +46,14 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
45
46
|
if (!this.shouldLog(level)) return;
|
|
46
47
|
const ts = Date.now();
|
|
47
48
|
if (typeof objOrMsg === "string") {
|
|
48
|
-
|
|
49
|
+
logMethod({
|
|
49
50
|
...this.data,
|
|
50
51
|
msg: objOrMsg,
|
|
51
52
|
ts
|
|
52
|
-
};
|
|
53
|
-
logMethod(logData$1, ...args);
|
|
53
|
+
}, ...args);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
logMethod(msg ? {
|
|
57
57
|
...this.data,
|
|
58
58
|
...objOrMsg,
|
|
59
59
|
msg,
|
|
@@ -62,22 +62,21 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
62
62
|
...this.data,
|
|
63
63
|
...objOrMsg,
|
|
64
64
|
ts
|
|
65
|
-
};
|
|
66
|
-
logMethod(logData, ...args);
|
|
65
|
+
}, ...args);
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
/** Trace level logging function */
|
|
70
|
-
trace = this.createLogFn(console.trace.bind(console),
|
|
69
|
+
trace = this.createLogFn(console.trace.bind(console), "trace");
|
|
71
70
|
/** Debug level logging function */
|
|
72
|
-
debug = this.createLogFn(console.debug.bind(console),
|
|
71
|
+
debug = this.createLogFn(console.debug.bind(console), "debug");
|
|
73
72
|
/** Info level logging function */
|
|
74
|
-
info = this.createLogFn(console.info.bind(console),
|
|
73
|
+
info = this.createLogFn(console.info.bind(console), "info");
|
|
75
74
|
/** Warning level logging function */
|
|
76
|
-
warn = this.createLogFn(console.warn.bind(console),
|
|
75
|
+
warn = this.createLogFn(console.warn.bind(console), "warn");
|
|
77
76
|
/** Error level logging function */
|
|
78
|
-
error = this.createLogFn(console.error.bind(console),
|
|
77
|
+
error = this.createLogFn(console.error.bind(console), "error");
|
|
79
78
|
/** Fatal level logging function (uses console.error) */
|
|
80
|
-
fatal = this.createLogFn(console.error.bind(console),
|
|
79
|
+
fatal = this.createLogFn(console.error.bind(console), "fatal");
|
|
81
80
|
/**
|
|
82
81
|
* Creates a child logger with additional context data.
|
|
83
82
|
* The child logger inherits all context from the parent and adds its own.
|
|
@@ -142,11 +141,11 @@ const DEFAULT_LOGGER = new ConsoleLogger();
|
|
|
142
141
|
* ```
|
|
143
142
|
*/
|
|
144
143
|
function createLogger(options = {}) {
|
|
145
|
-
return new ConsoleLogger({}, options.level ??
|
|
144
|
+
return new ConsoleLogger({}, options.level ?? "info");
|
|
146
145
|
}
|
|
147
|
-
|
|
148
146
|
//#endregion
|
|
149
147
|
exports.ConsoleLogger = ConsoleLogger;
|
|
150
148
|
exports.DEFAULT_LOGGER = DEFAULT_LOGGER;
|
|
151
149
|
exports.createLogger = createLogger;
|
|
150
|
+
|
|
152
151
|
//# sourceMappingURL=console.cjs.map
|
package/dist/console.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.cjs","names":[
|
|
1
|
+
{"version":3,"file":"console.cjs","names":[],"sources":["../src/console.ts"],"sourcesContent":["import type { CreateLoggerOptions, LogFn, Logger } from './types';\nimport { LogLevel } from './types';\n\n/**\n * Numeric priority for log levels (higher = more severe)\n */\nconst LOG_LEVEL_PRIORITY: Record<LogLevel, number> = {\n\t[LogLevel.Trace]: 10,\n\t[LogLevel.Debug]: 20,\n\t[LogLevel.Info]: 30,\n\t[LogLevel.Warn]: 40,\n\t[LogLevel.Error]: 50,\n\t[LogLevel.Fatal]: 60,\n\t[LogLevel.Silent]: 70,\n};\n\nexport class ConsoleLogger implements Logger {\n\tprivate readonly level: LogLevel;\n\n\t/**\n\t * Creates a new ConsoleLogger instance.\n\t *\n\t * @param data - Initial context data to include in all log messages\n\t * @param level - Minimum log level to output (default: Info)\n\t */\n\tconstructor(\n\t\treadonly data: object = {},\n\t\tlevel: LogLevel = LogLevel.Info,\n\t) {\n\t\tthis.level = level;\n\t}\n\n\t/**\n\t * Checks if a log level should be output based on the configured minimum level.\n\t */\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\tif (this.level === LogLevel.Silent) {\n\t\t\treturn false;\n\t\t}\n\t\treturn LOG_LEVEL_PRIORITY[level] >= LOG_LEVEL_PRIORITY[this.level];\n\t}\n\n\t/**\n\t * Creates a logging function that merges context data and adds timestamps.\n\t *\n\t * @param logMethod - The console method to use (e.g., console.log, console.error)\n\t * @param level - The log level for this method\n\t * @returns A LogFn that handles both structured and simple logging\n\t * @private\n\t */\n\tprivate createLogFn(\n\t\tlogMethod: (...args: any[]) => void,\n\t\tlevel: LogLevel,\n\t): LogFn {\n\t\treturn <T extends object>(\n\t\t\tobjOrMsg: T | string,\n\t\t\tmsg?: string,\n\t\t\t...args: any[]\n\t\t): void => {\n\t\t\tif (!this.shouldLog(level)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst ts = Date.now();\n\n\t\t\t// Handle simple string logging: logger.info('message')\n\t\t\tif (typeof objOrMsg === 'string') {\n\t\t\t\tconst logData = { ...this.data, msg: objOrMsg, ts };\n\t\t\t\tlogMethod(logData, ...args);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Handle structured logging: logger.info({ data }, 'message')\n\t\t\tconst logData = msg\n\t\t\t\t? { ...this.data, ...objOrMsg, msg, ts }\n\t\t\t\t: { ...this.data, ...objOrMsg, ts };\n\t\t\tlogMethod(logData, ...args);\n\t\t};\n\t}\n\n\t/** Trace level logging function */\n\ttrace: LogFn = this.createLogFn(console.trace.bind(console), LogLevel.Trace);\n\t/** Debug level logging function */\n\tdebug: LogFn = this.createLogFn(console.debug.bind(console), LogLevel.Debug);\n\t/** Info level logging function */\n\tinfo: LogFn = this.createLogFn(console.info.bind(console), LogLevel.Info);\n\t/** Warning level logging function */\n\twarn: LogFn = this.createLogFn(console.warn.bind(console), LogLevel.Warn);\n\t/** Error level logging function */\n\terror: LogFn = this.createLogFn(console.error.bind(console), LogLevel.Error);\n\t/** Fatal level logging function (uses console.error) */\n\tfatal: LogFn = this.createLogFn(console.error.bind(console), LogLevel.Fatal);\n\n\t/**\n\t * Creates a child logger with additional context data.\n\t * The child logger inherits all context from the parent and adds its own.\n\t *\n\t * @param obj - Additional context data for the child logger\n\t * @returns A new ConsoleLogger instance with merged context\n\t *\n\t * @example\n\t * ```typescript\n\t * const parentLogger = new ConsoleLogger({ app: 'myApp' });\n\t * const childLogger = parentLogger.child({ module: 'database' });\n\t * childLogger.info({ query: 'SELECT * FROM users' }, 'Query executed');\n\t * // Context includes both { app: 'myApp' } and { module: 'database' }\n\t * ```\n\t */\n\tchild(obj: object): Logger {\n\t\treturn new ConsoleLogger(\n\t\t\t{\n\t\t\t\t...this.data,\n\t\t\t\t...obj,\n\t\t\t},\n\t\t\tthis.level,\n\t\t);\n\t}\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', msg: 'Application starting', ts: 1234567890 }\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, msg: 'User authenticated', ts: 1234567891 }\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 * import { LogLevel } from '@geekmidas/logger';\n *\n * const logger = createLogger({ level: LogLevel.Debug });\n * logger.debug('This will be logged');\n * logger.trace('This will NOT be logged (below Debug level)');\n * ```\n */\nexport function createLogger(options: CreateLoggerOptions = {}): Logger {\n\treturn new ConsoleLogger({}, options.level ?? LogLevel.Info);\n}\n"],"mappings":";;;;;;AAMA,MAAM,qBAA+C;EAClC,UAAA;EACA,UAAA;EACD,SAAA;EACA,SAAA;EACC,UAAA;EACA,UAAA;EACC,WAAA;AACpB;AAEA,IAAa,gBAAb,MAAa,cAAgC;CAUlC;CATV;;;;;;;CAQA,YACC,OAAwB,CAAC,GACzB,QAAA,QACC;EAFQ,KAAA,OAAA;EAGT,KAAK,QAAQ;CACd;;;;CAKA,UAAkB,OAA0B;EAC3C,IAAI,KAAK,UAAA,UACR,OAAO;EAER,OAAO,mBAAmB,UAAU,mBAAmB,KAAK;CAC7D;;;;;;;;;CAUA,YACC,WACA,OACQ;EACR,QACC,UACA,KACA,GAAG,SACO;GACV,IAAI,CAAC,KAAK,UAAU,KAAK,GACxB;GAGD,MAAM,KAAK,KAAK,IAAI;GAGpB,IAAI,OAAO,aAAa,UAAU;IAEjC,UAAU;KADQ,GAAG,KAAK;KAAM,KAAK;KAAU;IAC/B,GAAG,GAAG,IAAI;IAC1B;GACD;GAMA,UAHgB,MACb;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;IAAK;GAAG,IACrC;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;GAAG,GAChB,GAAG,IAAI;EAC3B;CACD;;CAGA,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;CAE3E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;CAE3E,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,OAAO,GAAA,MAAgB;;CAExE,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,OAAO,GAAA,MAAgB;;CAExE,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;CAE3E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;;;;;;;;;;;;;;;CAiB3E,MAAM,KAAqB;EAC1B,OAAO,IAAI,cACV;GACC,GAAG,KAAK;GACR,GAAG;EACJ,GACA,KAAK,KACN;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,iBAAiB,IAAI,cAAc;;;;;;;;;;;;;;;;;AAkBhD,SAAgB,aAAa,UAA+B,CAAC,GAAW;CACvE,OAAO,IAAI,cAAc,CAAC,GAAG,QAAQ,SAAA,MAAsB;AAC5D"}
|
package/dist/console.d.cts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types
|
|
2
|
-
|
|
1
|
+
import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types.cjs";
|
|
3
2
|
//#region src/console.d.ts
|
|
4
|
-
declare class ConsoleLogger implements Logger {
|
|
3
|
+
export declare class ConsoleLogger implements Logger {
|
|
5
4
|
readonly data: object;
|
|
6
5
|
private readonly level;
|
|
7
6
|
/**
|
|
@@ -77,7 +76,7 @@ declare class ConsoleLogger implements Logger {
|
|
|
77
76
|
* }
|
|
78
77
|
* ```
|
|
79
78
|
*/
|
|
80
|
-
declare const DEFAULT_LOGGER: any;
|
|
79
|
+
export declare const DEFAULT_LOGGER: any;
|
|
81
80
|
/**
|
|
82
81
|
* Creates a console logger with the same API as pino's createLogger.
|
|
83
82
|
*
|
|
@@ -94,8 +93,6 @@ declare const DEFAULT_LOGGER: any;
|
|
|
94
93
|
* logger.trace('This will NOT be logged (below Debug level)');
|
|
95
94
|
* ```
|
|
96
95
|
*/
|
|
97
|
-
declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
98
|
-
//# sourceMappingURL=console.d.ts.map
|
|
96
|
+
export declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
99
97
|
//#endregion
|
|
100
|
-
export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
|
|
101
98
|
//# sourceMappingURL=console.d.cts.map
|
package/dist/console.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.cts","names":[],"sources":["../src/console.ts"],"
|
|
1
|
+
{"version":3,"file":"console.d.cts","names":[],"sources":["../src/console.ts"],"mappings":";;qBAgBa,yBAAyB;WAU3B;mBATO;;;;;;;EAQjB,YACU,eACT,QAAO;;;;UAQA;;;;;;;;;UAeA;;EA+BR,OAAO;;EAEP,OAAO;;EAEP,MAAM;;EAEN,MAAM;;EAEN,OAAO;;EAEP,OAAO;;;;;;;;;;;;;;;;EAiBP,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCR;;;;;;;;;;;;;;;;;wBAkBG,aAAa,UAAS,sBAA2B"}
|
package/dist/console.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types
|
|
2
|
-
|
|
1
|
+
import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types.mjs";
|
|
3
2
|
//#region src/console.d.ts
|
|
4
|
-
declare class ConsoleLogger implements Logger {
|
|
3
|
+
export declare class ConsoleLogger implements Logger {
|
|
5
4
|
readonly data: object;
|
|
6
5
|
private readonly level;
|
|
7
6
|
/**
|
|
@@ -77,7 +76,7 @@ declare class ConsoleLogger implements Logger {
|
|
|
77
76
|
* }
|
|
78
77
|
* ```
|
|
79
78
|
*/
|
|
80
|
-
declare const DEFAULT_LOGGER: any;
|
|
79
|
+
export declare const DEFAULT_LOGGER: any;
|
|
81
80
|
/**
|
|
82
81
|
* Creates a console logger with the same API as pino's createLogger.
|
|
83
82
|
*
|
|
@@ -94,8 +93,6 @@ declare const DEFAULT_LOGGER: any;
|
|
|
94
93
|
* logger.trace('This will NOT be logged (below Debug level)');
|
|
95
94
|
* ```
|
|
96
95
|
*/
|
|
97
|
-
declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
98
|
-
//# sourceMappingURL=console.d.ts.map
|
|
96
|
+
export declare function createLogger(options?: CreateLoggerOptions): Logger;
|
|
99
97
|
//#endregion
|
|
100
|
-
export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
|
|
101
98
|
//# sourceMappingURL=console.d.mts.map
|
package/dist/console.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.d.mts","names":[],"sources":["../src/console.ts"],"
|
|
1
|
+
{"version":3,"file":"console.d.mts","names":[],"sources":["../src/console.ts"],"mappings":";;qBAgBa,yBAAyB;WAU3B;mBATO;;;;;;;EAQjB,YACU,eACT,QAAO;;;;UAQA;;;;;;;;;UAeA;;EA+BR,OAAO;;EAEP,OAAO;;EAEP,MAAM;;EAEN,MAAM;;EAEN,OAAO;;EAEP,OAAO;;;;;;;;;;;;;;;;EAiBP,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCR;;;;;;;;;;;;;;;;;wBAkBG,aAAa,UAAS,sBAA2B"}
|
package/dist/console.mjs
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import "./types.mjs";
|
|
3
2
|
//#region src/console.ts
|
|
4
3
|
/**
|
|
5
4
|
* Numeric priority for log levels (higher = more severe)
|
|
6
5
|
*/
|
|
7
6
|
const LOG_LEVEL_PRIORITY = {
|
|
8
|
-
[
|
|
9
|
-
[
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
7
|
+
["trace"]: 10,
|
|
8
|
+
["debug"]: 20,
|
|
9
|
+
["info"]: 30,
|
|
10
|
+
["warn"]: 40,
|
|
11
|
+
["error"]: 50,
|
|
12
|
+
["fatal"]: 60,
|
|
13
|
+
["silent"]: 70
|
|
15
14
|
};
|
|
16
15
|
var ConsoleLogger = class ConsoleLogger {
|
|
16
|
+
data;
|
|
17
17
|
level;
|
|
18
18
|
/**
|
|
19
19
|
* Creates a new ConsoleLogger instance.
|
|
@@ -21,7 +21,7 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
21
21
|
* @param data - Initial context data to include in all log messages
|
|
22
22
|
* @param level - Minimum log level to output (default: Info)
|
|
23
23
|
*/
|
|
24
|
-
constructor(data = {}, level =
|
|
24
|
+
constructor(data = {}, level = "info") {
|
|
25
25
|
this.data = data;
|
|
26
26
|
this.level = level;
|
|
27
27
|
}
|
|
@@ -29,7 +29,7 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
29
29
|
* Checks if a log level should be output based on the configured minimum level.
|
|
30
30
|
*/
|
|
31
31
|
shouldLog(level) {
|
|
32
|
-
if (this.level ===
|
|
32
|
+
if (this.level === "silent") return false;
|
|
33
33
|
return LOG_LEVEL_PRIORITY[level] >= LOG_LEVEL_PRIORITY[this.level];
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
@@ -45,15 +45,14 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
45
45
|
if (!this.shouldLog(level)) return;
|
|
46
46
|
const ts = Date.now();
|
|
47
47
|
if (typeof objOrMsg === "string") {
|
|
48
|
-
|
|
48
|
+
logMethod({
|
|
49
49
|
...this.data,
|
|
50
50
|
msg: objOrMsg,
|
|
51
51
|
ts
|
|
52
|
-
};
|
|
53
|
-
logMethod(logData$1, ...args);
|
|
52
|
+
}, ...args);
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
|
-
|
|
55
|
+
logMethod(msg ? {
|
|
57
56
|
...this.data,
|
|
58
57
|
...objOrMsg,
|
|
59
58
|
msg,
|
|
@@ -62,22 +61,21 @@ var ConsoleLogger = class ConsoleLogger {
|
|
|
62
61
|
...this.data,
|
|
63
62
|
...objOrMsg,
|
|
64
63
|
ts
|
|
65
|
-
};
|
|
66
|
-
logMethod(logData, ...args);
|
|
64
|
+
}, ...args);
|
|
67
65
|
};
|
|
68
66
|
}
|
|
69
67
|
/** Trace level logging function */
|
|
70
|
-
trace = this.createLogFn(console.trace.bind(console),
|
|
68
|
+
trace = this.createLogFn(console.trace.bind(console), "trace");
|
|
71
69
|
/** Debug level logging function */
|
|
72
|
-
debug = this.createLogFn(console.debug.bind(console),
|
|
70
|
+
debug = this.createLogFn(console.debug.bind(console), "debug");
|
|
73
71
|
/** Info level logging function */
|
|
74
|
-
info = this.createLogFn(console.info.bind(console),
|
|
72
|
+
info = this.createLogFn(console.info.bind(console), "info");
|
|
75
73
|
/** Warning level logging function */
|
|
76
|
-
warn = this.createLogFn(console.warn.bind(console),
|
|
74
|
+
warn = this.createLogFn(console.warn.bind(console), "warn");
|
|
77
75
|
/** Error level logging function */
|
|
78
|
-
error = this.createLogFn(console.error.bind(console),
|
|
76
|
+
error = this.createLogFn(console.error.bind(console), "error");
|
|
79
77
|
/** Fatal level logging function (uses console.error) */
|
|
80
|
-
fatal = this.createLogFn(console.error.bind(console),
|
|
78
|
+
fatal = this.createLogFn(console.error.bind(console), "fatal");
|
|
81
79
|
/**
|
|
82
80
|
* Creates a child logger with additional context data.
|
|
83
81
|
* The child logger inherits all context from the parent and adds its own.
|
|
@@ -142,9 +140,9 @@ const DEFAULT_LOGGER = new ConsoleLogger();
|
|
|
142
140
|
* ```
|
|
143
141
|
*/
|
|
144
142
|
function createLogger(options = {}) {
|
|
145
|
-
return new ConsoleLogger({}, options.level ??
|
|
143
|
+
return new ConsoleLogger({}, options.level ?? "info");
|
|
146
144
|
}
|
|
147
|
-
|
|
148
145
|
//#endregion
|
|
149
146
|
export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
|
|
147
|
+
|
|
150
148
|
//# sourceMappingURL=console.mjs.map
|
package/dist/console.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.mjs","names":[
|
|
1
|
+
{"version":3,"file":"console.mjs","names":[],"sources":["../src/console.ts"],"sourcesContent":["import type { CreateLoggerOptions, LogFn, Logger } from './types';\nimport { LogLevel } from './types';\n\n/**\n * Numeric priority for log levels (higher = more severe)\n */\nconst LOG_LEVEL_PRIORITY: Record<LogLevel, number> = {\n\t[LogLevel.Trace]: 10,\n\t[LogLevel.Debug]: 20,\n\t[LogLevel.Info]: 30,\n\t[LogLevel.Warn]: 40,\n\t[LogLevel.Error]: 50,\n\t[LogLevel.Fatal]: 60,\n\t[LogLevel.Silent]: 70,\n};\n\nexport class ConsoleLogger implements Logger {\n\tprivate readonly level: LogLevel;\n\n\t/**\n\t * Creates a new ConsoleLogger instance.\n\t *\n\t * @param data - Initial context data to include in all log messages\n\t * @param level - Minimum log level to output (default: Info)\n\t */\n\tconstructor(\n\t\treadonly data: object = {},\n\t\tlevel: LogLevel = LogLevel.Info,\n\t) {\n\t\tthis.level = level;\n\t}\n\n\t/**\n\t * Checks if a log level should be output based on the configured minimum level.\n\t */\n\tprivate shouldLog(level: LogLevel): boolean {\n\t\tif (this.level === LogLevel.Silent) {\n\t\t\treturn false;\n\t\t}\n\t\treturn LOG_LEVEL_PRIORITY[level] >= LOG_LEVEL_PRIORITY[this.level];\n\t}\n\n\t/**\n\t * Creates a logging function that merges context data and adds timestamps.\n\t *\n\t * @param logMethod - The console method to use (e.g., console.log, console.error)\n\t * @param level - The log level for this method\n\t * @returns A LogFn that handles both structured and simple logging\n\t * @private\n\t */\n\tprivate createLogFn(\n\t\tlogMethod: (...args: any[]) => void,\n\t\tlevel: LogLevel,\n\t): LogFn {\n\t\treturn <T extends object>(\n\t\t\tobjOrMsg: T | string,\n\t\t\tmsg?: string,\n\t\t\t...args: any[]\n\t\t): void => {\n\t\t\tif (!this.shouldLog(level)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst ts = Date.now();\n\n\t\t\t// Handle simple string logging: logger.info('message')\n\t\t\tif (typeof objOrMsg === 'string') {\n\t\t\t\tconst logData = { ...this.data, msg: objOrMsg, ts };\n\t\t\t\tlogMethod(logData, ...args);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Handle structured logging: logger.info({ data }, 'message')\n\t\t\tconst logData = msg\n\t\t\t\t? { ...this.data, ...objOrMsg, msg, ts }\n\t\t\t\t: { ...this.data, ...objOrMsg, ts };\n\t\t\tlogMethod(logData, ...args);\n\t\t};\n\t}\n\n\t/** Trace level logging function */\n\ttrace: LogFn = this.createLogFn(console.trace.bind(console), LogLevel.Trace);\n\t/** Debug level logging function */\n\tdebug: LogFn = this.createLogFn(console.debug.bind(console), LogLevel.Debug);\n\t/** Info level logging function */\n\tinfo: LogFn = this.createLogFn(console.info.bind(console), LogLevel.Info);\n\t/** Warning level logging function */\n\twarn: LogFn = this.createLogFn(console.warn.bind(console), LogLevel.Warn);\n\t/** Error level logging function */\n\terror: LogFn = this.createLogFn(console.error.bind(console), LogLevel.Error);\n\t/** Fatal level logging function (uses console.error) */\n\tfatal: LogFn = this.createLogFn(console.error.bind(console), LogLevel.Fatal);\n\n\t/**\n\t * Creates a child logger with additional context data.\n\t * The child logger inherits all context from the parent and adds its own.\n\t *\n\t * @param obj - Additional context data for the child logger\n\t * @returns A new ConsoleLogger instance with merged context\n\t *\n\t * @example\n\t * ```typescript\n\t * const parentLogger = new ConsoleLogger({ app: 'myApp' });\n\t * const childLogger = parentLogger.child({ module: 'database' });\n\t * childLogger.info({ query: 'SELECT * FROM users' }, 'Query executed');\n\t * // Context includes both { app: 'myApp' } and { module: 'database' }\n\t * ```\n\t */\n\tchild(obj: object): Logger {\n\t\treturn new ConsoleLogger(\n\t\t\t{\n\t\t\t\t...this.data,\n\t\t\t\t...obj,\n\t\t\t},\n\t\t\tthis.level,\n\t\t);\n\t}\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', msg: 'Application starting', ts: 1234567890 }\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, msg: 'User authenticated', ts: 1234567891 }\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 * import { LogLevel } from '@geekmidas/logger';\n *\n * const logger = createLogger({ level: LogLevel.Debug });\n * logger.debug('This will be logged');\n * logger.trace('This will NOT be logged (below Debug level)');\n * ```\n */\nexport function createLogger(options: CreateLoggerOptions = {}): Logger {\n\treturn new ConsoleLogger({}, options.level ?? LogLevel.Info);\n}\n"],"mappings":";;;;;AAMA,MAAM,qBAA+C;EAClC,UAAA;EACA,UAAA;EACD,SAAA;EACA,SAAA;EACC,UAAA;EACA,UAAA;EACC,WAAA;AACpB;AAEA,IAAa,gBAAb,MAAa,cAAgC;CAUlC;CATV;;;;;;;CAQA,YACC,OAAwB,CAAC,GACzB,QAAA,QACC;EAFQ,KAAA,OAAA;EAGT,KAAK,QAAQ;CACd;;;;CAKA,UAAkB,OAA0B;EAC3C,IAAI,KAAK,UAAA,UACR,OAAO;EAER,OAAO,mBAAmB,UAAU,mBAAmB,KAAK;CAC7D;;;;;;;;;CAUA,YACC,WACA,OACQ;EACR,QACC,UACA,KACA,GAAG,SACO;GACV,IAAI,CAAC,KAAK,UAAU,KAAK,GACxB;GAGD,MAAM,KAAK,KAAK,IAAI;GAGpB,IAAI,OAAO,aAAa,UAAU;IAEjC,UAAU;KADQ,GAAG,KAAK;KAAM,KAAK;KAAU;IAC/B,GAAG,GAAG,IAAI;IAC1B;GACD;GAMA,UAHgB,MACb;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;IAAK;GAAG,IACrC;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;GAAG,GAChB,GAAG,IAAI;EAC3B;CACD;;CAGA,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;CAE3E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;CAE3E,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,OAAO,GAAA,MAAgB;;CAExE,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,OAAO,GAAA,MAAgB;;CAExE,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;CAE3E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,OAAO,GAAA,OAAiB;;;;;;;;;;;;;;;;CAiB3E,MAAM,KAAqB;EAC1B,OAAO,IAAI,cACV;GACC,GAAG,KAAK;GACR,GAAG;EACJ,GACA,KAAK,KACN;CACD;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,iBAAiB,IAAI,cAAc;;;;;;;;;;;;;;;;;AAkBhD,SAAgB,aAAa,UAA+B,CAAC,GAAW;CACvE,OAAO,IAAI,cAAc,CAAC,GAAG,QAAQ,SAAA,MAAsB;AAC5D"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.LogLevel = require_types.LogLevel;
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_types = require("./types.cjs");
|
|
3
|
+
exports.LogLevel = require_types.LogLevel;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types
|
|
2
|
-
export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
|
|
1
|
+
import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types.cjs";
|
|
2
|
+
export { type CreateLoggerOptions, type LogFn, LogLevel, type Logger, type RedactOptions };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types
|
|
2
|
-
export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
|
|
1
|
+
import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types.mjs";
|
|
2
|
+
export { type CreateLoggerOptions, type LogFn, LogLevel, type Logger, type RedactOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { LogLevel } from "./types
|
|
2
|
-
|
|
3
|
-
export { LogLevel };
|
|
1
|
+
import { LogLevel } from "./types.mjs";
|
|
2
|
+
export { LogLevel };
|
package/dist/pino.cjs
CHANGED
|
@@ -1,44 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
const require_redact_paths = require('./redact-paths-D0m0DIuQ.cjs');
|
|
25
|
-
const pino = __toESM(require("pino"));
|
|
26
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_redact_paths = require("./redact-paths.cjs");
|
|
3
|
+
let pino = require("pino");
|
|
27
4
|
//#region src/pino.ts
|
|
28
5
|
/**
|
|
6
|
+
* Pino logger with built-in redaction support for sensitive data.
|
|
7
|
+
*
|
|
8
|
+
* Redaction is on by default: a logger that was never told about passwords
|
|
9
|
+
* and tokens still masks them. `redact: false` is the explicit opt-out.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { createLogger, DEFAULT_REDACT_PATHS } from '@geekmidas/logger/pino';
|
|
14
|
+
*
|
|
15
|
+
* // Redaction with sensible defaults — the same as `redact: true`
|
|
16
|
+
* const logger = createLogger();
|
|
17
|
+
*
|
|
18
|
+
* // Sensitive data is automatically masked
|
|
19
|
+
* logger.info({ password: 'secret123', user: 'john' }, 'Login');
|
|
20
|
+
* // Output: { password: '[Redacted]', user: 'john' } Login
|
|
21
|
+
*
|
|
22
|
+
* // Add custom paths (merged with defaults)
|
|
23
|
+
* const logger2 = createLogger({ redact: ['user.ssn'] });
|
|
24
|
+
*
|
|
25
|
+
* // Override defaults for full control
|
|
26
|
+
* const logger3 = createLogger({
|
|
27
|
+
* redact: {
|
|
28
|
+
* paths: ['onlyThis'],
|
|
29
|
+
* resolution: 'override',
|
|
30
|
+
* }
|
|
31
|
+
* });
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @module
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
29
37
|
* Resolves redaction configuration from options.
|
|
30
|
-
* Returns undefined
|
|
38
|
+
* Returns undefined only when redaction is turned off with `false`; leaving it
|
|
39
|
+
* unset is the same as `true`, so sensitive paths are masked unless someone
|
|
40
|
+
* decides they should not be.
|
|
31
41
|
*
|
|
32
42
|
* By default (resolution: 'merge'), custom paths are merged with DEFAULT_REDACT_PATHS.
|
|
33
43
|
* With resolution: 'override', only the custom paths are used.
|
|
34
44
|
*/
|
|
35
45
|
function resolveRedactConfig(redact) {
|
|
36
|
-
if (redact ===
|
|
37
|
-
if (redact === true) return require_redact_paths.DEFAULT_REDACT_PATHS;
|
|
46
|
+
if (redact === false) return;
|
|
47
|
+
if (redact === void 0 || redact === true) return require_redact_paths.DEFAULT_REDACT_PATHS;
|
|
38
48
|
if (Array.isArray(redact)) return [...require_redact_paths.DEFAULT_REDACT_PATHS, ...redact];
|
|
39
49
|
const { resolution = "merge", paths, censor, remove } = redact;
|
|
40
|
-
const
|
|
41
|
-
const config = { paths: resolvedPaths };
|
|
50
|
+
const config = { paths: resolution === "override" ? paths : [...require_redact_paths.DEFAULT_REDACT_PATHS, ...paths] };
|
|
42
51
|
if (censor !== void 0) config.censor = censor;
|
|
43
52
|
if (remove !== void 0) config.remove = remove;
|
|
44
53
|
return config;
|
|
@@ -51,24 +60,24 @@ function resolveRedactConfig(redact) {
|
|
|
51
60
|
*
|
|
52
61
|
* @example
|
|
53
62
|
* ```typescript
|
|
54
|
-
* // Basic logger
|
|
63
|
+
* // Basic logger — sensitive paths are redacted by default
|
|
55
64
|
* const logger = createLogger({ level: 'debug' });
|
|
56
65
|
*
|
|
57
|
-
* //
|
|
58
|
-
* const
|
|
66
|
+
* // Opt out of redaction
|
|
67
|
+
* const rawLogger = createLogger({ redact: false });
|
|
59
68
|
*
|
|
60
69
|
* // Pretty printing in development
|
|
61
|
-
* const devLogger = createLogger({ pretty: true
|
|
70
|
+
* const devLogger = createLogger({ pretty: true });
|
|
62
71
|
* ```
|
|
63
72
|
*/
|
|
64
73
|
function createLogger(options = {}) {
|
|
65
|
-
const pretty = options?.pretty && process.NODE_ENV !== "production";
|
|
74
|
+
const pretty = options?.pretty && process.env.NODE_ENV !== "production";
|
|
66
75
|
const baseOptions = pretty ? { transport: {
|
|
67
76
|
target: "pino-pretty",
|
|
68
77
|
options: { colorize: true }
|
|
69
78
|
} } : {};
|
|
70
79
|
const redact = resolveRedactConfig(options.redact);
|
|
71
|
-
|
|
80
|
+
const pinoOptions = {
|
|
72
81
|
...baseOptions,
|
|
73
82
|
...options.level && { level: options.level },
|
|
74
83
|
...redact && { redact },
|
|
@@ -80,10 +89,11 @@ function createLogger(options = {}) {
|
|
|
80
89
|
return { level: label.toUpperCase() };
|
|
81
90
|
}
|
|
82
91
|
}
|
|
83
|
-
}
|
|
92
|
+
};
|
|
93
|
+
return options.destination && !pretty ? (0, pino.pino)(pinoOptions, options.destination) : (0, pino.pino)(pinoOptions);
|
|
84
94
|
}
|
|
85
|
-
|
|
86
95
|
//#endregion
|
|
87
96
|
exports.DEFAULT_REDACT_PATHS = require_redact_paths.DEFAULT_REDACT_PATHS;
|
|
88
97
|
exports.createLogger = createLogger;
|
|
98
|
+
|
|
89
99
|
//# sourceMappingURL=pino.cjs.map
|
package/dist/pino.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pino.cjs","names":["
|
|
1
|
+
{"version":3,"file":"pino.cjs","names":["DEFAULT_REDACT_PATHS"],"sources":["../src/pino.ts"],"sourcesContent":["/**\n * Pino logger with built-in redaction support for sensitive data.\n *\n * Redaction is on by default: a logger that was never told about passwords\n * and tokens still masks them. `redact: false` is the explicit opt-out.\n *\n * @example\n * ```typescript\n * import { createLogger, DEFAULT_REDACT_PATHS } from '@geekmidas/logger/pino';\n *\n * // Redaction with sensible defaults — the same as `redact: true`\n * const logger = createLogger();\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 { DEFAULT_REDACT_PATHS } from './redact-paths';\nimport type { CreateLoggerOptions, RedactOptions } from './types';\n\n// Re-export for backwards compatibility\nexport { DEFAULT_REDACT_PATHS } from './redact-paths';\n\n/**\n * Type for the resolved pino redact config (without our custom resolution field).\n */\ntype PinoRedactConfig =\n\t| string[]\n\t| {\n\t\t\tpaths: string[];\n\t\t\tcensor?: string | ((value: unknown, path: string[]) => unknown);\n\t\t\tremove?: boolean;\n\t };\n\n/**\n * Resolves redaction configuration from options.\n * Returns undefined only when redaction is turned off with `false`; leaving it\n * unset is the same as `true`, so sensitive paths are masked unless someone\n * decides they should not be.\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\tredact: boolean | RedactOptions | undefined,\n): PinoRedactConfig | undefined {\n\tif (redact === false) {\n\t\treturn undefined;\n\t}\n\n\tif (redact === undefined || redact === true) {\n\t\treturn DEFAULT_REDACT_PATHS;\n\t}\n\n\t// Array syntax - merge with defaults\n\tif (Array.isArray(redact)) {\n\t\treturn [...DEFAULT_REDACT_PATHS, ...redact];\n\t}\n\n\t// Object syntax - check resolution mode\n\tconst { resolution = 'merge', paths, censor, remove } = redact;\n\n\tconst resolvedPaths =\n\t\tresolution === 'override' ? paths : [...DEFAULT_REDACT_PATHS, ...paths];\n\n\t// Return clean pino config without our resolution field\n\tconst config: PinoRedactConfig = { paths: resolvedPaths };\n\tif (censor !== undefined) config.censor = censor;\n\tif (remove !== undefined) config.remove = remove;\n\n\treturn 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 — sensitive paths are redacted by default\n * const logger = createLogger({ level: 'debug' });\n *\n * // Opt out of redaction\n * const rawLogger = createLogger({ redact: false });\n *\n * // Pretty printing in development\n * const devLogger = createLogger({ pretty: true });\n * ```\n */\nexport function createLogger(options: CreateLoggerOptions = {}) {\n\t// Pretty printing spawns a transport worker and writes for humans; in\n\t// production the output is for a log pipeline, so `pretty` is ignored there.\n\tconst pretty = options?.pretty && process.env.NODE_ENV !== 'production';\n\tconst baseOptions = pretty\n\t\t? {\n\t\t\t\ttransport: {\n\t\t\t\t\ttarget: 'pino-pretty',\n\t\t\t\t\toptions: { colorize: true },\n\t\t\t\t},\n\t\t\t}\n\t\t: {};\n\n\tconst redact = resolveRedactConfig(options.redact);\n\n\tconst pinoOptions = {\n\t\t...baseOptions,\n\t\t...(options.level && { level: options.level }),\n\t\t...(redact && { redact }),\n\t\tformatters: {\n\t\t\tbindings() {\n\t\t\t\treturn { nodeVersion: process.version };\n\t\t\t},\n\t\t\tlevel: (label: string) => {\n\t\t\t\treturn { level: label.toUpperCase() };\n\t\t\t},\n\t\t},\n\t};\n\n\t// A transport writes on its own worker, so a destination only applies when\n\t// the logger is not pretty-printing.\n\treturn options.destination && !pretty\n\t\t? pino(pinoOptions, options.destination)\n\t\t: pino(pinoOptions);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAS,oBACR,QAC+B;CAC/B,IAAI,WAAW,OACd;CAGD,IAAI,WAAW,KAAA,KAAa,WAAW,MACtC,OAAOA,qBAAAA;CAIR,IAAI,MAAM,QAAQ,MAAM,GACvB,OAAO,CAAC,GAAGA,qBAAAA,sBAAsB,GAAG,MAAM;CAI3C,MAAM,EAAE,aAAa,SAAS,OAAO,QAAQ,WAAW;CAMxD,MAAM,SAA2B,EAAE,OAHlC,eAAe,aAAa,QAAQ,CAAC,GAAGA,qBAAAA,sBAAsB,GAAG,KAAK,EAGf;CACxD,IAAI,WAAW,KAAA,GAAW,OAAO,SAAS;CAC1C,IAAI,WAAW,KAAA,GAAW,OAAO,SAAS;CAE1C,OAAO;AACR;;;;;;;;;;;;;;;;;;;AAoBA,SAAgB,aAAa,UAA+B,CAAC,GAAG;CAG/D,MAAM,SAAS,SAAS,UAAU,QAAQ,IAAI,aAAa;CAC3D,MAAM,cAAc,SACjB,EACA,WAAW;EACV,QAAQ;EACR,SAAS,EAAE,UAAU,KAAK;CAC3B,EACD,IACC,CAAC;CAEJ,MAAM,SAAS,oBAAoB,QAAQ,MAAM;CAEjD,MAAM,cAAc;EACnB,GAAG;EACH,GAAI,QAAQ,SAAS,EAAE,OAAO,QAAQ,MAAM;EAC5C,GAAI,UAAU,EAAE,OAAO;EACvB,YAAY;GACX,WAAW;IACV,OAAO,EAAE,aAAa,QAAQ,QAAQ;GACvC;GACA,QAAQ,UAAkB;IACzB,OAAO,EAAE,OAAO,MAAM,YAAY,EAAE;GACrC;EACD;CACD;CAIA,OAAO,QAAQ,eAAe,CAAC,UAAA,GAC5B,KAAA,KAAA,CAAK,aAAa,QAAQ,WAAW,KAAA,GACrC,KAAA,KAAA,CAAK,WAAW;AACpB"}
|
package/dist/pino.d.cts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { CreateLoggerOptions } from "./types
|
|
2
|
-
import { DEFAULT_REDACT_PATHS } from "./redact-paths
|
|
3
|
-
import * as pino0 from "pino";
|
|
4
|
-
|
|
1
|
+
import { CreateLoggerOptions } from "./types.cjs";
|
|
2
|
+
import { DEFAULT_REDACT_PATHS } from "./redact-paths.cjs";
|
|
5
3
|
//#region src/pino.d.ts
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* Creates a pino logger instance with optional redaction support.
|
|
9
6
|
*
|
|
@@ -12,18 +9,17 @@ import * as pino0 from "pino";
|
|
|
12
9
|
*
|
|
13
10
|
* @example
|
|
14
11
|
* ```typescript
|
|
15
|
-
* // Basic logger
|
|
12
|
+
* // Basic logger — sensitive paths are redacted by default
|
|
16
13
|
* const logger = createLogger({ level: 'debug' });
|
|
17
14
|
*
|
|
18
|
-
* //
|
|
19
|
-
* const
|
|
15
|
+
* // Opt out of redaction
|
|
16
|
+
* const rawLogger = createLogger({ redact: false });
|
|
20
17
|
*
|
|
21
18
|
* // Pretty printing in development
|
|
22
|
-
* const devLogger = createLogger({ pretty: true
|
|
19
|
+
* const devLogger = createLogger({ pretty: true });
|
|
23
20
|
* ```
|
|
24
21
|
*/
|
|
25
|
-
declare function createLogger(options?: CreateLoggerOptions):
|
|
26
|
-
//# sourceMappingURL=pino.d.ts.map
|
|
22
|
+
export declare function createLogger(options?: CreateLoggerOptions): import("pino").Logger<never, boolean>;
|
|
27
23
|
//#endregion
|
|
28
|
-
export { DEFAULT_REDACT_PATHS
|
|
24
|
+
export { DEFAULT_REDACT_PATHS };
|
|
29
25
|
//# sourceMappingURL=pino.d.cts.map
|
package/dist/pino.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pino.d.cts","names":[],"sources":["../src/pino.ts"],"
|
|
1
|
+
{"version":3,"file":"pino.d.cts","names":[],"sources":["../src/pino.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;wBA0GgB,aAAa,UAAS,qCAAwB"}
|
package/dist/pino.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { CreateLoggerOptions } from "./types
|
|
2
|
-
import { DEFAULT_REDACT_PATHS } from "./redact-paths
|
|
3
|
-
import * as pino0 from "pino";
|
|
4
|
-
|
|
1
|
+
import { CreateLoggerOptions } from "./types.mjs";
|
|
2
|
+
import { DEFAULT_REDACT_PATHS } from "./redact-paths.mjs";
|
|
5
3
|
//#region src/pino.d.ts
|
|
6
|
-
|
|
7
4
|
/**
|
|
8
5
|
* Creates a pino logger instance with optional redaction support.
|
|
9
6
|
*
|
|
@@ -12,18 +9,17 @@ import * as pino0 from "pino";
|
|
|
12
9
|
*
|
|
13
10
|
* @example
|
|
14
11
|
* ```typescript
|
|
15
|
-
* // Basic logger
|
|
12
|
+
* // Basic logger — sensitive paths are redacted by default
|
|
16
13
|
* const logger = createLogger({ level: 'debug' });
|
|
17
14
|
*
|
|
18
|
-
* //
|
|
19
|
-
* const
|
|
15
|
+
* // Opt out of redaction
|
|
16
|
+
* const rawLogger = createLogger({ redact: false });
|
|
20
17
|
*
|
|
21
18
|
* // Pretty printing in development
|
|
22
|
-
* const devLogger = createLogger({ pretty: true
|
|
19
|
+
* const devLogger = createLogger({ pretty: true });
|
|
23
20
|
* ```
|
|
24
21
|
*/
|
|
25
|
-
declare function createLogger(options?: CreateLoggerOptions):
|
|
26
|
-
//# sourceMappingURL=pino.d.ts.map
|
|
22
|
+
export declare function createLogger(options?: CreateLoggerOptions): import("pino").Logger<never, boolean>;
|
|
27
23
|
//#endregion
|
|
28
|
-
export { DEFAULT_REDACT_PATHS
|
|
24
|
+
export { DEFAULT_REDACT_PATHS };
|
|
29
25
|
//# sourceMappingURL=pino.d.mts.map
|