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

Improve context in diagnostic logs #73

Merged
merged 1 commit into from
Jun 14, 2019
Merged

Conversation

justinharringa
Copy link
Contributor

Will add context for each change. Overall, there were some confusing strings and it seems useful to log some of these things near their locus of error.

@justinharringa justinharringa requested a review from afalko as a code owner June 8, 2019 15:46
@@ -72,13 +72,13 @@ public void execute(final Namespace ns, final DockerfileGitHubUtil dockerfileGit
changeDockerfiles(ns, pathToDockerfilesInParentRepo, imagesFoundInParentRepo, imageToTagMap, currUserRepo,
skippedRepos);
} catch (IOException e) {
log.error(String.format("Error changing Dockerfile for %s", currUserRepo.getName()), e);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seems advantageous to go ahead and log this immediately to be able to envision flow a bit.

exceptions.add(e);
}
}

if (!exceptions.isEmpty()) {
log.info("There were {} errors with changing Dockerfiles.", exceptions.size());
throw exceptions.get(0);
throw new IOException(String.format("There were %s errors with changing Dockerfiles.", exceptions.size()));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not stuck on this approach but it seemed odd to log the message and then just throw the first exception.

@@ -142,7 +142,7 @@ protected void loadDockerfileGithubUtil(DockerfileGitHubUtil _dockerfileGitHubUt
}
}

log.info("Path to Dockerfiles in repo '{}': {}", parentRepoName, pathToDockerfilesInParentRepo);
log.info("Path to Dockerfiles in repos: {}", pathToDockerfilesInParentRepo);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

parentRepoName was the last repo (which doesn't really make sense when you're printing something for all of the repos.

@@ -167,7 +167,7 @@ public GHContent tryRetrievingContent(GHRepository repo, String path, String bra
boolean listOfReposHasRecentForks = true;
for (String s : pathToDockerfileInParentRepo.keySet()) {
String forkName = s.substring(s.lastIndexOf('/') + 1);
log.info(forkName);
log.info(String.format("Verifying that %s has been forked", forkName));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

No context

@justinharringa justinharringa requested a review from npwolf June 8, 2019 15:48
@coveralls
Copy link

coveralls commented Jun 8, 2019

Coverage Status

Coverage remained the same at 71.812% when pulling 0867228 on improve-diagnostic-logs into 5aac8c9 on master.

@justinharringa justinharringa force-pushed the improve-diagnostic-logs branch from b0aff97 to 21a902c Compare June 10, 2019 19:16
@justinharringa justinharringa force-pushed the improve-diagnostic-logs branch from 21a902c to 0867228 Compare June 12, 2019 17:35
@justinharringa
Copy link
Contributor Author

@afalko any objections?

Copy link
Collaborator

@afalko afalko left a comment

Choose a reason for hiding this comment

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

Good change!

@afalko afalko merged commit 3bf9996 into master Jun 14, 2019
@justinharringa justinharringa deleted the improve-diagnostic-logs branch June 14, 2019 04:21
@justinharringa justinharringa added the improvement New features and improvements label Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement New features and improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants