-
Notifications
You must be signed in to change notification settings - Fork 232
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
feat: console colors #4058
feat: console colors #4058
Conversation
40cf307
to
bc68872
Compare
bc68872
to
efd52b4
Compare
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #4058 +/- ##
==========================================
+ Coverage 71.74% 74.03% +2.29%
==========================================
Files 919 989 +70
Lines 18457 20098 +1641
Branches 1037 1124 +87
==========================================
+ Hits 13242 14880 +1638
+ Misses 4756 4738 -18
- Partials 459 480 +21 ☔ View full report in Codecov by Sentry. |
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.
just nits, all good otherwise
What this PR changes/adds
This PR adds colored console output to the
ConsoleMonitor
. This is achieved by inserting special unicode characters before log lines to access ANSI coloring.Note that the actual color depends on the color configuration in your terminal.
This behaviour is on by default, and it can be deactivated by passing the
--no-color
command line argument. This might be useful in certain environments, for example running in clustered environments, where log tools like stern are used, that do coloring on their own.Also, some docker base images may not print colored output correctly, depending on the shell they use. There are ways to mitigate it, e.g. using the
tty: true
property in docker-compose, or passing the--it
parameter todocker run
.Why it does that
Better readability.
Further notes
I had considered several ways to toggle the coloring:
ConsoleMonitor
is instantiated before theServiceExtensionContext
, so we'd have a chicken-and-egg-problemmonitor-coloring
module that contains a custom monitor. Decided against it, because I wanted to be able to toggle within the same runtime.--no-color
. Needs to be implemented by the runtime base class, but has the least impact on the code base. Also, central configuration of the monitor in test runtimes was possible.Linked Issue(s)
Closes # <-- insert Issue number if one exists
Please be sure to take a look at the contributing guidelines and our etiquette for pull requests.