@logickernel/logger 0.10.4 → 0.10.5
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 +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -32,7 +32,7 @@ log.warning("disk space low", { used: "92%", mount: "/data" });
|
|
|
32
32
|
- **Full severity ladder**: `debug`, `info`, `notice`, `warning`, `error`, `critical`, `alert`, `emergency`.
|
|
33
33
|
- **Structured context**: Pass a plain object as the second argument — it becomes a `jsonPayload` in GCP (queryable by field) and inline JSON in the console.
|
|
34
34
|
- **Scope**: `logger("name")` attaches a `scope` label to every entry, great for filtering by component.
|
|
35
|
-
- **Per-call labels**: Pass a third argument to attach GCP labels to a single entry (e.g. `
|
|
35
|
+
- **Per-call labels**: Pass a third argument to attach GCP labels to a single entry (e.g. `provider`, `region`, `method`).
|
|
36
36
|
|
|
37
37
|
---
|
|
38
38
|
|
|
@@ -63,7 +63,7 @@ const apiLog = logger("api");
|
|
|
63
63
|
apiLog.info("request handled", { method: "GET", status: 200 });
|
|
64
64
|
|
|
65
65
|
// Per-call labels — merged with scope and env labels for that entry only
|
|
66
|
-
apiLog.info("request handled", {
|
|
66
|
+
apiLog.info("request handled", { ms: 42, status: 200 }, { method: "GET", route: "/users" });
|
|
67
67
|
```
|
|
68
68
|
|
|
69
69
|
`logger(scope?)` returns a `Logger` instance. Call it once per module or service boundary. The backend (GCP or console) is chosen once at module load:
|
|
@@ -122,8 +122,8 @@ log.info("request complete", { method: "GET", path: "/api/users", status: 200, m
|
|
|
122
122
|
Pass a `Record<string, string>` as the third argument to attach labels to a single entry (GCP only). They are merged with env labels and scope, with per-call values taking precedence:
|
|
123
123
|
|
|
124
124
|
```ts
|
|
125
|
-
log.info("payment processed", { amount: 99 }, {
|
|
126
|
-
// GCP entry: labels = { ...envLabels, scope: "...",
|
|
125
|
+
log.info("payment processed", { amount: 99, orderId: "o-4421" }, { provider: "stripe", currency: "usd" });
|
|
126
|
+
// GCP entry: labels = { ...envLabels, scope: "...", provider: "stripe", currency: "usd" }
|
|
127
127
|
```
|
|
128
128
|
|
|
129
129
|
### Console format
|