@geekmidas/logger 10.0.0-alpha.10 → 10.0.0-alpha.101

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 (61) hide show
  1. package/dist/console.cjs +24 -25
  2. package/dist/console.cjs.map +1 -1
  3. package/dist/console.d.cts +4 -7
  4. package/dist/console.d.cts.map +1 -1
  5. package/dist/console.d.mts +4 -7
  6. package/dist/console.d.mts.map +1 -1
  7. package/dist/console.mjs +23 -25
  8. package/dist/console.mjs.map +1 -1
  9. package/dist/index.cjs +3 -3
  10. package/dist/index.d.cts +2 -2
  11. package/dist/index.d.mts +2 -2
  12. package/dist/index.mjs +2 -3
  13. package/dist/otel.cjs +113 -0
  14. package/dist/otel.cjs.map +1 -0
  15. package/dist/otel.d.cts +31 -0
  16. package/dist/otel.d.cts.map +1 -0
  17. package/dist/otel.d.mts +31 -0
  18. package/dist/otel.d.mts.map +1 -0
  19. package/dist/otel.mjs +110 -0
  20. package/dist/otel.mjs.map +1 -0
  21. package/dist/pino.cjs +67 -39
  22. package/dist/pino.cjs.map +1 -1
  23. package/dist/pino.d.cts +9 -12
  24. package/dist/pino.d.cts.map +1 -1
  25. package/dist/pino.d.mts +9 -12
  26. package/dist/pino.d.mts.map +1 -1
  27. package/dist/pino.mjs +66 -16
  28. package/dist/pino.mjs.map +1 -1
  29. package/dist/redact-paths.cjs +116 -2
  30. package/dist/redact-paths.cjs.map +1 -0
  31. package/dist/redact-paths.d.cts +31 -2
  32. package/dist/redact-paths.d.cts.map +1 -0
  33. package/dist/redact-paths.d.mts +31 -2
  34. package/dist/redact-paths.d.mts.map +1 -0
  35. package/dist/redact-paths.mjs +113 -2
  36. package/dist/redact-paths.mjs.map +1 -0
  37. package/dist/types.cjs +32 -2
  38. package/dist/types.cjs.map +1 -0
  39. package/dist/types.d.cts +175 -2
  40. package/dist/types.d.cts.map +1 -0
  41. package/dist/types.d.mts +175 -2
  42. package/dist/types.d.mts.map +1 -0
  43. package/dist/types.mjs +31 -2
  44. package/dist/types.mjs.map +1 -0
  45. package/package.json +22 -3
  46. package/dist/redact-paths-CsK0_uz-.d.cts +0 -19
  47. package/dist/redact-paths-CsK0_uz-.d.cts.map +0 -1
  48. package/dist/redact-paths-D07eTMlH.d.mts +0 -19
  49. package/dist/redact-paths-D07eTMlH.d.mts.map +0 -1
  50. package/dist/redact-paths-D0m0DIuQ.cjs +0 -73
  51. package/dist/redact-paths-D0m0DIuQ.cjs.map +0 -1
  52. package/dist/redact-paths-DQoIXhkS.mjs +0 -67
  53. package/dist/redact-paths-DQoIXhkS.mjs.map +0 -1
  54. package/dist/types-BDdpcrpy.d.mts +0 -166
  55. package/dist/types-BDdpcrpy.d.mts.map +0 -1
  56. package/dist/types-Dk_k2-f_.d.cts +0 -166
  57. package/dist/types-Dk_k2-f_.d.cts.map +0 -1
  58. package/dist/types-ag_0Cvbg.cjs +0 -38
  59. package/dist/types-ag_0Cvbg.cjs.map +0 -1
  60. package/dist/types-yQ6XOihF.mjs +0 -32
  61. package/dist/types-yQ6XOihF.mjs.map +0 -1
package/dist/console.cjs CHANGED
@@ -1,19 +1,20 @@
1
- const require_types = require('./types-ag_0Cvbg.cjs');
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
- [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
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 = require_types.LogLevel.Info) {
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 === require_types.LogLevel.Silent) return false;
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
- const logData$1 = {
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
- const logData = msg ? {
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), require_types.LogLevel.Trace);
69
+ trace = this.createLogFn(console.trace.bind(console), "trace");
71
70
  /** Debug level logging function */
72
- debug = this.createLogFn(console.debug.bind(console), require_types.LogLevel.Debug);
71
+ debug = this.createLogFn(console.debug.bind(console), "debug");
73
72
  /** Info level logging function */
74
- info = this.createLogFn(console.info.bind(console), require_types.LogLevel.Info);
73
+ info = this.createLogFn(console.info.bind(console), "info");
75
74
  /** Warning level logging function */
76
- warn = this.createLogFn(console.warn.bind(console), require_types.LogLevel.Warn);
75
+ warn = this.createLogFn(console.warn.bind(console), "warn");
77
76
  /** Error level logging function */
78
- error = this.createLogFn(console.error.bind(console), require_types.LogLevel.Error);
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), require_types.LogLevel.Fatal);
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 ?? require_types.LogLevel.Info);
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
@@ -1 +1 @@
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
+ {"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,7 +1,6 @@
1
- import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-Dk_k2-f_.cjs";
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
@@ -1 +1 @@
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
+ {"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,7 +1,6 @@
1
- import { CreateLoggerOptions, LogFn, LogLevel, Logger } from "./types-BDdpcrpy.mjs";
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
@@ -1 +1 @@
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"}
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 { LogLevel } from "./types-yQ6XOihF.mjs";
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
- [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
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 = LogLevel.Info) {
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 === LogLevel.Silent) return false;
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
- const logData$1 = {
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
- const logData = msg ? {
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), LogLevel.Trace);
68
+ trace = this.createLogFn(console.trace.bind(console), "trace");
71
69
  /** Debug level logging function */
72
- debug = this.createLogFn(console.debug.bind(console), LogLevel.Debug);
70
+ debug = this.createLogFn(console.debug.bind(console), "debug");
73
71
  /** Info level logging function */
74
- info = this.createLogFn(console.info.bind(console), LogLevel.Info);
72
+ info = this.createLogFn(console.info.bind(console), "info");
75
73
  /** Warning level logging function */
76
- warn = this.createLogFn(console.warn.bind(console), LogLevel.Warn);
74
+ warn = this.createLogFn(console.warn.bind(console), "warn");
77
75
  /** Error level logging function */
78
- error = this.createLogFn(console.error.bind(console), LogLevel.Error);
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), LogLevel.Fatal);
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 ?? LogLevel.Info);
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
@@ -1 +1 @@
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"}
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
- const require_types = require('./types-ag_0Cvbg.cjs');
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-Dk_k2-f_.cjs";
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-BDdpcrpy.mjs";
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-yQ6XOihF.mjs";
2
-
3
- export { LogLevel };
1
+ import { LogLevel } from "./types.mjs";
2
+ export { LogLevel };
package/dist/otel.cjs ADDED
@@ -0,0 +1,113 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _opentelemetry_api_logs = require("@opentelemetry/api-logs");
3
+ //#region src/otel.ts
4
+ /**
5
+ * The bridge from pino to OpenTelemetry logs.
6
+ *
7
+ * A pino record is also emitted through `@opentelemetry/api-logs` when a
8
+ * `LoggerProvider` is registered globally — as the generated telemetry setup
9
+ * of a production server does. Nothing hooks module loading, so it works the
10
+ * same in a single bundled file as from `node_modules`.
11
+ *
12
+ * `@opentelemetry/api-logs` keeps its provider on `globalThis` under a
13
+ * `Symbol.for` key, so the copy imported here and the copy the SDK registered
14
+ * through share one provider even when a bundle holds both. That is why the
15
+ * provider is looked up per record rather than once: a logger obtained before
16
+ * the SDK registered — or through another copy's proxy — would stay a no-op.
17
+ *
18
+ * @module
19
+ */
20
+ /** The instrumentation scope every bridged record carries. */
21
+ const OTEL_SCOPE = "@geekmidas/logger";
22
+ /** Pino's level labels, upper-cased as the logger prints them. */
23
+ const SEVERITY = {
24
+ TRACE: _opentelemetry_api_logs.SeverityNumber.TRACE,
25
+ DEBUG: _opentelemetry_api_logs.SeverityNumber.DEBUG,
26
+ INFO: _opentelemetry_api_logs.SeverityNumber.INFO,
27
+ WARN: _opentelemetry_api_logs.SeverityNumber.WARN,
28
+ ERROR: _opentelemetry_api_logs.SeverityNumber.ERROR,
29
+ FATAL: _opentelemetry_api_logs.SeverityNumber.FATAL
30
+ };
31
+ /** Pino's numeric levels, for a record whose level was not formatted. */
32
+ function severityFromNumber(level) {
33
+ if (level >= 60) return _opentelemetry_api_logs.SeverityNumber.FATAL;
34
+ if (level >= 50) return _opentelemetry_api_logs.SeverityNumber.ERROR;
35
+ if (level >= 40) return _opentelemetry_api_logs.SeverityNumber.WARN;
36
+ if (level >= 30) return _opentelemetry_api_logs.SeverityNumber.INFO;
37
+ if (level >= 20) return _opentelemetry_api_logs.SeverityNumber.DEBUG;
38
+ return _opentelemetry_api_logs.SeverityNumber.TRACE;
39
+ }
40
+ const SEVERITY_TEXT = {
41
+ [_opentelemetry_api_logs.SeverityNumber.TRACE]: "TRACE",
42
+ [_opentelemetry_api_logs.SeverityNumber.DEBUG]: "DEBUG",
43
+ [_opentelemetry_api_logs.SeverityNumber.INFO]: "INFO",
44
+ [_opentelemetry_api_logs.SeverityNumber.WARN]: "WARN",
45
+ [_opentelemetry_api_logs.SeverityNumber.ERROR]: "ERROR",
46
+ [_opentelemetry_api_logs.SeverityNumber.FATAL]: "FATAL"
47
+ };
48
+ let cached;
49
+ /** The bridge's logger from whichever provider is registered now. */
50
+ function otelLogger() {
51
+ const provider = _opentelemetry_api_logs.logs.getLoggerProvider();
52
+ if (cached?.provider !== provider) cached = {
53
+ provider,
54
+ logger: provider.getLogger(OTEL_SCOPE)
55
+ };
56
+ return cached.logger;
57
+ }
58
+ /**
59
+ * Emit one serialized pino line through OpenTelemetry, when a provider is
60
+ * registered that wants it.
61
+ *
62
+ * The line is what pino is about to write — after path redaction and the
63
+ * URL-credential redaction — so the exported copy is exactly as redacted as
64
+ * stdout. It runs synchronously inside the log call, so the active context —
65
+ * and with it the trace and span ids — is the caller's.
66
+ *
67
+ * Without a registered provider the logger is a no-op whose `enabled()` is
68
+ * false, and the line is not parsed.
69
+ */
70
+ function emitToOtel(line) {
71
+ const logger = otelLogger();
72
+ if (!logger.enabled()) return;
73
+ let record;
74
+ try {
75
+ record = JSON.parse(line);
76
+ } catch {
77
+ return;
78
+ }
79
+ const { level, time, msg, ...attributes } = record;
80
+ const severityNumber = typeof level === "number" ? severityFromNumber(level) : SEVERITY[String(level).toUpperCase()] ?? _opentelemetry_api_logs.SeverityNumber.UNSPECIFIED;
81
+ if (!logger.enabled({ severityNumber })) return;
82
+ logger.emit({
83
+ severityNumber,
84
+ severityText: SEVERITY_TEXT[severityNumber] ?? (level === void 0 ? void 0 : String(level)),
85
+ ...msg !== void 0 && { body: String(msg) },
86
+ ...typeof time === "number" && { timestamp: time },
87
+ attributes
88
+ });
89
+ }
90
+ /**
91
+ * The bridge as a pino `streamWrite` hook, for a logger made with `pino()`
92
+ * directly rather than `createLogger` — which installs it already.
93
+ *
94
+ * @example
95
+ * ```typescript
96
+ * import pino from 'pino';
97
+ * import { otelStreamWrite } from '@geekmidas/logger/otel';
98
+ *
99
+ * const logger = pino({ hooks: { streamWrite: otelStreamWrite } });
100
+ * ```
101
+ */
102
+ function otelStreamWrite(line) {
103
+ try {
104
+ emitToOtel(line);
105
+ } catch {}
106
+ return line;
107
+ }
108
+ //#endregion
109
+ exports.OTEL_SCOPE = OTEL_SCOPE;
110
+ exports.emitToOtel = emitToOtel;
111
+ exports.otelStreamWrite = otelStreamWrite;
112
+
113
+ //# sourceMappingURL=otel.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.cjs","names":["SeverityNumber","logs"],"sources":["../src/otel.ts"],"sourcesContent":["/**\n * The bridge from pino to OpenTelemetry logs.\n *\n * A pino record is also emitted through `@opentelemetry/api-logs` when a\n * `LoggerProvider` is registered globally — as the generated telemetry setup\n * of a production server does. Nothing hooks module loading, so it works the\n * same in a single bundled file as from `node_modules`.\n *\n * `@opentelemetry/api-logs` keeps its provider on `globalThis` under a\n * `Symbol.for` key, so the copy imported here and the copy the SDK registered\n * through share one provider even when a bundle holds both. That is why the\n * provider is looked up per record rather than once: a logger obtained before\n * the SDK registered — or through another copy's proxy — would stay a no-op.\n *\n * @module\n */\nimport {\n\ttype AnyValueMap,\n\ttype Logger,\n\ttype LoggerProvider,\n\tlogs,\n\tSeverityNumber,\n} from '@opentelemetry/api-logs';\n\n/** The instrumentation scope every bridged record carries. */\nexport const OTEL_SCOPE = '@geekmidas/logger';\n\n/** Pino's level labels, upper-cased as the logger prints them. */\nconst SEVERITY: Record<string, SeverityNumber> = {\n\tTRACE: SeverityNumber.TRACE,\n\tDEBUG: SeverityNumber.DEBUG,\n\tINFO: SeverityNumber.INFO,\n\tWARN: SeverityNumber.WARN,\n\tERROR: SeverityNumber.ERROR,\n\tFATAL: SeverityNumber.FATAL,\n};\n\n/** Pino's numeric levels, for a record whose level was not formatted. */\nfunction severityFromNumber(level: number): SeverityNumber {\n\tif (level >= 60) return SeverityNumber.FATAL;\n\tif (level >= 50) return SeverityNumber.ERROR;\n\tif (level >= 40) return SeverityNumber.WARN;\n\tif (level >= 30) return SeverityNumber.INFO;\n\tif (level >= 20) return SeverityNumber.DEBUG;\n\treturn SeverityNumber.TRACE;\n}\n\nconst SEVERITY_TEXT: Partial<Record<SeverityNumber, string>> = {\n\t[SeverityNumber.TRACE]: 'TRACE',\n\t[SeverityNumber.DEBUG]: 'DEBUG',\n\t[SeverityNumber.INFO]: 'INFO',\n\t[SeverityNumber.WARN]: 'WARN',\n\t[SeverityNumber.ERROR]: 'ERROR',\n\t[SeverityNumber.FATAL]: 'FATAL',\n};\n\nlet cached: { provider: LoggerProvider; logger: Logger } | undefined;\n\n/** The bridge's logger from whichever provider is registered now. */\nfunction otelLogger(): Logger {\n\tconst provider = logs.getLoggerProvider();\n\tif (cached?.provider !== provider) {\n\t\tcached = { provider, logger: provider.getLogger(OTEL_SCOPE) };\n\t}\n\treturn cached.logger;\n}\n\n/**\n * Emit one serialized pino line through OpenTelemetry, when a provider is\n * registered that wants it.\n *\n * The line is what pino is about to write — after path redaction and the\n * URL-credential redaction — so the exported copy is exactly as redacted as\n * stdout. It runs synchronously inside the log call, so the active context —\n * and with it the trace and span ids — is the caller's.\n *\n * Without a registered provider the logger is a no-op whose `enabled()` is\n * false, and the line is not parsed.\n */\nexport function emitToOtel(line: string): void {\n\tconst logger = otelLogger();\n\tif (!logger.enabled()) return;\n\n\tlet record: Record<string, unknown>;\n\ttry {\n\t\trecord = JSON.parse(line);\n\t} catch {\n\t\treturn;\n\t}\n\n\tconst { level, time, msg, ...attributes } = record;\n\tconst severityNumber =\n\t\ttypeof level === 'number'\n\t\t\t? severityFromNumber(level)\n\t\t\t: (SEVERITY[String(level).toUpperCase()] ?? SeverityNumber.UNSPECIFIED);\n\n\tif (!logger.enabled({ severityNumber })) return;\n\n\tlogger.emit({\n\t\tseverityNumber,\n\t\tseverityText:\n\t\t\tSEVERITY_TEXT[severityNumber] ??\n\t\t\t(level === undefined ? undefined : String(level)),\n\t\t...(msg !== undefined && { body: String(msg) }),\n\t\t...(typeof time === 'number' && { timestamp: time }),\n\t\tattributes: attributes as AnyValueMap,\n\t});\n}\n\n/**\n * The bridge as a pino `streamWrite` hook, for a logger made with `pino()`\n * directly rather than `createLogger` — which installs it already.\n *\n * @example\n * ```typescript\n * import pino from 'pino';\n * import { otelStreamWrite } from '@geekmidas/logger/otel';\n *\n * const logger = pino({ hooks: { streamWrite: otelStreamWrite } });\n * ```\n */\nexport function otelStreamWrite(line: string): string {\n\ttry {\n\t\temitToOtel(line);\n\t} catch {\n\t\t// Exporting a log is never a reason to lose it from stdout.\n\t}\n\treturn line;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,aAAa;;AAG1B,MAAM,WAA2C;CAChD,OAAOA,wBAAAA,eAAe;CACtB,OAAOA,wBAAAA,eAAe;CACtB,MAAMA,wBAAAA,eAAe;CACrB,MAAMA,wBAAAA,eAAe;CACrB,OAAOA,wBAAAA,eAAe;CACtB,OAAOA,wBAAAA,eAAe;AACvB;;AAGA,SAAS,mBAAmB,OAA+B;CAC1D,IAAI,SAAS,IAAI,OAAOA,wBAAAA,eAAe;CACvC,IAAI,SAAS,IAAI,OAAOA,wBAAAA,eAAe;CACvC,IAAI,SAAS,IAAI,OAAOA,wBAAAA,eAAe;CACvC,IAAI,SAAS,IAAI,OAAOA,wBAAAA,eAAe;CACvC,IAAI,SAAS,IAAI,OAAOA,wBAAAA,eAAe;CACvC,OAAOA,wBAAAA,eAAe;AACvB;AAEA,MAAM,gBAAyD;EAC7DA,wBAAAA,eAAe,QAAQ;EACvBA,wBAAAA,eAAe,QAAQ;EACvBA,wBAAAA,eAAe,OAAO;EACtBA,wBAAAA,eAAe,OAAO;EACtBA,wBAAAA,eAAe,QAAQ;EACvBA,wBAAAA,eAAe,QAAQ;AACzB;AAEA,IAAI;;AAGJ,SAAS,aAAqB;CAC7B,MAAM,WAAWC,wBAAAA,KAAK,kBAAkB;CACxC,IAAI,QAAQ,aAAa,UACxB,SAAS;EAAE;EAAU,QAAQ,SAAS,UAAU,UAAU;CAAE;CAE7D,OAAO,OAAO;AACf;;;;;;;;;;;;;AAcA,SAAgB,WAAW,MAAoB;CAC9C,MAAM,SAAS,WAAW;CAC1B,IAAI,CAAC,OAAO,QAAQ,GAAG;CAEvB,IAAI;CACJ,IAAI;EACH,SAAS,KAAK,MAAM,IAAI;CACzB,QAAQ;EACP;CACD;CAEA,MAAM,EAAE,OAAO,MAAM,KAAK,GAAG,eAAe;CAC5C,MAAM,iBACL,OAAO,UAAU,WACd,mBAAmB,KAAK,IACvB,SAAS,OAAO,KAAK,CAAC,CAAC,YAAY,MAAMD,wBAAAA,eAAe;CAE7D,IAAI,CAAC,OAAO,QAAQ,EAAE,eAAe,CAAC,GAAG;CAEzC,OAAO,KAAK;EACX;EACA,cACC,cAAc,oBACb,UAAU,KAAA,IAAY,KAAA,IAAY,OAAO,KAAK;EAChD,GAAI,QAAQ,KAAA,KAAa,EAAE,MAAM,OAAO,GAAG,EAAE;EAC7C,GAAI,OAAO,SAAS,YAAY,EAAE,WAAW,KAAK;EACtC;CACb,CAAC;AACF;;;;;;;;;;;;;AAcA,SAAgB,gBAAgB,MAAsB;CACrD,IAAI;EACH,WAAW,IAAI;CAChB,QAAQ,CAER;CACA,OAAO;AACR"}
@@ -0,0 +1,31 @@
1
+ //#region src/otel.d.ts
2
+ /** The instrumentation scope every bridged record carries. */
3
+ export declare const OTEL_SCOPE = "@geekmidas/logger";
4
+ /**
5
+ * Emit one serialized pino line through OpenTelemetry, when a provider is
6
+ * registered that wants it.
7
+ *
8
+ * The line is what pino is about to write — after path redaction and the
9
+ * URL-credential redaction — so the exported copy is exactly as redacted as
10
+ * stdout. It runs synchronously inside the log call, so the active context —
11
+ * and with it the trace and span ids — is the caller's.
12
+ *
13
+ * Without a registered provider the logger is a no-op whose `enabled()` is
14
+ * false, and the line is not parsed.
15
+ */
16
+ export declare function emitToOtel(line: string): void;
17
+ /**
18
+ * The bridge as a pino `streamWrite` hook, for a logger made with `pino()`
19
+ * directly rather than `createLogger` — which installs it already.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import pino from 'pino';
24
+ * import { otelStreamWrite } from '@geekmidas/logger/otel';
25
+ *
26
+ * const logger = pino({ hooks: { streamWrite: otelStreamWrite } });
27
+ * ```
28
+ */
29
+ export declare function otelStreamWrite(line: string): string;
30
+ //#endregion
31
+ //# sourceMappingURL=otel.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.d.cts","names":[],"sources":["../src/otel.ts"],"mappings":";;qBAyBa;;;;;;;;;;;;;wBAsDG,WAAW;;;;;;;;;;;;;wBA0CX,gBAAgB"}
@@ -0,0 +1,31 @@
1
+ //#region src/otel.d.ts
2
+ /** The instrumentation scope every bridged record carries. */
3
+ export declare const OTEL_SCOPE = "@geekmidas/logger";
4
+ /**
5
+ * Emit one serialized pino line through OpenTelemetry, when a provider is
6
+ * registered that wants it.
7
+ *
8
+ * The line is what pino is about to write — after path redaction and the
9
+ * URL-credential redaction — so the exported copy is exactly as redacted as
10
+ * stdout. It runs synchronously inside the log call, so the active context —
11
+ * and with it the trace and span ids — is the caller's.
12
+ *
13
+ * Without a registered provider the logger is a no-op whose `enabled()` is
14
+ * false, and the line is not parsed.
15
+ */
16
+ export declare function emitToOtel(line: string): void;
17
+ /**
18
+ * The bridge as a pino `streamWrite` hook, for a logger made with `pino()`
19
+ * directly rather than `createLogger` — which installs it already.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * import pino from 'pino';
24
+ * import { otelStreamWrite } from '@geekmidas/logger/otel';
25
+ *
26
+ * const logger = pino({ hooks: { streamWrite: otelStreamWrite } });
27
+ * ```
28
+ */
29
+ export declare function otelStreamWrite(line: string): string;
30
+ //#endregion
31
+ //# sourceMappingURL=otel.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"otel.d.mts","names":[],"sources":["../src/otel.ts"],"mappings":";;qBAyBa;;;;;;;;;;;;;wBAsDG,WAAW;;;;;;;;;;;;;wBA0CX,gBAAgB"}