-
Notifications
You must be signed in to change notification settings - Fork 37
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
Allow capturing logging endpoint messages #397
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That global mutex has bothered me for a long time, thank you for fixing this!
#[derive(Clone)] | ||
pub struct LogEndpoint { | ||
name: Vec<u8>, | ||
writer: Arc<Mutex<dyn Write + Send>>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this escapes out now, would it be worth adding a synonym for Arc<Mutex<dyn Write + Send>>
for readability elsewhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. While trying to decide how to answer it, I've stared at the places this is visible, and I think my answer is that it shouldn't actually be visible in most of those places. In particular, I don't think either the LogEndpoint
or Session
types should be exported. The only place library users should encounter this type is in the ExecuteCtx::with_capture_logs
method, and I don't think a type alias is necessary for that.
It's a little annoying naming this type multiple places within the library, but I think it's a little better to keep the details visible so that, for example, it's clear that using clone
is cheap.
So I guess I'm not inclined to introduce a type alias for this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reasonable!
Some integration tests need to capture log output in order to verify that logging endpoints work correctly from guests, but it's also potentially useful for people using Viceroy as a library. The previous way that the integration tests did this was not reliable when multiple tests ran in parallel, because there was only one global hook for capturing logs. Exposing this as a configuration option on execution contexts instead allows each test to set independent capture buffers. I guess this should be considered a breaking API change since `viceroy_lib::logging::LOG_WRITER` was exported publicly from the crate.
Some integration tests need to capture log output in order to verify that logging endpoints work correctly from guests, but it's also potentially useful for people using Viceroy as a library. The previous way that the integration tests did this was not reliable when multiple tests ran in parallel, because there was only one global hook for capturing logs. Exposing this as a configuration option on execution contexts instead allows each test to set independent capture buffers. I guess this should be considered a breaking API change since `viceroy_lib::logging::LOG_WRITER` was exported publicly from the crate.
Some integration tests need to capture log output in order to verify that logging endpoints work correctly from guests, but it's also potentially useful for people using Viceroy as a library.
The previous way that the integration tests did this was not reliable when multiple tests ran in parallel, because there was only one global hook for capturing logs. Exposing this as a configuration option on execution contexts instead allows each test to set independent capture buffers.
I guess this should be considered a breaking API change since
viceroy_lib::logging::LOG_WRITER
was exported publicly from the crate.