Skip to content
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

Merged

Conversation

paullatzelsperger
Copy link
Member

@paullatzelsperger paullatzelsperger commented Mar 28, 2024

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 to docker run.

Why it does that

Better readability.

Further notes

I had considered several ways to toggle the coloring:

  1. using a config property: does not work properly, because the default ConsoleMonitor is instantiated before the ServiceExtensionContext, so we'd have a chicken-and-egg-problem
  2. using a dedicated monitor-coloring module that contains a custom monitor. Decided against it, because I wanted to be able to toggle within the same runtime.
  3. passing a command line arg --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.

@paullatzelsperger paullatzelsperger changed the title console colors feat: console colors Mar 28, 2024
@paullatzelsperger paullatzelsperger force-pushed the feat/console_colors branch 2 times, most recently from 40cf307 to bc68872 Compare March 28, 2024 07:07
@codecov-commenter
Copy link

codecov-commenter commented Mar 28, 2024

Codecov Report

Attention: Patch coverage is 3.70370% with 26 lines in your changes are missing coverage. Please review.

Project coverage is 74.03%. Comparing base (7f20ba5) to head (60092c4).
Report is 175 commits behind head on main.

Files Patch % Lines
...va/org/eclipse/edc/spi/monitor/ConsoleMonitor.java 0.00% 21 Missing ⚠️
...a/org/eclipse/edc/boot/system/ExtensionLoader.java 0.00% 1 Missing and 1 partial ⚠️
...g/eclipse/edc/boot/system/runtime/BaseRuntime.java 33.33% 2 Missing ⚠️
...ipse/edc/junit/extensions/EdcRuntimeExtension.java 0.00% 1 Missing ⚠️

❗ 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.
📢 Have feedback on the report? Share it here.

Copy link
Member

@ndr-brt ndr-brt left a 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

@paullatzelsperger paullatzelsperger merged commit e5bf0e9 into eclipse-edc:main Mar 28, 2024
16 checks passed
@paullatzelsperger paullatzelsperger deleted the feat/console_colors branch March 28, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core feature enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants