@holz/core 0.8.3-rc.172 → 0.8.3-rc.175

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -63,7 +63,7 @@ A `Log` object contains the following properties:
63
63
  - `message`: The verbatim log message. This property should not contain any interpolated data.
64
64
  - `level`: The severity of the log message, expressed as a member of the `LogLevel` enum. The available log levels are, in increasing order of severity: `trace`, `debug`, `info`, `warn`, `error`, `fatal`.
65
65
  - `origin`: The source of the log message. This property is an array of strings that typically identifies the library, module, or component that generated the log message, followed by more specific information. This property can be used to filter and group log messages based on their origin.
66
- - `context`: A dictionary of key-value pairs that provides additional context for the log message. The values in this object must be JSON serializable. Because it's easy to accidentally include unsuitable log context, such as PII or deeply nested objects, the use of nested objects in the context is discouraged.
66
+ - `context`: A dictionary of key-value pairs that provides additional context for the log message. The values in this object must be JSON serializable, except for `error` which must be an `Error` instance.
67
67
 
68
68
  Here is an example of a log message expressed as a `Log` object:
69
69
 
@@ -42,11 +42,19 @@ predicate: (log: Log) => boolean,
42
42
  processor: LogProcessor) => LogProcessor;
43
43
 
44
44
  declare interface JsonContext {
45
- [key: string]: JsonPrimitive | ReadonlyArray<JsonPrimitive>;
45
+ [key: string]: JsonValue;
46
46
  }
47
47
 
48
48
  declare type JsonPrimitive = string | number | boolean | null | undefined;
49
49
 
50
+ /**
51
+ * Any JSON-serializable value. Supports nested objects and arrays so log
52
+ * context can carry structured data.
53
+ */
54
+ declare type JsonValue = JsonPrimitive | ReadonlyArray<JsonValue> | {
55
+ readonly [key: string]: JsonValue;
56
+ };
57
+
50
58
  export declare const level: {
51
59
  /** A critical failure happened and the program must exit. */
52
60
  readonly fatal: 60;
@@ -84,10 +92,6 @@ export declare interface Log {
84
92
  *
85
93
  * These values must be JSON serializable.
86
94
  *
87
- * Because it's easy to accidentally include unsuitable log context (e.g.
88
- * redux state, PII) nested objects are not allowed. The restriction doesn't
89
- * make it impossible, but it makes it harder to miss during code review.
90
- *
91
95
  * @example { userId: 123, reason: 'disconnect' }
92
96
  */
93
97
  readonly context: LogContext;
@@ -146,7 +150,7 @@ export declare interface LogProcessor {
146
150
  * first, then falling back to any JSON value.
147
151
  */
148
152
  declare type StrictContext<Input> = {
149
- [Key in keyof Input]: Key extends keyof CustomContext ? CustomContext[Key] : JsonPrimitive | ReadonlyArray<JsonPrimitive>;
153
+ [Key in keyof Input]: Key extends keyof CustomContext ? CustomContext[Key] : JsonValue;
150
154
  };
151
155
 
152
156
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@holz/core",
3
- "version": "0.8.3-rc.172+825de79",
3
+ "version": "0.8.3-rc.175+ed2e609",
4
4
  "description": "A structured and composable logger",
5
5
  "type": "module",
6
6
  "repository": {
@@ -44,5 +44,5 @@
44
44
  "vite-tsconfig-paths": "^6.0.0",
45
45
  "vitest": "^4.0.0"
46
46
  },
47
- "gitHead": "825de79d6a02f0f1ee2f58836d0a10c37530e538"
47
+ "gitHead": "ed2e609533740bf1ed09e46ae81ca6eba426e87f"
48
48
  }