-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 colorized custom formatters by exposing TextWriterExtensions #44582
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
@ericstj I suggest adding the |
Closely related to #44513. |
Tagging subscribers to this area: @maryamariyan Issue meta data
|
Thanks @ramondeklein as @SingleAccretion recommended, because of #44513, we'd want to preferably first expose some common APIs which fit better into System.Console and remove logic out of Logging.Console accordingly. That is why we decided not to make color specific formatting and Ansi parsing APIs public in Logging.Console as it might not be the right place for it. Until those APIs are available, what I would do for custom formatting that would support colors, is to use the template gist I shared in the comment here, which basically just duplicates the same TextWriterExtensions code you shared above. If any such TextWriterExtensions APIs are needed to become public I think they should live in System.Console instead not in Logging.Console. cc @eerhardt perhaps we could dupe this as part of #44513 as well? |
This is a supporting case for adding those general ANSI APIs in System.Console. Closing as dupe. |
Note for future, there is a doc related to this topic: https://docs.microsoft.com/en-us/dotnet/core/extensions/console-log-formatter |
Background and Motivation
.NET Core 5 supports using custom console formatters, which is great to customize the logging output. Using colors is very useful for console logging to highlight important events, but each custom formatter needs to implement this.
The BCL already has a very useful TextWriterExtensions that implements colorized output, but it's internal and can't be used for custom formatters. Making this class public would make it much easier to implement a custom formatter that uses colors the correct way.
Proposed API
Make
Microsoft.Extensions.Logging.Console.TextWriterExtensions
public or make theAnsiParser
accessible.The text was updated successfully, but these errors were encountered: