org.sonar.api.utils.log.Logger.isDebugEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(146)

本文整理了Java中org.sonar.api.utils.log.Logger.isDebugEnabled()方法的一些代码示例,展示了Logger.isDebugEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.isDebugEnabled()方法的具体详情如下:
包路径:org.sonar.api.utils.log.Logger
类名称:Logger
方法名:isDebugEnabled

Logger.isDebugEnabled介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Override
public boolean isDebugEnabled() {
 return logger.isDebugEnabled();
}

代码示例来源:origin: SonarSource/sonarqube

private static void logPostJobs(Collection<PostJobWrapper> postJobs) {
  if (LOG.isDebugEnabled()) {
   LOG.debug(() -> "Post-jobs : " + postJobs.stream().map(Object::toString).collect(Collectors.joining(" -> ")));
  }
 }
}

代码示例来源:origin: SonarSource/sonarqube

public static Profiler createIfDebug(Logger logger) {
 if (logger.isDebugEnabled()) {
  return create(logger);
 }
 return NullProfiler.NULL_INSTANCE;
}

代码示例来源:origin: SonarSource/sonarqube

public static Profiler createIfDebug(Logger logger) {
 if (logger.isDebugEnabled()) {
  return create(logger);
 }
 return NullProfiler.NULL_INSTANCE;
}

代码示例来源:origin: SonarSource/sonarqube

private static boolean shouldLog(Logger logger, LoggerLevel level) {
 if (level == LoggerLevel.TRACE && !logger.isTraceEnabled()) {
  return false;
 }
 return level != LoggerLevel.DEBUG || logger.isDebugEnabled();
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * Logs a DEBUG message which is only to be constructed if the logging level
 * is such that the message will actually be logged.
 * <p>
 * DEBUG messages must
 * be valuable for diagnosing production problems. They must not be used for development debugging.
 * @param msgSupplier A function, which when called, produces the desired log message
 * @since 6.3
 */
default void debug(Supplier<String> msgSupplier) {
 if (isDebugEnabled()) {
  debug(msgSupplier.get());
 }
}

代码示例来源:origin: SonarSource/sonarqube

public void setSystemProperty(String key, String value) {
 checkKeyAndValue(key, value);
 String systemValue = systemProps.getProperty(key);
 if (LOG.isDebugEnabled() && systemValue != null && !value.equals(systemValue)) {
  LOG.debug(format("System property '%s' with value '%s' overwritten with value '%s'", key, systemValue, value));
 }
 overwrittenSystemProps.put(key, value.trim());
}

代码示例来源:origin: SonarSource/sonarqube

private static void logVisitorExecutionDurations(List<ComponentVisitor> visitors, VisitorsCrawler visitorsCrawler) {
  if (LOGGER.isDebugEnabled()) {
   LOGGER.debug("  Execution time for each component visitor:");
   Map<ComponentVisitor, Long> cumulativeDurations = visitorsCrawler.getCumulativeDurations();
   for (ComponentVisitor visitor : visitors) {
    LOGGER.debug("  - {} | time={}ms", visitor.getClass().getSimpleName(), cumulativeDurations.get(visitor));
   }
  }
 }
}

代码示例来源:origin: SonarSource/sonarqube

private List<PurgeableAnalysisDto> delete(String rootUuid, List<PurgeableAnalysisDto> snapshots, DbSession session) {
 if (LOG.isDebugEnabled()) {
  LOG.debug("<- Delete analyses of component {}: {}",
   rootUuid,
   Joiner.on(", ").join(
    snapshots.stream()
     .map(snapshot -> snapshot.getAnalysisUuid() + "@" + DateUtils.formatDateTime(snapshot.getDate()))
     .collect(MoreCollectors.toArrayList(snapshots.size()))));
 }
 purgeDao.deleteAnalyses(
  session, profiler,
  snapshots.stream().map(DefaultPeriodCleaner::toIdUuidPair).collect(MoreCollectors.toList(snapshots.size())));
 return snapshots;
}

代码示例来源:origin: SonarSource/sonarqube

private static void logPaths(String label, Path baseDir, List<Path> paths) {
 if (!paths.isEmpty()) {
  StringBuilder sb = new StringBuilder(label);
  for (Iterator<Path> it = paths.iterator(); it.hasNext();) {
   Path file = it.next();
   Optional<String> relativePathToBaseDir = PathResolver.relativize(baseDir, file);
   if (!relativePathToBaseDir.isPresent()) {
    sb.append(file);
   } else if (StringUtils.isBlank(relativePathToBaseDir.get())) {
    sb.append(".");
   } else {
    sb.append(relativePathToBaseDir.get());
   }
   if (it.hasNext()) {
    sb.append(", ");
   }
  }
  if (LOG.isDebugEnabled()) {
   LOG.debug(sb.toString());
  } else {
   LOG.info(StringUtils.abbreviate(sb.toString(), 80));
  }
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public void logoutFailure(HttpServletRequest request, String errorMessage) {
 checkRequest(request);
 requireNonNull(errorMessage, "error message can't be null");
 if (!LOGGER.isDebugEnabled()) {
  return;
 }
 LOGGER.debug("logout failure [error|{}][IP|{}|{}]",
  emptyIfNull(errorMessage),
  request.getRemoteAddr(), getAllIps(request));
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public void logoutSuccess(HttpServletRequest request, @Nullable String login) {
 checkRequest(request);
 if (!LOGGER.isDebugEnabled()) {
  return;
 }
 LOGGER.debug("logout success [IP|{}|{}][login|{}]",
  request.getRemoteAddr(), getAllIps(request),
  preventLogFlood(emptyIfNull(login)));
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public void loginSuccess(HttpServletRequest request, @Nullable String login, Source source) {
 checkRequest(request);
 requireNonNull(source, "source can't be null");
 if (!LOGGER.isDebugEnabled()) {
  return;
 }
 LOGGER.debug("login success [method|{}][provider|{}|{}][IP|{}|{}][login|{}]",
  source.getMethod(), source.getProvider(), source.getProviderName(),
  request.getRemoteAddr(), getAllIps(request),
  preventLogFlood(emptyIfNull(login)));
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public void execute(ComputationStep.Context context) {
 VisitorsCrawler visitorsCrawler = new VisitorsCrawler(visitors, LOGGER.isDebugEnabled());
 visitorsCrawler.visit(treeRootHolder.getRoot());
 logVisitorExecutionDurations(visitors, visitorsCrawler);
}

代码示例来源:origin: SonarSource/sonarqube

public void init(ScannerReportWriter writer) {
 if (mode.isIssues()) {
  return;
 }
 File analysisLog = writer.getFileStructure().analysisLog();
 try (BufferedWriter fileWriter = Files.newBufferedWriter(analysisLog.toPath(), StandardCharsets.UTF_8)) {
  if (LOG.isDebugEnabled()) {
   writeEnvVariables(fileWriter);
   writeSystemProps(fileWriter);
  }
  writePlugins(fileWriter);
  writeGlobalSettings(fileWriter);
  writeProjectSettings(fileWriter);
  writeModulesSettings(fileWriter);
 } catch (IOException e) {
  throw new IllegalStateException("Unable to write analysis log", e);
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public void loginFailure(HttpServletRequest request, AuthenticationException e) {
 checkRequest(request);
 requireNonNull(e, "AuthenticationException can't be null");
 if (!LOGGER.isDebugEnabled()) {
  return;
 }
 Source source = e.getSource();
 LOGGER.debug("login failure [cause|{}][method|{}][provider|{}|{}][IP|{}|{}][login|{}]",
  emptyIfNull(e.getMessage()),
  source.getMethod(), source.getProvider(), source.getProviderName(),
  request.getRemoteAddr(), getAllIps(request),
  preventLogFlood(emptyIfNull(e.getLogin())));
}

代码示例来源:origin: SonarSource/sonarqube

@Override
public void execute(ComputationStep.Context context) {
 try (DbSession dbSession = dbClient.openSession(false)) {
  Optional<CeTaskInputDao.DataStream> opt = dbClient.ceTaskInputDao().selectData(dbSession, task.getUuid());
  if (opt.isPresent()) {
   File unzippedDir = tempFolder.newDir();
   try (CeTaskInputDao.DataStream reportStream = opt.get();
      InputStream zipStream = new BufferedInputStream(reportStream.getInputStream())) {
    ZipUtils.unzip(zipStream, unzippedDir);
   } catch (IOException e) {
    throw new IllegalStateException("Fail to extract report " + task.getUuid() + " from database", e);
   }
   reportDirectoryHolder.setDirectory(unzippedDir);
   if (LOGGER.isDebugEnabled()) {
    // size is not added to context statistics because computation
    // can take time. It's enabled only if log level is DEBUG.
    try {
     String dirSize = FileUtils.byteCountToDisplaySize(FileUtils2.sizeOf(unzippedDir.toPath()));
     LOGGER.debug("Analysis report is {} uncompressed", dirSize);
    } catch (IOException e) {
     LOGGER.warn("Fail to compute size of directory " + unzippedDir, e);
    }
   }
  } else {
   throw MessageException.of("Analysis report " + task.getUuid() + " is missing in database");
  }
 }
}

代码示例来源:origin: org.codehaus.sonar/sonar-plugin-api

public static Profiler createIfDebug(Logger logger) {
 if (logger.isDebugEnabled()) {
  return create(logger);
 }
 return NullProfiler.NULL_INSTANCE;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-plugin-api

public static Profiler createIfDebug(Logger logger) {
 if (logger.isDebugEnabled()) {
  return create(logger);
 }
 return NullProfiler.NULL_INSTANCE;
}

代码示例来源:origin: org.sonarsource.sonarqube/sonar-server

@Override
public void execute() {
 VisitorsCrawler visitorsCrawler = new VisitorsCrawler(visitors, LOGGER.isDebugEnabled());
 visitorsCrawler.visit(treeRootHolder.getRoot());
 logVisitorExecutionDurations(visitors, visitorsCrawler);
}

相关文章