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 monitor): Log level can be set via program arg #4476

Merged
merged 17 commits into from
Sep 24, 2024

Conversation

rafaelmag110
Copy link
Contributor

@rafaelmag110 rafaelmag110 commented Sep 13, 2024

What this PR changes/adds

This allows to set the log level of the ConsoleMonitor via program args (i.e. --log-level=INFO).

Why it does that

It was not possible to set the level.

Linked Issue(s)

Closes #4392

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are always happy to welcome new contributors ❤️ To make things easier for everyone, please make sure to follow our contribution guidelines, check if you have already signed the ECA, and relate this pull request to an existing issue or discussion.

@rafaelmag110 rafaelmag110 added the enhancement New feature or request label Sep 13, 2024
@jimmarino
Copy link
Contributor

jimmarino commented Sep 13, 2024

Setting the log level should not be done like this, particularly having BaseRuntime downcast to ConsoleMonitor. The log level can be set via a program argument. This PR can be simplified only to change ExtensionLoader.loadMonitor(..) to handle this case.

Copy link
Contributor

@jimmarino jimmarino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my comment about redoing this PR.

@rafaelmag110
Copy link
Contributor Author

So you suggest removing the config option?

@jimmarino
Copy link
Contributor

It should be set the same way the color arg is done. Only one class needs to be modified for this.

@ndr-brt ndr-brt self-requested a review September 16, 2024 07:12
@rafaelmag110
Copy link
Contributor Author

rafaelmag110 commented Sep 16, 2024

Thanks for your reviews. I do understand your points.
I'd still like the option to set the default monitor log level via a system / env property since changing the run command might not be ideal in certain situations.

I have two suggestions:
1 - Simply read from the system or environment properties using propOrEnv() on the constructor. (function link)
2 - Have a constructor that reads default monitor configs from a dedicated config file (similar to what the jdk-logger permits).

With option 2 we can easily add new configs later if we need them (i.e. like a formatter option).

We can also change the color option to be configurable that way.

@jimmarino
Copy link
Contributor

Thanks for your reviews. I do understand your points. I'd still like the option to set the default monitor log level via a system / env property since changing the run command might not be ideal in certain situations.

I have two suggestions: 1 - Simply read from the system or environment properties using propOrEnv() on the constructor. (function link) 2 - Have a constructor that reads default monitor configs from a dedicated config file (similar to what the jdk-logger permits).

With option 2 we can easily add new configs later if we need them (i.e. like a formatter option).

We can also change the color option to be configurable that way.

As I mentioned, this PR is too complex for what it needs to do. Program arguments can be sourced from environment variables for people who want to create their Docker images that way. There's no need to introduce this behavior in the codebase, and we should never introduce a dedicated configuration source such as a file. Let's keep this as simple as possible and try to only modify the single class.

@rafaelmag110
Copy link
Contributor Author

@jimmarino @paullatzelsperger @ndr-brt
Adjusted the PR as per discussed. Please review.

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.

a pair of nits, ready to go otherwise

@rafaelmag110 rafaelmag110 changed the title feat(console monitor): Log level can be set by program arg and config feat(console monitor): Log level can be set by program arg Sep 17, 2024
@rafaelmag110 rafaelmag110 changed the title feat(console monitor): Log level can be set by program arg feat(console monitor): Log level can be set via program arg Sep 17, 2024
Copy link
Member

@paullatzelsperger paullatzelsperger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nits, OK for me otherwise

rafaelmag110 and others added 2 commits September 18, 2024 08:40
Co-authored-by: Paul Latzelsperger <[email protected]>
@EnumSource
void loadMonitor_programArgsSetConsoleMonitorLogLevel(ConsoleMonitor.Level level) {

var monitor = ExtensionLoader.loadMonitor(new ArrayList<>(), ConsoleMonitor.LEVEL_PROG_ARG + "=" + level.toString());
Copy link
Member

@paullatzelsperger paullatzelsperger Sep 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also test various combinations of spaces, upper, lower case etc.:

"--log-level = INFO", "--log-level= INFO", "--log-level =INFO", "--log-level=info",...

This could also be done with a ParamterizedTest and a @ValueSource.

Not saying all of these variants should get accepted, IMO it's fine to only accept "--log-level=XYZ", but to have a definitive test and to guard against regression.

Copy link
Member

@paullatzelsperger paullatzelsperger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are getting there.

@paullatzelsperger paullatzelsperger merged commit 154dec9 into eclipse-edc:main Sep 24, 2024
21 checks passed
@rafaelmag110 rafaelmag110 deleted the set_monitor_log_level branch September 24, 2024 11:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permit ConsoleMonitor level configuration
4 participants