Skip to content

Improve logging foundation#1907

Open
lukasIO wants to merge 2 commits intomainfrom
lukas/logging-improvements
Open

Improve logging foundation#1907
lukasIO wants to merge 2 commits intomainfrom
lukas/logging-improvements

Conversation

@lukasIO
Copy link
Copy Markdown
Contributor

@lukasIO lukasIO commented Apr 21, 2026

No description provided.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 21, 2026

size-limit report 📦

Path Size
dist/livekit-client.esm.mjs 97.04 KB (+0.1% 🔺)
dist/livekit-client.umd.js 106.03 KB (+0.13% 🔺)

@lukasIO lukasIO marked this pull request as ready for review April 29, 2026 14:42
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 29, 2026

⚠️ No Changeset found

Latest commit: a77a1ad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@lukasIO lukasIO requested a review from 1egoman April 29, 2026 14:42
Comment thread src/logger.test.ts
expect(debugCalls).toHaveLength(1);
const [level, msg, ctx] = debugCalls[0];
expect(level).toBe(LogLevel.debug);
expect(msg).toBe('[room=foo participant=alice] hello world');
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sweet! That being said, should there be a way to turn the prefix on or off? In particular, I'm thinking that if people were capturing these logs with a tool like datadog / ELK, they'd have the rich metadata and it would get annoying maybe to see it duplicated again in the log message.

Comment thread src/logger.ts
* suitable for prepending to a log message. Returns an empty string when
* no display keys are present. Pure function — safe to unit test directly.
*/
export function formatDisplayContext(ctx: object | undefined): string {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Could it be possible to make ctx something like Partial<Record<keyof typeof DISPLAY_KEYS, unknown>> (probably broken out into a type though and not inline, and also using this in ContextProvider?). If this were done everywhere that would make the typing information a bit more robust.

Comment thread LOGGING.md
- **debug** — everything else: individual signal messages, per-ICE-
candidate, SDP, DTX/simulcast/codec negotiation, data channel
lifecycle, reconnection internal states, timing details.
- **trace** — reserved for deliberate deep dives; unused by default.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: It might be worth mentioning here what you told me in our 1:1 that loglevel's trace logs include stack traces, and that's the main reason this level isn't being used more extensively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants