Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

servoshell: allow event tracing to be configured with RUST_LOG #31657

Merged
merged 5 commits into from Mar 14, 2024

Conversation

delan
Copy link
Member

@delan delan commented Mar 14, 2024

To make debugging easier, servoshell logs events from winit, from servo, and to servo, but the output of these logs can be so noisy as to be unusable, unless we reconfigure which event types are logged at compile time.

We use log and env_logger, which allows runtime configuration with RUST_LOG, but by default, while you can filter logs by module path or filter them to only messages that match a regex, you can’t filter them to exclude messages by regex. Custom targets allow us to key our logs on an arbitrary string (as long as it doesn’t contain ,=/).

This patch sets custom targets on servoshell’s event tracing logs, allowing them to be filtered by RUST_LOG. The targets are of the form “servoshell<[source]@[event]” or “servoshell>[destination]@[event]”. For example:

  • to trace only events from servo:
    RUST_LOG='servoshell<=off,servoshell>=off,servoshell<servo@'
  • to trace all events except for AxisMotion events:
    RUST_LOG='servoshell<,servoshell>,servoshell<winit@WindowEvent(AxisMotion)=off'
  • to trace only winit window moved events:
    RUST_LOG='servoshell<=off,servoshell>=off,servoshell<winit@WindowEvent(Moved)'

You can get a very usable setup that traces most unusual events with:

RUST_LOG='warn,servoshell<,servoshell>,servoshell<winit@DeviceEvent=off,servoshell<winit@MainEventsCleared=off,servoshell<winit@NewEvents(WaitCancelled)=off,servoshell<winit@RedrawEventsCleared=off,servoshell<winit@RedrawRequested=off,servoshell<winit@UserEvent(WakerEvent)=off,servoshell<winit@WindowEvent(CursorMoved)=off,servoshell<winit@WindowEvent(AxisMotion)=off,servoshell<servo@EventDelivered=off,servoshell<servo@ReadyToPresent=off,servoshell>servo@Idle=off,servoshell>servo@MouseWindowMoveEventClass=off'


  • ./mach build -d does not report any errors
  • ./mach test-tidy does not report any errors
  • These changes fix #___ (GitHub issue number if applicable)
  • There are tests for these changes OR
  • These changes do not require tests because they only affect debug logging

@delan delan requested a review from atbrakhi March 14, 2024 08:15
Copy link
Member

@mrobinson mrobinson left a comment

Choose a reason for hiding this comment

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

Seems pretty reasonable. My only doubts are about the names (typical, I know 😅).

ports/servoshell/tracing.rs Outdated Show resolved Hide resolved
ports/servoshell/webview.rs Outdated Show resolved Hide resolved
ports/servoshell/webview.rs Outdated Show resolved Hide resolved
@delan delan enabled auto-merge March 14, 2024 09:03
@delan delan added this pull request to the merge queue Mar 14, 2024
Merged via the queue into main with commit eaa800c Mar 14, 2024
9 checks passed
@delan delan deleted the servoshell-event-tracing branch March 14, 2024 10:37
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.

None yet

2 participants