@geekmidas/logger 10.0.0-alpha.99 → 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/CHANGELOG.md ADDED
@@ -0,0 +1,48 @@
1
+ # @geekmidas/logger
2
+
3
+ ## 10.0.0
4
+
5
+ ## 9.0.2
6
+
7
+ ### Patch Changes
8
+
9
+ - [#12](https://github.com/geekmidas/toolbox/pull/12) [`d53863a`](https://github.com/geekmidas/toolbox/commit/d53863a84db2e4ab5420e08f79128b637043fc42) Thanks [@geekmidas](https://github.com/geekmidas)! - Align every published package on a single version and keep them in step.
10
+
11
+ All packages now share one version, enforced by a changesets `fixed` group. The
12
+ baseline is 9.0.1 — @geekmidas/client's published version — so nothing moves
13
+ backwards; this release takes the whole set to 9.0.2 together.
14
+
15
+ Independent versions made "which version of the docs applies to me"
16
+ unanswerable: a reader on constructs@7 and cli@2 was on no version at all. One
17
+ number per release makes versioned documentation possible, and lets 9 freeze as
18
+ the current paradigm while the constructs rework is developed against it.
19
+
20
+ Every release now publishes every package, and a major anywhere is a major
21
+ everywhere. Peer ranges get simpler in return.
22
+
23
+ ## 1.0.3
24
+
25
+ ### Patch Changes
26
+
27
+ - 🐛 [#11](https://github.com/geekmidas/toolbox/pull/11) [`40f4dc0`](https://github.com/geekmidas/toolbox/commit/40f4dc095911b2223a255029d8f776caf7781309) Thanks [@geekmidas](https://github.com/geekmidas)! - Patch release across all packages to realign published versions with the
28
+ registry. The previous release only published the four packages that had
29
+ version bumps; the remaining packages failed with "cannot publish over the
30
+ previously published versions" because their versions were unchanged.
31
+
32
+ ## 1.0.2
33
+
34
+ ### Patch Changes
35
+
36
+ - 🐛 [`d70c6c0`](https://github.com/geekmidas/toolbox/commit/d70c6c0aeb8a79da2473ac77dbd8255a4a2f5651) Thanks [@geekmidas](https://github.com/geekmidas)! - Fix `package.json` exports so TypeScript declarations resolve correctly under NodeNext/Bundler module resolution. Each subpath export now nests `types` inside its `import`/`require` condition, pointing at the `.d.mts` and `.d.cts` files that `tsdown` actually emits (previously the exports referenced non-existent `.d.ts` files, causing type-resolution failures for consumers). Both ESM (`.mjs`) and CJS (`.cjs`) runtime entry points are preserved. Additionally, `@geekmidas/ui` had `import` paths pointing at `.js` files that were never emitted — those are corrected to `.mjs`.
37
+
38
+ ## 1.0.1
39
+
40
+ ### Patch Changes
41
+
42
+ - ✨ [`0830c6e`](https://github.com/geekmidas/toolbox/commit/0830c6e0d60842526788e0e1f0e78827514ea7b3) Thanks [@geekmidas](https://github.com/geekmidas)! - Add optional sniff support
43
+
44
+ ## 1.0.0
45
+
46
+ ### Major Changes
47
+
48
+ - [`ff7b115`](https://github.com/geekmidas/toolbox/commit/ff7b11599f60f84ac6cdc73714c853ecf786b2e8) Thanks [@geekmidas](https://github.com/geekmidas)! - Version 1 Stable release
package/dist/console.cjs CHANGED
@@ -1,20 +1,19 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- require("./types.cjs");
1
+ const require_types = require('./types-ag_0Cvbg.cjs');
2
+
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
- ["trace"]: 10,
9
- ["debug"]: 20,
10
- ["info"]: 30,
11
- ["warn"]: 40,
12
- ["error"]: 50,
13
- ["fatal"]: 60,
14
- ["silent"]: 70
8
+ [require_types.LogLevel.Trace]: 10,
9
+ [require_types.LogLevel.Debug]: 20,
10
+ [require_types.LogLevel.Info]: 30,
11
+ [require_types.LogLevel.Warn]: 40,
12
+ [require_types.LogLevel.Error]: 50,
13
+ [require_types.LogLevel.Fatal]: 60,
14
+ [require_types.LogLevel.Silent]: 70
15
15
  };
16
16
  var ConsoleLogger = class ConsoleLogger {
17
- data;
18
17
  level;
19
18
  /**
20
19
  * Creates a new ConsoleLogger instance.
@@ -22,7 +21,7 @@ var ConsoleLogger = class ConsoleLogger {
22
21
  * @param data - Initial context data to include in all log messages
23
22
  * @param level - Minimum log level to output (default: Info)
24
23
  */
25
- constructor(data = {}, level = "info") {
24
+ constructor(data = {}, level = require_types.LogLevel.Info) {
26
25
  this.data = data;
27
26
  this.level = level;
28
27
  }
@@ -30,7 +29,7 @@ var ConsoleLogger = class ConsoleLogger {
30
29
  * Checks if a log level should be output based on the configured minimum level.
31
30
  */
32
31
  shouldLog(level) {
33
- if (this.level === "silent") return false;
32
+ if (this.level === require_types.LogLevel.Silent) return false;
34
33
  return LOG_LEVEL_PRIORITY[level] >= LOG_LEVEL_PRIORITY[this.level];
35
34
  }
36
35
  /**
@@ -46,14 +45,15 @@ var ConsoleLogger = class ConsoleLogger {
46
45
  if (!this.shouldLog(level)) return;
47
46
  const ts = Date.now();
48
47
  if (typeof objOrMsg === "string") {
49
- logMethod({
48
+ const logData$1 = {
50
49
  ...this.data,
51
50
  msg: objOrMsg,
52
51
  ts
53
- }, ...args);
52
+ };
53
+ logMethod(logData$1, ...args);
54
54
  return;
55
55
  }
56
- logMethod(msg ? {
56
+ const logData = msg ? {
57
57
  ...this.data,
58
58
  ...objOrMsg,
59
59
  msg,
@@ -62,21 +62,22 @@ var ConsoleLogger = class ConsoleLogger {
62
62
  ...this.data,
63
63
  ...objOrMsg,
64
64
  ts
65
- }, ...args);
65
+ };
66
+ logMethod(logData, ...args);
66
67
  };
67
68
  }
68
69
  /** Trace level logging function */
69
- trace = this.createLogFn(console.trace.bind(console), "trace");
70
+ trace = this.createLogFn(console.trace.bind(console), require_types.LogLevel.Trace);
70
71
  /** Debug level logging function */
71
- debug = this.createLogFn(console.debug.bind(console), "debug");
72
+ debug = this.createLogFn(console.debug.bind(console), require_types.LogLevel.Debug);
72
73
  /** Info level logging function */
73
- info = this.createLogFn(console.info.bind(console), "info");
74
+ info = this.createLogFn(console.info.bind(console), require_types.LogLevel.Info);
74
75
  /** Warning level logging function */
75
- warn = this.createLogFn(console.warn.bind(console), "warn");
76
+ warn = this.createLogFn(console.warn.bind(console), require_types.LogLevel.Warn);
76
77
  /** Error level logging function */
77
- error = this.createLogFn(console.error.bind(console), "error");
78
+ error = this.createLogFn(console.error.bind(console), require_types.LogLevel.Error);
78
79
  /** Fatal level logging function (uses console.error) */
79
- fatal = this.createLogFn(console.error.bind(console), "fatal");
80
+ fatal = this.createLogFn(console.error.bind(console), require_types.LogLevel.Fatal);
80
81
  /**
81
82
  * Creates a child logger with additional context data.
82
83
  * The child logger inherits all context from the parent and adds its own.
@@ -141,11 +142,11 @@ const DEFAULT_LOGGER = new ConsoleLogger();
141
142
  * ```
142
143
  */
143
144
  function createLogger(options = {}) {
144
- return new ConsoleLogger({}, options.level ?? "info");
145
+ return new ConsoleLogger({}, options.level ?? require_types.LogLevel.Info);
145
146
  }
147
+
146
148
  //#endregion
147
149
  exports.ConsoleLogger = ConsoleLogger;
148
150
  exports.DEFAULT_LOGGER = DEFAULT_LOGGER;
149
151
  exports.createLogger = createLogger;
150
-
151
152
  //# sourceMappingURL=console.cjs.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"console.cjs","names":["LOG_LEVEL_PRIORITY: Record<LogLevel, number>","LogLevel","data: object","level: LogLevel","logMethod: (...args: any[]) => void","objOrMsg: T | string","msg?: string","logData","obj: object","options: CreateLoggerOptions"],"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,MAAMA,qBAA+C;EACnDC,uBAAS,QAAQ;EACjBA,uBAAS,QAAQ;EACjBA,uBAAS,OAAO;EAChBA,uBAAS,OAAO;EAChBA,uBAAS,QAAQ;EACjBA,uBAAS,QAAQ;EACjBA,uBAAS,SAAS;AACnB;AAED,IAAa,gBAAb,MAAa,cAAgC;CAC5C,AAAiB;;;;;;;CAQjB,YACUC,OAAe,CAAE,GAC1BC,QAAkBF,uBAAS,MAC1B;EAFQ;AAGT,OAAK,QAAQ;CACb;;;;CAKD,AAAQ,UAAUE,OAA0B;AAC3C,MAAI,KAAK,UAAUF,uBAAS,OAC3B,QAAO;AAER,SAAO,mBAAmB,UAAU,mBAAmB,KAAK;CAC5D;;;;;;;;;CAUD,AAAQ,YACPG,WACAD,OACQ;AACR,SAAO,CACNE,UACAC,KACA,GAAG,SACO;AACV,QAAK,KAAK,UAAU,MAAM,CACzB;GAGD,MAAM,KAAK,KAAK,KAAK;AAGrB,cAAW,aAAa,UAAU;IACjC,MAAMC,YAAU;KAAE,GAAG,KAAK;KAAM,KAAK;KAAU;IAAI;AACnD,cAAUA,WAAS,GAAG,KAAK;AAC3B;GACA;GAGD,MAAM,UAAU,MACb;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;IAAK;GAAI,IACtC;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;GAAI;AACpC,aAAU,SAAS,GAAG,KAAK;EAC3B;CACD;;CAGD,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAEN,uBAAS,MAAM;;CAE5E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAEA,uBAAS,MAAM;;CAE5E,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,EAAEA,uBAAS,KAAK;;CAEzE,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,EAAEA,uBAAS,KAAK;;CAEzE,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAEA,uBAAS,MAAM;;CAE5E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAEA,uBAAS,MAAM;;;;;;;;;;;;;;;;CAiB5E,MAAMO,KAAqB;AAC1B,SAAO,IAAI,cACV;GACC,GAAG,KAAK;GACR,GAAG;EACH,GACD,KAAK;CAEN;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AA2BD,MAAa,iBAAiB,IAAI;;;;;;;;;;;;;;;;;AAkBlC,SAAgB,aAAaC,UAA+B,CAAE,GAAU;AACvE,QAAO,IAAI,cAAc,CAAE,GAAE,QAAQ,SAASR,uBAAS;AACvD"}
@@ -1,6 +1,7 @@
1
- import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types.cjs";
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-Dk_k2-f_.cjs";
2
+
2
3
  //#region src/console.d.ts
3
- export declare class ConsoleLogger implements Logger {
4
+ declare class ConsoleLogger implements Logger {
4
5
  readonly data: object;
5
6
  private readonly level;
6
7
  /**
@@ -76,7 +77,7 @@ export declare class ConsoleLogger implements Logger {
76
77
  * }
77
78
  * ```
78
79
  */
79
- export declare const DEFAULT_LOGGER: any;
80
+ declare const DEFAULT_LOGGER: any;
80
81
  /**
81
82
  * Creates a console logger with the same API as pino's createLogger.
82
83
  *
@@ -93,6 +94,8 @@ export declare const DEFAULT_LOGGER: any;
93
94
  * logger.trace('This will NOT be logged (below Debug level)');
94
95
  * ```
95
96
  */
96
- export declare function createLogger(options?: CreateLoggerOptions): Logger;
97
+ declare function createLogger(options?: CreateLoggerOptions): Logger;
98
+ //# sourceMappingURL=console.d.ts.map
97
99
  //#endregion
100
+ export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
98
101
  //# sourceMappingURL=console.d.cts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"console.d.cts","names":[],"sources":["../src/console.ts"],"sourcesContent":[],"mappings":";;;cAgBa,aAAA,YAAyB;EAAzB,SAAA,IAAA,EAAA,MAAc;EAAA,iBAAA,KAAA;EAAA;;;;;;EAyEd,WAEL,CAAA,IAAA,CAAA,EAAA,MAAA,EAAA,KAAA,CAAA,EAhEC,QAgED;EAAK;;AA3E+B;EAgI/B,QAAA,SAA2C;EAkBxC;;;;AAAuD;;;;;;SAjF/D;;SAEA;;QAED;;QAEA;;SAEC;;SAEA;;;;;;;;;;;;;;;;sBAiBa;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCR;;;;;;;;;;;;;;;;;iBAkBG,YAAA,WAAsB,sBAA2B"}
@@ -1,6 +1,7 @@
1
- import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types.mjs";
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-BDdpcrpy.mjs";
2
+
2
3
  //#region src/console.d.ts
3
- export declare class ConsoleLogger implements Logger {
4
+ declare class ConsoleLogger implements Logger {
4
5
  readonly data: object;
5
6
  private readonly level;
6
7
  /**
@@ -76,7 +77,7 @@ export declare class ConsoleLogger implements Logger {
76
77
  * }
77
78
  * ```
78
79
  */
79
- export declare const DEFAULT_LOGGER: any;
80
+ declare const DEFAULT_LOGGER: any;
80
81
  /**
81
82
  * Creates a console logger with the same API as pino's createLogger.
82
83
  *
@@ -93,6 +94,8 @@ export declare const DEFAULT_LOGGER: any;
93
94
  * logger.trace('This will NOT be logged (below Debug level)');
94
95
  * ```
95
96
  */
96
- export declare function createLogger(options?: CreateLoggerOptions): Logger;
97
+ declare function createLogger(options?: CreateLoggerOptions): Logger;
98
+ //# sourceMappingURL=console.d.ts.map
97
99
  //#endregion
100
+ export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
98
101
  //# sourceMappingURL=console.d.mts.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"console.d.mts","names":[],"sources":["../src/console.ts"],"sourcesContent":[],"mappings":";;;cAgBa,aAAA,YAAyB;EAAzB,SAAA,IAAA,EAAA,MAAc;EAAA,iBAAA,KAAA;EAAA;;;;;;EAyEd,WAEL,CAAA,IAAA,CAAA,EAAA,MAAA,EAAA,KAAA,CAAA,EAhEC,QAgED;EAAK;;AA3E+B;EAgI/B,QAAA,SAA2C;EAkBxC;;;;AAAuD;;;;;;SAjF/D;;SAEA;;QAED;;QAEA;;SAEC;;SAEA;;;;;;;;;;;;;;;;sBAiBa;;;;;;;;;;;;;;;;;;;;;;;;;;cAoCR;;;;;;;;;;;;;;;;;iBAkBG,YAAA,WAAsB,sBAA2B"}
package/dist/console.mjs CHANGED
@@ -1,19 +1,19 @@
1
- import "./types.mjs";
1
+ import { LogLevel } from "./types-yQ6XOihF.mjs";
2
+
2
3
  //#region src/console.ts
3
4
  /**
4
5
  * Numeric priority for log levels (higher = more severe)
5
6
  */
6
7
  const LOG_LEVEL_PRIORITY = {
7
- ["trace"]: 10,
8
- ["debug"]: 20,
9
- ["info"]: 30,
10
- ["warn"]: 40,
11
- ["error"]: 50,
12
- ["fatal"]: 60,
13
- ["silent"]: 70
8
+ [LogLevel.Trace]: 10,
9
+ [LogLevel.Debug]: 20,
10
+ [LogLevel.Info]: 30,
11
+ [LogLevel.Warn]: 40,
12
+ [LogLevel.Error]: 50,
13
+ [LogLevel.Fatal]: 60,
14
+ [LogLevel.Silent]: 70
14
15
  };
15
16
  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 = "info") {
24
+ constructor(data = {}, level = LogLevel.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 === "silent") return false;
32
+ if (this.level === LogLevel.Silent) return false;
33
33
  return LOG_LEVEL_PRIORITY[level] >= LOG_LEVEL_PRIORITY[this.level];
34
34
  }
35
35
  /**
@@ -45,14 +45,15 @@ var ConsoleLogger = class ConsoleLogger {
45
45
  if (!this.shouldLog(level)) return;
46
46
  const ts = Date.now();
47
47
  if (typeof objOrMsg === "string") {
48
- logMethod({
48
+ const logData$1 = {
49
49
  ...this.data,
50
50
  msg: objOrMsg,
51
51
  ts
52
- }, ...args);
52
+ };
53
+ logMethod(logData$1, ...args);
53
54
  return;
54
55
  }
55
- logMethod(msg ? {
56
+ const logData = msg ? {
56
57
  ...this.data,
57
58
  ...objOrMsg,
58
59
  msg,
@@ -61,21 +62,22 @@ var ConsoleLogger = class ConsoleLogger {
61
62
  ...this.data,
62
63
  ...objOrMsg,
63
64
  ts
64
- }, ...args);
65
+ };
66
+ logMethod(logData, ...args);
65
67
  };
66
68
  }
67
69
  /** Trace level logging function */
68
- trace = this.createLogFn(console.trace.bind(console), "trace");
70
+ trace = this.createLogFn(console.trace.bind(console), LogLevel.Trace);
69
71
  /** Debug level logging function */
70
- debug = this.createLogFn(console.debug.bind(console), "debug");
72
+ debug = this.createLogFn(console.debug.bind(console), LogLevel.Debug);
71
73
  /** Info level logging function */
72
- info = this.createLogFn(console.info.bind(console), "info");
74
+ info = this.createLogFn(console.info.bind(console), LogLevel.Info);
73
75
  /** Warning level logging function */
74
- warn = this.createLogFn(console.warn.bind(console), "warn");
76
+ warn = this.createLogFn(console.warn.bind(console), LogLevel.Warn);
75
77
  /** Error level logging function */
76
- error = this.createLogFn(console.error.bind(console), "error");
78
+ error = this.createLogFn(console.error.bind(console), LogLevel.Error);
77
79
  /** Fatal level logging function (uses console.error) */
78
- fatal = this.createLogFn(console.error.bind(console), "fatal");
80
+ fatal = this.createLogFn(console.error.bind(console), LogLevel.Fatal);
79
81
  /**
80
82
  * Creates a child logger with additional context data.
81
83
  * The child logger inherits all context from the parent and adds its own.
@@ -140,9 +142,9 @@ const DEFAULT_LOGGER = new ConsoleLogger();
140
142
  * ```
141
143
  */
142
144
  function createLogger(options = {}) {
143
- return new ConsoleLogger({}, options.level ?? "info");
145
+ return new ConsoleLogger({}, options.level ?? LogLevel.Info);
144
146
  }
147
+
145
148
  //#endregion
146
149
  export { ConsoleLogger, DEFAULT_LOGGER, createLogger };
147
-
148
150
  //# sourceMappingURL=console.mjs.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"console.mjs","names":["LOG_LEVEL_PRIORITY: Record<LogLevel, number>","data: object","level: LogLevel","logMethod: (...args: any[]) => void","objOrMsg: T | string","msg?: string","logData","obj: object","options: CreateLoggerOptions"],"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,MAAMA,qBAA+C;EACnD,SAAS,QAAQ;EACjB,SAAS,QAAQ;EACjB,SAAS,OAAO;EAChB,SAAS,OAAO;EAChB,SAAS,QAAQ;EACjB,SAAS,QAAQ;EACjB,SAAS,SAAS;AACnB;AAED,IAAa,gBAAb,MAAa,cAAgC;CAC5C,AAAiB;;;;;;;CAQjB,YACUC,OAAe,CAAE,GAC1BC,QAAkB,SAAS,MAC1B;EAFQ;AAGT,OAAK,QAAQ;CACb;;;;CAKD,AAAQ,UAAUA,OAA0B;AAC3C,MAAI,KAAK,UAAU,SAAS,OAC3B,QAAO;AAER,SAAO,mBAAmB,UAAU,mBAAmB,KAAK;CAC5D;;;;;;;;;CAUD,AAAQ,YACPC,WACAD,OACQ;AACR,SAAO,CACNE,UACAC,KACA,GAAG,SACO;AACV,QAAK,KAAK,UAAU,MAAM,CACzB;GAGD,MAAM,KAAK,KAAK,KAAK;AAGrB,cAAW,aAAa,UAAU;IACjC,MAAMC,YAAU;KAAE,GAAG,KAAK;KAAM,KAAK;KAAU;IAAI;AACnD,cAAUA,WAAS,GAAG,KAAK;AAC3B;GACA;GAGD,MAAM,UAAU,MACb;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;IAAK;GAAI,IACtC;IAAE,GAAG,KAAK;IAAM,GAAG;IAAU;GAAI;AACpC,aAAU,SAAS,GAAG,KAAK;EAC3B;CACD;;CAGD,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAE,SAAS,MAAM;;CAE5E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAE,SAAS,MAAM;;CAE5E,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,EAAE,SAAS,KAAK;;CAEzE,OAAc,KAAK,YAAY,QAAQ,KAAK,KAAK,QAAQ,EAAE,SAAS,KAAK;;CAEzE,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAE,SAAS,MAAM;;CAE5E,QAAe,KAAK,YAAY,QAAQ,MAAM,KAAK,QAAQ,EAAE,SAAS,MAAM;;;;;;;;;;;;;;;;CAiB5E,MAAMC,KAAqB;AAC1B,SAAO,IAAI,cACV;GACC,GAAG,KAAK;GACR,GAAG;EACH,GACD,KAAK;CAEN;AACD;;;;;;;;;;;;;;;;;;;;;;;;;AA2BD,MAAa,iBAAiB,IAAI;;;;;;;;;;;;;;;;;AAkBlC,SAAgB,aAAaC,UAA+B,CAAE,GAAU;AACvE,QAAO,IAAI,cAAc,CAAE,GAAE,QAAQ,SAAS,SAAS;AACvD"}
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_types = require("./types.cjs");
3
- exports.LogLevel = require_types.LogLevel;
1
+ const require_types = require('./types-ag_0Cvbg.cjs');
2
+
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.cjs";
2
- export { type CreateLoggerOptions, type LogFn, LogLevel, type Logger, type RedactOptions };
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-Dk_k2-f_.cjs";
2
+ export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types.mjs";
2
- export { type CreateLoggerOptions, type LogFn, LogLevel, type Logger, type RedactOptions };
1
+ import { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions } from "./types-BDdpcrpy.mjs";
2
+ export { CreateLoggerOptions, LogFn, LogLevel, Logger, RedactOptions };
package/dist/index.mjs CHANGED
@@ -1,2 +1,3 @@
1
- import { LogLevel } from "./types.mjs";
2
- export { LogLevel };
1
+ import { LogLevel } from "./types-yQ6XOihF.mjs";
2
+
3
+ export { LogLevel };
package/dist/pino.cjs CHANGED
@@ -1,54 +1,44 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_otel = require("./otel.cjs");
3
- const require_redact_paths = require("./redact-paths.cjs");
4
- let pino = require("pino");
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
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
+
5
27
  //#region src/pino.ts
6
28
  /**
7
- * Pino logger with built-in redaction support for sensitive data.
8
- *
9
- * Redaction is on by default: a logger that was never told about passwords
10
- * and tokens still masks them. `redact: false` is the explicit opt-out.
11
- *
12
- * @example
13
- * ```typescript
14
- * import { createLogger, DEFAULT_REDACT_PATHS } from '@geekmidas/logger/pino';
15
- *
16
- * // Redaction with sensible defaults — the same as `redact: true`
17
- * const logger = createLogger();
18
- *
19
- * // Sensitive data is automatically masked
20
- * logger.info({ password: 'secret123', user: 'john' }, 'Login');
21
- * // Output: { password: '[Redacted]', user: 'john' } Login
22
- *
23
- * // Add custom paths (merged with defaults)
24
- * const logger2 = createLogger({ redact: ['user.ssn'] });
25
- *
26
- * // Override defaults for full control
27
- * const logger3 = createLogger({
28
- * redact: {
29
- * paths: ['onlyThis'],
30
- * resolution: 'override',
31
- * }
32
- * });
33
- * ```
34
- *
35
- * @module
36
- */
37
- /**
38
29
  * Resolves redaction configuration from options.
39
- * Returns undefined only when redaction is turned off with `false`; leaving it
40
- * unset is the same as `true`, so sensitive paths are masked unless someone
41
- * decides they should not be.
30
+ * Returns undefined if redaction is disabled, or a pino-compatible redact config.
42
31
  *
43
32
  * By default (resolution: 'merge'), custom paths are merged with DEFAULT_REDACT_PATHS.
44
33
  * With resolution: 'override', only the custom paths are used.
45
34
  */
46
35
  function resolveRedactConfig(redact) {
47
- if (redact === false) return;
48
- if (redact === void 0 || redact === true) return require_redact_paths.DEFAULT_REDACT_PATHS;
36
+ if (redact === void 0 || redact === false) return void 0;
37
+ if (redact === true) return require_redact_paths.DEFAULT_REDACT_PATHS;
49
38
  if (Array.isArray(redact)) return [...require_redact_paths.DEFAULT_REDACT_PATHS, ...redact];
50
39
  const { resolution = "merge", paths, censor, remove } = redact;
51
- const config = { paths: resolution === "override" ? paths : [...require_redact_paths.DEFAULT_REDACT_PATHS, ...paths] };
40
+ const resolvedPaths = resolution === "override" ? paths : [...require_redact_paths.DEFAULT_REDACT_PATHS, ...paths];
41
+ const config = { paths: resolvedPaths };
52
42
  if (censor !== void 0) config.censor = censor;
53
43
  if (remove !== void 0) config.remove = remove;
54
44
  return config;
@@ -61,45 +51,28 @@ function resolveRedactConfig(redact) {
61
51
  *
62
52
  * @example
63
53
  * ```typescript
64
- * // Basic logger — sensitive paths are redacted by default
54
+ * // Basic logger
65
55
  * const logger = createLogger({ level: 'debug' });
66
56
  *
67
- * // Opt out of redaction
68
- * const rawLogger = createLogger({ redact: false });
57
+ * // With redaction enabled
58
+ * const secureLogger = createLogger({ redact: true });
69
59
  *
70
60
  * // Pretty printing in development
71
- * const devLogger = createLogger({ pretty: true });
61
+ * const devLogger = createLogger({ pretty: true, redact: true });
72
62
  * ```
73
63
  */
74
64
  function createLogger(options = {}) {
75
- const pretty = options?.pretty && process.env.NODE_ENV !== "production";
65
+ const pretty = options?.pretty && process.NODE_ENV !== "production";
76
66
  const baseOptions = pretty ? { transport: {
77
67
  target: "pino-pretty",
78
68
  options: { colorize: true }
79
69
  } } : {};
80
70
  const redact = resolveRedactConfig(options.redact);
81
- const serializeError = (value) => {
82
- const serialized = pino.stdSerializers.err(value);
83
- if (!redact || serialized === value) return serialized;
84
- return require_redact_paths.redactUrlCredentialsIn({ ...serialized });
85
- };
86
- const pinoOptions = {
71
+ return (0, pino.pino)({
87
72
  ...baseOptions,
88
73
  ...options.level && { level: options.level },
89
74
  ...redact && { redact },
90
- serializers: {
91
- err: serializeError,
92
- error: serializeError
93
- },
94
- hooks: {
95
- ...redact && { logMethod(args, method) {
96
- const redacted = args.map((arg) => typeof arg === "string" ? require_redact_paths.redactUrlCredentials(arg) : arg);
97
- return method.apply(this, redacted);
98
- } },
99
- streamWrite: require_otel.otelStreamWrite
100
- },
101
75
  formatters: {
102
- ...redact && { log: (object) => require_redact_paths.redactUrlCredentialsIn(object) },
103
76
  bindings() {
104
77
  return { nodeVersion: process.version };
105
78
  },
@@ -107,11 +80,10 @@ function createLogger(options = {}) {
107
80
  return { level: label.toUpperCase() };
108
81
  }
109
82
  }
110
- };
111
- return options.destination && !pretty ? (0, pino.pino)(pinoOptions, options.destination) : (0, pino.pino)(pinoOptions);
83
+ });
112
84
  }
85
+
113
86
  //#endregion
114
87
  exports.DEFAULT_REDACT_PATHS = require_redact_paths.DEFAULT_REDACT_PATHS;
115
88
  exports.createLogger = createLogger;
116
-
117
89
  //# sourceMappingURL=pino.cjs.map
package/dist/pino.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pino.cjs","names":["DEFAULT_REDACT_PATHS","stdSerializers","redactUrlCredentialsIn","redactUrlCredentials","otelStreamWrite"],"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 { type LogFn, type Logger, pino, stdSerializers } from 'pino';\nimport { otelStreamWrite } from './otel';\nimport {\n\tDEFAULT_REDACT_PATHS,\n\tredactUrlCredentials,\n\tredactUrlCredentialsIn,\n} 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\t// An Error is serialized only under a key pino has a serializer for — `err`\n\t// by default — and anything else is JSON.stringify'd, which an Error survives\n\t// as `{}`: no message, no stack. `logger.error({ error }, …)` is how most\n\t// code writes it, so `error` gets the same serializer as `err`.\n\t//\n\t// The serialized copy is a plain object, so URL credentials in the message\n\t// or the stack are masked like any other field; path redaction runs after\n\t// serializers, so `err.message` and `error.stack` are paths it can reach.\n\tconst serializeError = (value: unknown) => {\n\t\tconst serialized = stdSerializers.err(value as Error);\n\t\tif (!redact || serialized === value) return serialized;\n\t\treturn redactUrlCredentialsIn({ ...serialized });\n\t};\n\n\tconst pinoOptions = {\n\t\t...baseOptions,\n\t\t...(options.level && { level: options.level }),\n\t\t...(redact && { redact }),\n\t\tserializers: { err: serializeError, error: serializeError },\n\t\thooks: {\n\t\t\t// Redaction also masks the credentials of any URL, in any field or\n\t\t\t// in the message: `s3://KEY:SECRET@uploads` is logged with its\n\t\t\t// secret under a name no path list can predict.\n\t\t\t...(redact && {\n\t\t\t\tlogMethod(this: Logger, args: Parameters<LogFn>, method: LogFn) {\n\t\t\t\t\tconst redacted = args.map((arg) =>\n\t\t\t\t\t\ttypeof arg === 'string' ? redactUrlCredentials(arg) : arg,\n\t\t\t\t\t) as Parameters<LogFn>;\n\t\t\t\t\treturn method.apply(this, redacted);\n\t\t\t\t},\n\t\t\t}),\n\t\t\t// Each line, once redacted and serialized, also goes to\n\t\t\t// OpenTelemetry when a LoggerProvider is registered. On the calling\n\t\t\t// thread, before any transport, so the active span is the caller's.\n\t\t\tstreamWrite: otelStreamWrite,\n\t\t},\n\t\tformatters: {\n\t\t\t...(redact && {\n\t\t\t\tlog: (object: Record<string, unknown>) =>\n\t\t\t\t\tredactUrlCredentialsIn(object),\n\t\t\t}),\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+DA,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;CAUjD,MAAM,kBAAkB,UAAmB;EAC1C,MAAM,aAAaC,KAAAA,eAAe,IAAI,KAAc;EACpD,IAAI,CAAC,UAAU,eAAe,OAAO,OAAO;EAC5C,OAAOC,qBAAAA,uBAAuB,EAAE,GAAG,WAAW,CAAC;CAChD;CAEA,MAAM,cAAc;EACnB,GAAG;EACH,GAAI,QAAQ,SAAS,EAAE,OAAO,QAAQ,MAAM;EAC5C,GAAI,UAAU,EAAE,OAAO;EACvB,aAAa;GAAE,KAAK;GAAgB,OAAO;EAAe;EAC1D,OAAO;GAIN,GAAI,UAAU,EACb,UAAwB,MAAyB,QAAe;IAC/D,MAAM,WAAW,KAAK,KAAK,QAC1B,OAAO,QAAQ,WAAWC,qBAAAA,qBAAqB,GAAG,IAAI,GACvD;IACA,OAAO,OAAO,MAAM,MAAM,QAAQ;GACnC,EACD;GAIA,aAAaC,aAAAA;EACd;EACA,YAAY;GACX,GAAI,UAAU,EACb,MAAM,WACLF,qBAAAA,uBAAuB,MAAM,EAC/B;GACA,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"}
1
+ {"version":3,"file":"pino.cjs","names":["redact: boolean | RedactOptions | undefined","DEFAULT_REDACT_PATHS","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 { 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 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\tredact: boolean | RedactOptions | undefined,\n): PinoRedactConfig | undefined {\n\tif (redact === undefined || redact === false) {\n\t\treturn undefined;\n\t}\n\n\tif (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\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\t// @ts-expect-error\n\tconst pretty = options?.pretty && process.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\treturn pino({\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) => {\n\t\t\t\treturn { level: label.toUpperCase() };\n\t\t\t},\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqDA,SAAS,oBACRA,QAC+B;AAC/B,KAAI,qBAAwB,WAAW,MACtC;AAGD,KAAI,WAAW,KACd,QAAOC;AAIR,KAAI,MAAM,QAAQ,OAAO,CACxB,QAAO,CAAC,GAAGA,2CAAsB,GAAG,MAAO;CAI5C,MAAM,EAAE,aAAa,SAAS,OAAO,QAAQ,QAAQ,GAAG;CAExD,MAAM,gBACL,eAAe,aAAa,QAAQ,CAAC,GAAGA,2CAAsB,GAAG,KAAM;CAGxE,MAAMC,SAA2B,EAAE,OAAO,cAAe;AACzD,KAAI,kBAAsB,QAAO,SAAS;AAC1C,KAAI,kBAAsB,QAAO,SAAS;AAE1C,QAAO;AACP;;;;;;;;;;;;;;;;;;;AAoBD,SAAgB,aAAaC,UAA+B,CAAE,GAAE;CAE/D,MAAM,SAAS,SAAS,UAAU,QAAQ,aAAa;CACvD,MAAM,cAAc,SACjB,EACA,WAAW;EACV,QAAQ;EACR,SAAS,EAAE,UAAU,KAAM;CAC3B,EACD,IACA,CAAE;CAEL,MAAM,SAAS,oBAAoB,QAAQ,OAAO;AAElD,QAAO,eAAK;EACX,GAAG;EACH,GAAI,QAAQ,SAAS,EAAE,OAAO,QAAQ,MAAO;EAC7C,GAAI,UAAU,EAAE,OAAQ;EACxB,YAAY;GACX,WAAW;AACV,WAAO,EAAE,aAAa,QAAQ,QAAS;GACvC;GACD,OAAO,CAAC,UAAU;AACjB,WAAO,EAAE,OAAO,MAAM,aAAa,CAAE;GACrC;EACD;CACD,EAAC;AACF"}