-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
[dotnet] Make internal console writer more flexible via taking TextWriter only #15346
[dotnet] Make internal console writer more flexible via taking TextWriter only #15346
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
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.
Having the TextWriterHandler
is a good idea, however the existing ConsoleLogHandler
is used by users. We would need to keep a type that just points to the text writer handler:
public class ConsoleLogHandler : TestWriterHandler(Console.Error);
Additionally, TestWriterHandler(Console.Error)
is not the same as ConsoleLogHandler
if a user uses the Console.SetError
method. The current code would point to whatever the new Console.Error
pointed to, but this PR would still point to the old sink.
True, and it is still good. As a low-level library we want to give user a power. Since this is "internal/advanced" thing, I am OK with this behavior.
OK, let's keep it and proceed via standard deprecation policy. Thank you, it is really better than just break. |
User description
Console
is an output. We can be more extendable/abstract/generic.Motivation and Context
Taking minimal required.
Types of changes
Checklist
PR Type
Enhancement
Description
Replaced
ConsoleLogHandler
withTextWriterHandler
for flexibility.Updated
LogContextManager
to useTextWriterHandler
.Modified logging tests to reflect the new handler.
Improved abstraction by utilizing
TextWriter
for log output.Changes walkthrough 📝
LogContextManager.cs
Refactored LogContextManager to use TextWriterHandler
dotnet/src/webdriver/Internal/Logging/LogContextManager.cs
ConsoleLogHandler
withTextWriterHandler
.GlobalContext
initialization to use the new handler.AsyncLocal
initialization syntax.TextWriterHandler.cs
Introduced TextWriterHandler for flexible log output
dotnet/src/webdriver/Internal/Logging/TextWriterHandler.cs
ConsoleLogHandler
toTextWriterHandler
.Console.Error
with aTextWriter
parameter.TextWriter
.LogTest.cs
Updated logging tests for TextWriterHandler
dotnet/test/common/Internal/Logging/LogTest.cs
TextWriterHandler
instead ofConsoleLogHandler
.