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

Change docker.verbose parameter to String to handle multiple logging levels #1192

Merged
merged 7 commits into from
Apr 21, 2019

Conversation

rohanKanojia
Copy link
Member

@rohanKanojia rohanKanojia commented Apr 7, 2019

Fix #917

@rohanKanojia rohanKanojia requested a review from rhuss April 7, 2019 09:22
Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Thanks ! Looks good, but I have some suggestions. See below, especially wrt/ backwards compatibility (you should still allow 'true' and 'false' as valus) + a generalization to make it easier to add more LogVerboseCategory element.

Also, don't forget to add it to the documentation.

@@ -78,7 +78,13 @@ public void info(String message, Object ... params) {

/** {@inheritDoc} */
public void verbose(String message, Object ... params) {
if (verbose) {
if (verbose != null && verbose.contains("build")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would enable this also when this parameter is set to true, so that the old behaviour with -Ddocker.verbose=true still works (and which would switch on just the 'build' verbose part).

@@ -106,7 +112,7 @@ public boolean isDebugEnabled() {
}

public boolean isVerboseEnabled() {
return verbose;
return !verbose.isEmpty();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think if you use -Ddocker.verbose=false then verbose logging should be disabled as well. Please add a check for "false", too.

* @param format verbose message format
* @param params parameter for formatting message
*/
void verboseApi(String format, Object ... params);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could we generalise this ? I.e. to add an an enum LogVerboseCategory with elements "Build" and "Api", and a verbose(LogCategory cat, String format, .... params) method ?

That would make it much easier to add more than the Api for logging.

@@ -28,7 +28,7 @@
private final String prefix;
private final boolean batchMode;

private boolean verbose;
private String verbose = "build";
Copy link
Collaborator

Choose a reason for hiding this comment

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

better call it "verboseModes" and maybe make it an array of LogVerboseCategory enums ? see below.

…PUT/DELETE to docker

Signed-off-by: Kenny MacLeod <kmacleod@atlassian.com>
Copy link
Collaborator

@rhuss rhuss left a comment

Choose a reason for hiding this comment

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

Thanks, looks good ! Two possible gotchas found, please address them and then we can merge.

* @param format verbose message format
* @param params parameter for formatting message
*/
void verbose(String format, Object ... params);
void verbose(AnsiLogger.LogVerboseCategory logVerboseCategory, String format, Object ... params);
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should move the category to this interface. It's a bad smell to have the interface to reference to one of its implementations.

this.log = log;
this.verbose = verbose;
this.isVerbose = checkBackwardVersionValues(verbose); // For backward compatibility
Copy link
Collaborator

Choose a reason for hiding this comment

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

What happens when "verbose" is null ? It doesn't look like that the code really checks this case. It should be that in this case verbose logging should be disabled.

@rhuss rhuss added this to the 0.30.0 milestone Apr 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Log more information when verbose=true
3 participants