Skip to content

Commit

Permalink
Merge pull request #46 from snyk/feat/reduce-logging
Browse files Browse the repository at this point in the history
feat: reduce logging and use debug levels
  • Loading branch information
Jahed Ahmed committed Aug 10, 2021
2 parents 99af286 + a1b5b21 commit e522f65
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 10 additions & 4 deletions core/src/main/java/io/snyk/plugins/artifactory/SnykPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import javax.annotation.Nonnull;
import java.io.File;
import java.util.Optional;
import java.util.Properties;

import io.snyk.plugins.artifactory.audit.AuditModule;
Expand Down Expand Up @@ -91,15 +92,20 @@ public void handleBeforeDownloadEvent(RepoPath repoPath) {
try {
scannerModule.scanArtifact(repoPath);
} catch (CannotScanException e) {
LOG.warn("Artifact cannot be scanned {}. {}", repoPath, e.getMessage());
LOG.debug("Artifact cannot be scanned {}. {}", repoPath, e.getMessage());
} catch (SnykAPIFailureException e) {
final String blockOnApiFailurePropertyKey = SCANNER_BLOCK_ON_API_FAILURE.propertyKey();
final String blockOnApiFailure = configurationModule.getPropertyOrDefault(SCANNER_BLOCK_ON_API_FAILURE);
String message = "Failed to scan artifact '" + repoPath + "'. " + e.getMessage();
final String causeMessage = Optional.ofNullable(e.getCause())
.map(Throwable::getMessage)
.map(m -> " " + m)
.orElse("");

String message = "Failed to scan artifact '" + repoPath + "'. " + e.getMessage() + causeMessage;
if ("true".equals(blockOnApiFailure)) {
throw new CancelException(message, e, 500);
throw new CancelException(message, 500);
}
LOG.warn(message, e);
LOG.debug(message);
LOG.debug("Property '{}' is false, so allowing download: '{}'", blockOnApiFailurePropertyKey, repoPath);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ public static String getArtifactDetailsURL(String groupID, String artifactID, St
}

public TestResult scan(FileLayoutInfo fileLayoutInfo, RepoPath repoPath) {
if (!fileLayoutInfo.isValid()) {
LOG.warn("Artifact '{}' file layout info is not valid.", repoPath);
}

String groupID = Optional.ofNullable(fileLayoutInfo.getOrganization())
.orElseThrow(() -> new CannotScanException("Group ID not provided."));
String artifactID = Optional.ofNullable(fileLayoutInfo.getModule())
Expand Down

0 comments on commit e522f65

Please sign in to comment.