List of usage examples for org.apache.maven.plugin.logging Log debug
void debug(Throwable error);
From source file:com.rabbitstewdio.build.maven.tomcat.ClasspathServlet.java
License:Apache License
public ClasspathServlet(ClassLoader projectClassLoader, Log log) { super(log);/*from w ww. ja v a 2 s . co m*/ this.projectClassLoader = projectClassLoader; if (log.isDebugEnabled()) { log.debug("Begin Logging Classloader for " + projectClassLoader); ClassLoader cl = projectClassLoader; while (cl.getParent() != null && cl.getParent() != cl) { if (cl instanceof URLClassLoader) { URLClassLoader ucl = (URLClassLoader) cl; for (URL url : ucl.getURLs()) { log.info(" => " + url); } } log.debug("-> " + cl); cl = cl.getParent(); } log.debug("Finished Logging Classloader for " + projectClassLoader); } }
From source file:com.redhat.victims.VictimsRule.java
License:Open Source License
/** * Configure execution context based on sensible defaults and * overrides in the pom.xml configuration. * @param log// www .j a v a 2 s . c o m * @return Configured execution context * @throws EnforcerRuleException */ public ExecutionContext setupContext(Log log) throws EnforcerRuleException { ExecutionContext ctx = new ExecutionContext(); ctx.setLog(log); ctx.setSettings(new Settings()); ctx.getSettings().set(Settings.METADATA, metadata); ctx.getSettings().set(Settings.FINGERPRINT, fingerprint); ctx.getSettings().set(Settings.UPDATE_DATABASE, updates); // Only need to query using one hashing mechanism System.setProperty(VictimsConfig.Key.ALGORITHMS, "SHA512"); if (baseUrl != null) { System.setProperty(VictimsConfig.Key.URI, baseUrl); ctx.getSettings().set(VictimsConfig.Key.URI, baseUrl); } if (entryPoint != null) { System.setProperty(VictimsConfig.Key.ENTRY, entryPoint); ctx.getSettings().set(VictimsConfig.Key.URI, baseUrl); } if (jdbcDriver != null) { System.setProperty(VictimsConfig.Key.DB_DRIVER, jdbcDriver); ctx.getSettings().set(VictimsConfig.Key.DB_DRIVER, jdbcDriver); } if (jdbcUrl != null) { System.setProperty(VictimsConfig.Key.DB_URL, jdbcUrl); ctx.getSettings().set(VictimsConfig.Key.DB_URL, jdbcUrl); } if (jdbcUser != null) { System.setProperty(VictimsConfig.Key.DB_USER, jdbcUser); ctx.getSettings().set(VictimsConfig.Key.DB_USER, jdbcUser); } if (jdbcPass != null) { System.setProperty(VictimsConfig.Key.DB_PASS, jdbcPass); ctx.getSettings().set(VictimsConfig.Key.DB_PASS, "(not shown)"); } // Setup database try { ctx.setDatabase(VictimsDB.db()); } catch (VictimsException e) { log.debug(e); throw new EnforcerRuleException(e.getMessage()); } // Setup cache try { ctx.setCache(new VictimsResultCache()); } catch (VictimsException e) { log.debug(e); throw new EnforcerRuleException(e.getMessage()); } // Validate settings try { ctx.getSettings().validate(); ctx.getSettings().show(ctx.getLog()); } catch (VictimsException e) { log.debug(e); throw new EnforcerRuleException(e.getMessage()); } return ctx; }
From source file:com.redhat.victims.VictimsRule.java
License:Open Source License
/** * Updates the database according to the given configuration * @param ctx/* www. j a va 2 s . c o m*/ * @throws VictimsException */ public void updateDatabase(ExecutionContext ctx) throws VictimsException { Log log = ctx.getLog(); // Disable updates via command line -Dvictims.skip.update=true String override = System.getProperty(Settings.UPDATES_OVERRIDE); if (override != null && override.equalsIgnoreCase("true")) { log.warn("[victims-enforcer] Updates disabled via system property."); return; } VictimsDBInterface db = ctx.getDatabase(); Date updated = db.lastUpdated(); // update automatically every time if (ctx.updateAlways()) { log.info(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(), VictimsConfig.uri())); db.synchronize(); // update once per day } else if (ctx.updateDaily()) { Date today = new Date(); SimpleDateFormat cmp = new SimpleDateFormat("yyyyMMdd"); boolean updatedToday = cmp.format(today).equals(cmp.format(updated)); if (!updatedToday) { log.info(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(), VictimsConfig.uri())); db.synchronize(); } else { log.debug("[victims-enforcer] database last synchronized: " + updated.toString()); } } else if (ctx.updateWeekly()) { Date today = new Date(); SimpleDateFormat cmp = new SimpleDateFormat("yyyyw"); if (cmp.format(today).equals(cmp.format(updated))) { log.info(TextUI.fmt(Resources.INFO_UPDATES, updated.toString(), VictimsConfig.uri())); db.synchronize(); } else { log.debug("[victims-enforcer] database last synchronized: " + updated.toString()); } // updates disabled } else { log.debug("[victims-enforcer] database synchronization disabled."); } }
From source file:com.redhat.victims.VictimsRule.java
License:Open Source License
/** * This is a helper method that processes a single result that * has been executed. // w ww. j a va2s . c o m * * If any exceptions were thrown during execution they are inspected * to see if they indicate a vulnerable artifact. The result is also * added to the cache for the current execution context. * * * @param ctx - The execution context the result was generated under * @param result - The result to examine * @throws VictimsException * @throws VulnerableArtifactException * @throws EnforcerRuleException */ private void processResult(ExecutionContext ctx, Future<ArtifactStub> result) throws VictimsException, VulnerableArtifactException, EnforcerRuleException { VictimsResultCache cache = ctx.getCache(); Log log = ctx.getLog(); try { ArtifactStub checked = result.get(); if (checked != null) { log.debug("[victims-enforcer] done: " + checked.getId()); cache.add(checked.getId(), null); } } catch (InterruptedException e) { log.info(e.getMessage()); } catch (ExecutionException e) { log.debug(e); Throwable cause = e.getCause(); if (cause instanceof VulnerableArtifactException) { VulnerableArtifactException ve = (VulnerableArtifactException) cause; // cache vulnerable artifact cache.add(ve.getId(), ve.getVulnerabilites()); // Log the error and rethrow in case a fatal error log.warn(ve.getLogMessage()); throw ve; } else { throw new EnforcerRuleException(e.getCause().getMessage()); } } }
From source file:com.redhat.victims.VictimsRule.java
License:Open Source License
/** * Scan the supplied artifacts given the provided execution context. An * exception will be raised if a vulnerable artifact has been detected. * @param ctx/* w ww . j a va 2 s.c om*/ * @param artifacts * @throws EnforcerRuleException */ public void execute(ExecutionContext ctx, Set<Artifact> artifacts) throws EnforcerRuleException { VictimsResultCache cache = ctx.getCache(); Log log = ctx.getLog(); int cores = Runtime.getRuntime().availableProcessors(); ExecutorService executor = null; ExecutorCompletionService<ArtifactStub> completionService = null; List<Future<ArtifactStub>> results = null; try { // Synchronize database with victims service try { updateDatabase(ctx); } catch (VictimsException e) { log.warn("Unable to update victims database! Your CVE records might be out of date."); log.debug(e.toString()); } // Concurrently process each dependency executor = Executors.newFixedThreadPool(cores); completionService = new ExecutorCompletionService<ArtifactStub>(executor); results = new ArrayList<Future<ArtifactStub>>(); for (Artifact a : artifacts) { // Check if we've already inspected this dependency if (cache.exists(a.getId())) { HashSet<String> cves = cache.get(a.getId()); log.debug("[victims-enforcer] cached: " + a.getId()); if (!cves.isEmpty()) { VulnerableArtifactException err = new VulnerableArtifactException(a, Settings.FINGERPRINT, cves); log.warn(err.getLogMessage()); if (err.isFatal(ctx)) { throw new EnforcerRuleException(err.getErrorMessage()); } } continue; } // Not in cache process artifact results.add(completionService.submit(new VictimsCommand(ctx, a))); // Poll completion service for completed tasks to short circuit // on failure conditions. Future<ArtifactStub> result = completionService.poll(); if (result != null) { try { results.remove(result); processResult(ctx, result); } catch (VulnerableArtifactException e) { if (e.isFatal(ctx)) { // Cancel other jobs for (Future<ArtifactStub> f : results) { f.cancel(true); } throw new EnforcerRuleException(e.getErrorMessage(), e); } } } } executor.shutdown(); // Process any remaining results. for (Future<ArtifactStub> future : results) { processResult(ctx, future); } } catch (VulnerableArtifactException e) { // fatal exception if (e.isFatal(ctx)) { throw new EnforcerRuleException(e.getErrorMessage()); } } catch (VictimsException e) { log.debug(e); throw new EnforcerRuleException(e.getMessage()); } finally { if (executor != null) { executor.shutdownNow(); } } }
From source file:com.relativitas.maven.plugins.formatter.FormatterMojo.java
License:Apache License
/** * Format individual file./*w w w. j a v a 2 s . c o m*/ * * @param file * @param rc * @param hashCache * @param basedirPath * @throws IOException * @throws BadLocationException */ private void doFormatFile(File file, ResultCollector rc, Properties hashCache) throws IOException, BadLocationException { Log log = getLog(); String code = readFileAsString(file); String originalHash = md5hash(code); String canonicalPath = file.getCanonicalPath(); String path = canonicalPath.substring(getBasedirPath().length()); String cachedHash = hashCache.getProperty(path); if (cachedHash != null && cachedHash.equals(originalHash)) { rc.skippedCount++; log.debug(file.getAbsolutePath() + " is already formatted."); return; } String lineSeparator = getLineEnding(code); TextEdit te = null; try { te = getCodeFormatter().format(CodeFormatter.K_COMPILATION_UNIT + CodeFormatter.F_INCLUDE_COMMENTS, code, 0, code.length(), 0, lineSeparator); } catch (RuntimeException formatFailed) { log.debug("Formatting of " + file.getAbsolutePath() + " failed", formatFailed); } catch (MojoExecutionException e) { log.debug("Formatting of " + file.getAbsolutePath() + " failed", e); } if (te == null) { rc.skippedCount++; log.debug(file.getAbsolutePath() + " cannot be formatted. Possible cause is unmatched source/target/compliance version."); return; } IDocument doc = new Document(code); te.apply(doc); String formattedCode = doc.get(); String formattedHash = md5hash(formattedCode); if (cachedHash == null || !cachedHash.equals(formattedHash)) { hashCache.setProperty(path, formattedHash); rc.hashUpdatedCount++; if (log.isDebugEnabled()) { log.debug("Adding hash code to cachedHash for path " + path + ":" + formattedHash); } } if (originalHash.equals(formattedHash)) { rc.skippedCount++; log.debug("Equal hash code for " + path + ". Not writing result to file."); return; } writeStringToFile(formattedCode, file); rc.successCount++; }
From source file:com.sap.prd.mobile.ios.mios.EffectiveBuildSettings.java
License:Apache License
private static void debug(Log log, String message) { log.debug(EffectiveBuildSettings.class.getName() + ": " + message); }
From source file:com.slim.service.ValidateService.java
License:Apache License
/** * Prepare pattern of expressions to ignore * //from w w w .j ava 2 s. c om * @return */ private Pattern preparePattern(MavenProject project, String designerBinDir, String outputDirectory, String validationIgnoresFile, Log logger) { String lineIgnore; Pattern p = Pattern.compile(""); try { BufferedReader ignoredStream = new BufferedReader( new InputStreamReader(new FileInputStream(validationIgnoresFile))); lineIgnore = null; StringBuilder sb = new StringBuilder(); while ((lineIgnore = ignoredStream.readLine()) != null) { if (!lineIgnore.startsWith("#")) { sb.append("(?:" + lineIgnore + ")|"); } } sb.deleteCharAt(sb.length() - 1);// remove the last "|" (OR) logger.debug("Pattern to match is : " + sb.toString()); p = Pattern.compile(sb.toString()); } catch (Exception ex) { logger.warn("********************************************************************************"); logger.warn(validationIgnoresFile + " file is empty or could not be loaded. Run in debug mode to have Exception info"); logger.warn("********************************************************************************"); logger.debug(ex); } return p; }
From source file:com.sri.vt.majic.util.clean.Cleaner.java
License:Apache License
/** * Creates a new cleaner./*www.j a v a 2 s. c o m*/ * * @param log The logger to use, may be <code>null</code> to disable logging. * @param verbose Whether to perform verbose logging. */ public Cleaner(final Log log, boolean verbose) { logDebug = (log == null || !log.isDebugEnabled()) ? null : new Logger() { public void log(CharSequence message) { log.debug(message); } }; logInfo = (log == null || !log.isInfoEnabled()) ? null : new Logger() { public void log(CharSequence message) { log.info(message); } }; logWarn = (log == null || !log.isWarnEnabled()) ? null : new Logger() { public void log(CharSequence message) { log.warn(message); } }; logVerbose = verbose ? logInfo : logDebug; }
From source file:com.stratio.mojo.scala.crossbuild.ChangeVersionMojoHelper.java
License:Apache License
public static void changeProjects(final List<MavenProject> projects, final String scalaBinaryVersionProperty, final String scalaVersionProperty, final String scalaBinaryVersion, final String scalaVersion, final Log log) throws MojoExecutionException { final RewritePom rewritePom = new RewritePom(); for (final MavenProject subproject : projects) { log.debug("Rewriting " + subproject.getFile()); try {/*from w w w .ja va 2s .com*/ rewritePom.rewrite(subproject, scalaBinaryVersionProperty, scalaVersionProperty, scalaBinaryVersion, scalaVersion); } catch (final IOException | XMLStreamException ex) { restoreProjects(projects); throw new MojoExecutionException("Failed to rewrite POM", ex); } } }