@warlock.js/logger 5.30.0 → 5.32.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 (69) hide show
  1. package/CHANGELOG.md +32 -5
  2. package/README.md +8 -11
  3. package/cjs/index.cjs +339 -31
  4. package/cjs/index.cjs.map +1 -1
  5. package/esm/channels/console-log.d.mts +2 -4
  6. package/esm/channels/console-log.d.mts.map +1 -1
  7. package/esm/channels/console-log.mjs.map +1 -1
  8. package/esm/channels/file-log.d.mts +130 -15
  9. package/esm/channels/file-log.d.mts.map +1 -1
  10. package/esm/channels/file-log.mjs +204 -23
  11. package/esm/channels/file-log.mjs.map +1 -1
  12. package/esm/channels/file-name-pattern.d.mts +15 -0
  13. package/esm/channels/file-name-pattern.d.mts.map +1 -0
  14. package/esm/channels/file-name-pattern.mjs +41 -0
  15. package/esm/channels/file-name-pattern.mjs.map +1 -0
  16. package/esm/channels/index.mjs +2 -2
  17. package/esm/channels/json-file-log.d.mts +1 -3
  18. package/esm/channels/json-file-log.d.mts.map +1 -1
  19. package/esm/channels/json-file-log.mjs +24 -5
  20. package/esm/channels/json-file-log.mjs.map +1 -1
  21. package/esm/channels/sentry-log.d.mts +7 -8
  22. package/esm/channels/sentry-log.d.mts.map +1 -1
  23. package/esm/channels/sentry-log.mjs.map +1 -1
  24. package/esm/index.d.mts +5 -3
  25. package/esm/index.mjs +3 -2
  26. package/esm/log-channel.d.mts +23 -3
  27. package/esm/log-channel.d.mts.map +1 -1
  28. package/esm/log-channel.mjs +22 -0
  29. package/esm/log-channel.mjs.map +1 -1
  30. package/esm/logger.d.mts +8 -5
  31. package/esm/logger.d.mts.map +1 -1
  32. package/esm/logger.mjs +12 -3
  33. package/esm/logger.mjs.map +1 -1
  34. package/esm/redact/default-keys.d.mts +3 -4
  35. package/esm/redact/default-keys.d.mts.map +1 -1
  36. package/esm/redact/escape-log-value.d.mts +25 -0
  37. package/esm/redact/escape-log-value.d.mts.map +1 -0
  38. package/esm/redact/escape-log-value.mjs +37 -0
  39. package/esm/redact/escape-log-value.mjs.map +1 -0
  40. package/esm/redact/index.mjs +2 -1
  41. package/esm/redact/mask-email.d.mts +3 -4
  42. package/esm/redact/mask-email.d.mts.map +1 -1
  43. package/esm/redact/redact.d.mts +3 -5
  44. package/esm/redact/redact.d.mts.map +1 -1
  45. package/esm/redact/redact.mjs.map +1 -1
  46. package/esm/types.d.mts +14 -14
  47. package/esm/types.d.mts.map +1 -1
  48. package/esm/utils/capture-unhandled-errors.d.mts +2 -3
  49. package/esm/utils/capture-unhandled-errors.d.mts.map +1 -1
  50. package/esm/utils/clear-message.d.mts +1 -2
  51. package/esm/utils/clear-message.d.mts.map +1 -1
  52. package/esm/utils/index.mjs +1 -1
  53. package/esm/utils/safe-json-stringify.d.mts +1 -2
  54. package/esm/utils/safe-json-stringify.d.mts.map +1 -1
  55. package/llms-full.txt +241 -141
  56. package/llms.txt +2 -2
  57. package/package.json +2 -2
  58. package/skills/capture-unhandled-errors/SKILL.md +9 -10
  59. package/skills/configure-logger/SKILL.md +7 -10
  60. package/skills/filter-log-entries/SKILL.md +2 -2
  61. package/skills/flush-logs-on-shutdown/SKILL.md +32 -13
  62. package/skills/index.md +4 -1
  63. package/skills/logger-basics/SKILL.md +18 -21
  64. package/skills/overview/SKILL.md +17 -6
  65. package/skills/pick-log-channel/SKILL.md +36 -24
  66. package/skills/redact-sensitive-log-fields/SKILL.md +48 -18
  67. package/skills/ship-logs-to-sentry/SKILL.md +18 -18
  68. package/skills/test-logging-code/SKILL.md +4 -2
  69. package/skills/write-custom-log-channel/SKILL.md +50 -17
package/esm/types.d.mts CHANGED
@@ -8,7 +8,7 @@
8
8
  * - `error` — handled failure; the app continues
9
9
  * - `fatal` — unrecoverable failure; the app is going down
10
10
  */
11
- type LogLevel = "debug" | "info" | "warn" | "error" | "success" | "fatal";
11
+ export type LogLevel = "debug" | "info" | "warn" | "error" | "success" | "fatal";
12
12
  /**
13
13
  * Process-level events that `Logger.enableAutoFlush()` can hook to drain
14
14
  * buffered channels before the process terminates.
@@ -17,14 +17,14 @@ type LogLevel = "debug" | "info" | "warn" | "error" | "success" | "fatal";
17
17
  * then re-raised so Node's default exit behavior runs.
18
18
  * - `beforeExit` is flushed in place — Node exits on its own afterwards.
19
19
  */
20
- type AutoFlushEvent = "SIGINT" | "SIGTERM" | "SIGHUP" | "SIGBREAK" | "SIGUSR2" | "beforeExit";
21
- type DebugMode = "daily" | "monthly" | "yearly" | "hourly";
20
+ export type AutoFlushEvent = "SIGINT" | "SIGTERM" | "SIGHUP" | "SIGBREAK" | "SIGUSR2" | "beforeExit";
21
+ export type DebugMode = "daily" | "monthly" | "yearly" | "hourly";
22
22
  /**
23
23
  * Replacement value used by `RedactConfig`. Either a literal string
24
24
  * (e.g. `"[REDACTED]"`) or a function that receives the original value plus
25
25
  * the dotted path it sits at and returns whatever should replace it.
26
26
  */
27
- type RedactCensor = string | ((value: any, path: string) => any);
27
+ export type RedactCensor = string | ((value: any, path: string) => any);
28
28
  /**
29
29
  * Strip sensitive fields from log entries before they reach a channel.
30
30
  *
@@ -62,7 +62,7 @@ type RedactCensor = string | ((value: any, path: string) => any);
62
62
  * },
63
63
  * });
64
64
  */
65
- type RedactConfig = {
65
+ export type RedactConfig = {
66
66
  /**
67
67
  * Glob path patterns to redact. Paths are evaluated against the full
68
68
  * `LoggingData` object — so prefix with `context.` or `message.` to scope
@@ -100,7 +100,7 @@ type RedactConfig = {
100
100
  */
101
101
  censor?: RedactCensor;
102
102
  };
103
- type BasicLogConfigurations = {
103
+ export type BasicLogConfigurations = {
104
104
  /**
105
105
  * Set what level of logs should be logged
106
106
  *
@@ -130,7 +130,7 @@ type BasicLogConfigurations = {
130
130
  */
131
131
  redact?: RedactConfig;
132
132
  };
133
- type LogMessage = {
133
+ export type LogMessage = {
134
134
  content: string;
135
135
  level: LogLevel;
136
136
  date: string;
@@ -140,7 +140,7 @@ type LogMessage = {
140
140
  context?: Record<string, any>;
141
141
  timestamp?: string;
142
142
  };
143
- interface LogContract {
143
+ export interface LogContract {
144
144
  /**
145
145
  * Channel name
146
146
  */
@@ -171,19 +171,19 @@ interface LogContract {
171
171
  }
172
172
  /**
173
173
  * Receives a channel's delivery failure: a synchronous throw from its `log()`
174
- * or a rejection of the promise it returned, a redaction that threw, or a
175
- * `flush()` that timed out. Set with `Logger.onChannelError()` or
174
+ * or a rejection of the promise it returned, a redaction that threw, a
175
+ * `flush()` that timed out, or a channel's own background failure (such as
176
+ * `FileLog` retention failing to remove a file). Set with `Logger.onChannelError()` or
176
177
  * `configure({ onChannelError })`. It may be async; a rejection is swallowed.
177
178
  */
178
- type ChannelErrorHandler = (error: unknown, channel: LogContract, entry: LoggingData) => void | Promise<void>;
179
- type LoggingData = {
179
+ export type ChannelErrorHandler = (error: unknown, channel: LogContract, entry: LoggingData) => void | Promise<void>;
180
+ export type LoggingData = {
180
181
  type: LogLevel;
181
182
  module: string;
182
183
  action: string;
183
184
  message: any;
184
185
  context?: Record<string, any>;
185
186
  };
186
- type OmittedLoggingData = Omit<LoggingData, "type">;
187
+ export type OmittedLoggingData = Omit<LoggingData, "type">;
187
188
  //#endregion
188
- export { AutoFlushEvent, BasicLogConfigurations, ChannelErrorHandler, DebugMode, LogContract, LogLevel, LogMessage, LoggingData, OmittedLoggingData, RedactCensor, RedactConfig };
189
189
  //# sourceMappingURL=types.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","names":[],"sources":["../../../../../../../packages/logger/src/types.ts"],"mappings":";;AASA;;;;AAAoB;AAUpB;;;KAVY,QAAA;AAUc;AAQ1B;;;;AAAqB;AAOrB;;AAf0B,KAAd,cAAA;AAAA,KAQA,SAAA;AASkB;AAuC9B;;;;AAvC8B,KAFlB,YAAA,cAEN,KAAA,OAAY,IAAY;;;;;;AA2EP;AAGvB;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BuB;AAGvB;;;KAtEY,YAAA;EAuEV;;;;;;;EA/DA,KAAA;EAqEU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;EAIT;IACE;IACA;;;;;EAKF,UAAU,MAAM;;;;EAIhB,WAAW,MAAM,gBAAgB,QAAQ;;;;;;;EAOzC,SAAS;;YAGC;EACV;EACA,OAAO;EACP;EACA;EACA;EACA;EACA,UAAU;EACV;;iBAGe;;;;EAIf;;;;EAKA;;;;EAKA;;;;EAKA,IAAI,MAAM,qBAAqB;;;;;;;EAQ/B,iBAAiB;;;;EAKjB;;;;;;;;;YAUU,uBACV,gBACA,SAAS,aACT,OAAO,uBACG;YAEA;EACV,MAAM;EACN;EACA;EACA;EACA,UAAU;;YAGA,qBAAqB,KAAK"}
@@ -2,7 +2,7 @@
2
2
  /**
3
3
  * Options for {@link captureAnyUnhandledRejection}.
4
4
  */
5
- type CaptureUnhandledOptions = {
5
+ export type CaptureUnhandledOptions = {
6
6
  /**
7
7
  * Take the process down with `process.exit(1)` after an `uncaughtException`
8
8
  * is logged. Defaults to `true` — an uncaught exception leaves the process
@@ -41,7 +41,6 @@ type CaptureUnhandledOptions = {
41
41
  * captureAnyUnhandledRejection(); // exits on uncaught
42
42
  * captureAnyUnhandledRejection({ exitOnUncaughtException: false }); // dev: log only
43
43
  */
44
- declare function captureAnyUnhandledRejection(options?: CaptureUnhandledOptions): void;
44
+ export declare function captureAnyUnhandledRejection(options?: CaptureUnhandledOptions): void;
45
45
  //#endregion
46
- export { CaptureUnhandledOptions, captureAnyUnhandledRejection };
47
46
  //# sourceMappingURL=capture-unhandled-errors.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"capture-unhandled-errors.d.mts","names":[],"sources":["../../../../../../../../packages/logger/src/utils/capture-unhandled-errors.ts"],"mappings":";;AAKA;;KAAY,uBAAA;EAca;AAAA;AAkCzB;;;;AAAkF;;;;;;;EAlChF,uBAAuB;AAAA;;;;;;;;;;;;;;;;;;;;;;;;iBAkCT,4BAAA,CAA6B,OAAqC,GAA5B,uBAA4B"}
1
+ {"version":3,"file":"capture-unhandled-errors.d.mts","names":[],"sources":["../../../../../../../../packages/logger/src/utils/capture-unhandled-errors.ts"],"mappings":";;;;YAKY;;;;;;;;;;;;;;EAcV;;;;;;;;;;;;;;;;;;;;;;;;;wBAkCc,6BAA6B,UAAS"}
@@ -2,7 +2,6 @@
2
2
  /**
3
3
  * Clear message from any terminal codes
4
4
  */
5
- declare function clearMessage(message: any): any;
5
+ export declare function clearMessage(message: any): any;
6
6
  //#endregion
7
- export { clearMessage };
8
7
  //# sourceMappingURL=clear-message.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"clear-message.d.mts","names":[],"sources":["../../../../../../../../packages/logger/src/utils/clear-message.ts"],"mappings":";;AAGA;;iBAAgB,YAAA,CAAa,OAAY"}
1
+ {"version":3,"file":"clear-message.d.mts","names":[],"sources":["../../../../../../../../packages/logger/src/utils/clear-message.ts"],"mappings":";;;;wBAGgB,aAAa"}
@@ -2,4 +2,4 @@ import { safeJsonStringify } from "./safe-json-stringify.mjs";
2
2
  import { clearMessage } from "./clear-message.mjs";
3
3
  import { captureAnyUnhandledRejection } from "./capture-unhandled-errors.mjs";
4
4
 
5
- export { };
5
+ export { captureAnyUnhandledRejection, clearMessage, safeJsonStringify };
@@ -8,7 +8,6 @@
8
8
  * @example
9
9
  * await fs.promises.writeFile(filePath, safeJsonStringify(payload, 2));
10
10
  */
11
- declare function safeJsonStringify(value: unknown, space?: number): string;
11
+ export declare function safeJsonStringify(value: unknown, space?: number): string;
12
12
  //#endregion
13
- export { safeJsonStringify };
14
13
  //# sourceMappingURL=safe-json-stringify.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"safe-json-stringify.d.mts","names":[],"sources":["../../../../../../../../packages/logger/src/utils/safe-json-stringify.ts"],"mappings":";;AAyCA;;;;AAAgE;;;;iBAAhD,iBAAA,CAAkB,KAAA,WAAgB,KAAc"}
1
+ {"version":3,"file":"safe-json-stringify.d.mts","names":[],"sources":["../../../../../../../../packages/logger/src/utils/safe-json-stringify.ts"],"mappings":";;;;;;;;;;wBAyCgB,kBAAkB,gBAAgB"}