servoshell: allow event tracing to be configured with RUST_LOG #31657
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
RUST_LOG='servoshell<=off,servoshell>=off,servoshell<servo@'
RUST_LOG='servoshell<,servoshell>,servoshell<winit@WindowEvent(AxisMotion)=off'
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 errorsThese changes fix #___ (GitHub issue number if applicable)