Repository navigation
Add LoggerColorBehavior - #40221
Add LoggerColorBehavior#40221
Conversation
|
Tagging subscribers to this area: @maryamariyan |
|
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
0cf1e17 to
37d37ac
Compare
eerhardt
left a comment
There was a problem hiding this comment.
Looks good. Just a few minor clean ups and I think this is ready to merge.
tarekgh
left a comment
There was a problem hiding this comment.
I put a little suggestions, other than that LGTM.
Note on LoggerColorBehavior usage:The intention behind LoggerColorBehavior is to provide formatters with a way to configure when ANSI color encoding is allowed to get padded around logged messages. Therefore, if the log message itself contains some ANSI color codes, that gets logged as-is and LoggerColorBehavior is NOT designed/meant to remove that. Sample usage:The gist sample here implements a custom formatter that does color formatting conditioned by LoggerColorBehavior. Compare that against the built-in implementation of SimpleConsoleFormatter, which skips color coding for log level here: Hence, color coding logic within either formatters may be disabled using LoggerColorBehavior, but a call like: logger.LogInformation("Random log \x1B[42mwith green background\x1B[49m message");using either loggers will not strip out the padded color codes "\x1B[42m" and "\x1B[49m" within the message itself. |
Fixes: #37421
cc: @eerhardt @davidfowl @tarekgh