You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(3) Composing or filtering @workleap/logging loggers for multi-destination logging
10
+
(4) Integrating @workleap/logging with LogRocket via CompositeLogger
11
+
(5) Reviewing PRs or troubleshooting @workleap/logging usage
12
+
metadata:
13
+
version: 1.1
18
14
---
19
15
20
16
# Workleap Logging (@workleap/logging)
@@ -54,44 +50,10 @@ const logger = useLogger();
54
50
(loggerasRootLogger).startScope("User signup");
55
51
```
56
52
57
-
## API Reference
53
+
## Chained Segments
58
54
59
-
### BrowserConsoleLogger
55
+
Build complex log entries by chaining segments. **Always complete the chain with a log level method** (`.debug()`, `.error()`, etc.) or nothing is output.
-`verbose`: Whether debug information should be logged. If no loggers are provided, creates with a `BrowserConsoleLogger` by default.
161
-
-`loggers`: Array of loggers to create the `CompositeLogger` with.
162
-
163
-
## LogRocket Integration
164
-
165
-
By default, LogRocket session replays exclude console output. To send log entries to LogRocket, use `LogRocketLogger` from `@workleap/telemetry` or `@workleap/logrocket`:
166
-
167
-
```ts
168
-
import { LogRocketLogger } from"@workleap/telemetry"; // or from "@workleap/logrocket"
169
-
170
-
const logger =newLogRocketLogger();
171
-
logger.debug("Application started!");
172
-
```
173
-
174
-
Use `CompositeLogger` to send logs to both browser console and LogRocket:
import { LogRocketLogger } from"@workleap/telemetry"; // or from "@workleap/logrocket"
245
-
246
-
const logger =newCompositeLogger([
247
-
newBrowserConsoleLogger({
248
-
logLevel: LogLevel.error
249
-
}),
250
-
newLogRocketLogger({
251
-
logLevel: LogLevel.debug
252
-
})
253
-
]);
254
-
```
255
-
256
-
## Log Level Guidelines
257
-
258
-
| Environment | Recommended Level |
259
-
|-------------|-------------------|
260
-
| Development |`debug`|
261
-
| Production |`information`|
262
-
263
-
## PR Review Checklist
264
-
265
-
When reviewing logging changes:
266
-
- Verify appropriate log levels (debug for diagnostics, error for failures)
267
-
- Check that errors include context (withObject) and stack traces (withError)
268
-
- Ensure scopes are properly ended (end() or end({ dismiss: true }))
269
-
- Confirm no sensitive data in log messages
270
-
- Verify CompositeLogger filters are set per environment
271
-
272
65
## Common Mistakes
273
66
274
67
1.**Forgetting to call log method**: Chained segments require `.debug()`, `.error()`, etc. to output
@@ -277,3 +70,14 @@ When reviewing logging changes:
277
70
4.**Logging sensitive data**: Never log passwords, tokens, or PII
278
71
5.**Missing error context**: Always include `withObject()` for relevant data and `withError()` for exceptions
279
72
6.**Calling startScope on a non-RootLogger**: Only `RootLogger` instances can start scopes. When using `useLogger()` from Squide, cast to `RootLogger` first: `(logger as RootLogger).startScope("Label")`
73
+
74
+
## Reference Guide
75
+
76
+
For detailed documentation beyond the patterns above, consult:
77
+
78
+
-**`references/api.md`** — Logger constructors, all methods (styled text, line breaks), scope API, createCompositeLogger, log level guidelines
Body budget: ~75 lines. API details and common patterns moved to references/ since they are single-function examples and straightforward procedural content. Core concepts, chained segments, and common mistakes retained as they are the primary use cases and non-obvious pitfalls. New content goes in the appropriate `references/` file — only add to the body if it is a critical pattern needed in nearly every conversation.
0 commit comments