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

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

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

Logger.trace介绍

[英]Logs a TRACE message.

TRACE messages must be valuable for diagnosing production problems. They must not be used for development debugging. They can significantly slow down performances. The standard use-case is logging of SQL and Elasticsearch requests.
[中]记录跟踪消息。
跟踪消息对于诊断生产问题必须很有价值。它们不能用于开发调试。它们可以显著降低性能。标准用例是记录SQL和Elasticsearch请求。

代码示例

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

private void logTrace(String msg, @Nullable Object[] args) {
 if (args == null) {
  logger.trace(msg);
 } else {
  logger.trace(msg, args);
 }
}

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

private void silentlySendError(HttpServletResponse response, int error) {
 if (system.isCommitted(response)) {
  LOG.trace("Response is committed. Cannot send error response code {}", error);
  return;
 }
 try {
  system.sendError(response, error);
 } catch (IOException e) {
  LOG.trace("Failed to send error code {}: {}", error, e);
 }
}

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

@Override
public void startIt() {
 if (semaphore.tryAcquire()) {
  try {
   executorService.execute(this::doDatabaseMigration);
  } catch (RuntimeException e) {
   semaphore.release();
   throw e;
  }
 } else {
  LOGGER.trace("{}: lock is already taken or process is already running", Thread.currentThread().getName());
 }
}

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

private static void broadcastTo(Set<ChangedIssue> changedIssues, QGChangeEvent changeEvent, QGChangeEventListener listener) {
 try {
  LOG.trace("calling onChange() on listener {} for events {}...", listener.getClass().getName(), changeEvent);
  listener.onIssueChanges(changeEvent, changedIssues);
 } catch (Exception e) {
  LOG.warn(format("onChange() call failed on listener %s for events %s", listener.getClass().getName(), changeEvent), e);
 }
}

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

/**
 * Logs a TRACE message, which is only to be constructed if the logging level
 * is such that the message will actually be logged.
 * <p>
 * TRACE messages must
 * be valuable for diagnosing production problems. They must not be used for development debugging.
 * They can significantly slow down performances. The standard use-case is logging of
 * SQL and Elasticsearch requests.
 * @param msgSupplier A function, which when called, produces the desired log message
 * @since 6.3
 */
default void trace(Supplier<String> msgSupplier) {
 if (isTraceEnabled()) {
  trace(msgSupplier.get());
 }
}

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

private IndexingResult doIndex(DbSession dbSession, IndexType type, Collection<EsQueueDto> typeItems) {
 LOGGER.trace(LOG_PREFIX + "processing {} {}", typeItems.size(), type);
 ResilientIndexer indexer = indexersByType.get(type);
 if (indexer == null) {
  LOGGER.error(LOG_PREFIX + "ignore {} items with unsupported type {}", typeItems.size(), type);
  return new IndexingResult();
 }
 return indexer.index(dbSession, typeItems);
}

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

private static Optional<ScmInfo> getScmInfoFromReport(Component file, ScannerReport.Changesets changesets) {
 LOGGER.trace("Reading SCM info from report for file '{}'", file.getDbKey());
 return Optional.of(new ReportScmInfo(changesets));
}

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

private void cancelWornOuts() {
  try {
   LOG.trace("Cancelling any worn out task");
   internalCeQueue.cancelWornOuts();
  } catch (Exception e) {
   LOG.warn("Failed to cancel worn out tasks", e);
  }
 }
}

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

private static boolean handleRootIdUpdateForSubNodes(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException {
 long rootId = row.getLong(1);
 String rootUuid = componentUuidById.get(rootId);
 if (rootUuid == null) {
  LOG.trace("No UUID found for rootId={}", rootUuid);
  return false;
 }
 update.setString(1, rootUuid);
 update.setLong(2, rootId);
 return true;
}

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

@Override
public void visitFile(Component file) {
 List<CpdTextBlock> cpdTextBlocks;
 try (CloseableIterator<CpdTextBlock> blocksIt = reportReader.readCpdTextBlocks(file.getReportAttributes().getRef())) {
  cpdTextBlocks = newArrayList(blocksIt);
  LOGGER.trace("Found {} cpd blocks on file {}", cpdTextBlocks.size(), file.getDbKey());
  if (cpdTextBlocks.isEmpty()) {
   return;
  }
 }
 Collection<String> hashes = from(cpdTextBlocks).transform(CpdTextBlockToHash.INSTANCE).toList();
 List<DuplicationUnitDto> dtos = selectDuplicates(file, hashes);
 if (dtos.isEmpty()) {
  return;
 }
 Collection<Block> duplicatedBlocks = from(dtos).transform(DtoToBlock.INSTANCE).toList();
 Collection<Block> originBlocks = from(cpdTextBlocks).transform(new CpdTextBlockToBlock(file.getDbKey())).toList();
 LOGGER.trace("Found {} duplicated cpd blocks on file {}", duplicatedBlocks.size(), file.getDbKey());
 integrateCrossProjectDuplications.computeCpd(file, originBlocks, duplicatedBlocks);
}

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

private static boolean handleDeveloperUuuidUpdate(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException {
 long id = row.getLong(1);
 long personId = row.getLong(2);
 String developerUuid = componentUuidById.get(personId);
 if (developerUuid == null) {
  LOG.trace("No UUID found for personId={}", personId);
  return false;
 }
 update.setString(1, developerUuid);
 update.setLong(2, id);
 return true;
}

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

private void initNewDebtRatioCounter(Component file, Path<Counter> path) {
 // first analysis, no period, no differential value to compute, save processing time and return now
 if (!newLinesRepository.newLinesAvailable()) {
  return;
 }
 Optional<Set<Integer>> changedLines = newLinesRepository.getNewLines(file);
 if (!changedLines.isPresent()) {
  LOG.trace(String.format("No information about changed lines is available for file '%s'. Dev cost will be zero.", file.getKey()));
  return;
 }
 Optional<Measure> nclocDataMeasure = measureRepository.getRawMeasure(file, this.nclocDataMetric);
 if (!nclocDataMeasure.isPresent()) {
  return;
 }
 initNewDebtRatioCounter(path.current(), file, nclocDataMeasure.get(), changedLines.get());
}

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

private void resetTasksWithUnknownWorkerUUIDs() {
 try {
  LOG.trace("Resetting state of tasks with unknown worker UUIDs");
  internalCeQueue.resetTasksWithUnknownWorkerUUIDs(ceDistributedInformation.getWorkerUUIDs());
 } catch (Exception e) {
  LOG.warn("Failed to reset tasks with unknown worker UUIDs", e);
 }
}

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

private static boolean handleCopyComponentUuidUpdate(Map<Long, String> componentUuidById, Select.Row row, SqlStatement update) throws SQLException {
 long id = row.getLong(1);
 long copyResourceId = row.getLong(2);
 String copyComponentUuid = componentUuidById.get(copyResourceId);
 if (copyComponentUuid == null) {
  LOG.trace("No UUID found for copyResourceId={}", copyResourceId);
  return false;
 }
 update.setString(1, copyComponentUuid);
 update.setLong(2, id);
 return true;
}

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

private boolean isConnectedToDB() {
  try (DbSession dbSession = dbClient.openSession(false)) {
   return dbSession.getMapper(IsAliveMapper.class).isAlive() == IsAliveMapper.IS_ALIVE_RETURNED_VALUE;
  } catch (RuntimeException e) {
   LOGGER.trace("DB connection is down: {}", e);
   return false;
  }
 }
}

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

public Optional<DbScmInfo> getScmInfo(Component file) {
 Optional<String> uuid = getFileUUid(file);
 if (!uuid.isPresent()) {
  return Optional.empty();
 }
 LOGGER.trace("Reading SCM info from DB for file '{}'", uuid.get());
 try (DbSession dbSession = dbClient.openSession(false)) {
  FileSourceDto dto = dbClient.fileSourceDao().selectByFileUuid(dbSession, uuid.get());
  if (dto == null) {
   return Optional.empty();
  }
  return DbScmInfo.create(dto.getSourceData().getLinesList(), dto.getSrcHash());
 }
}

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

private void registerMatches(Map<String, DbComponent> dbFilesByUuid, Map<String, Component> reportFilesByUuid, ElectedMatches electedMatches) {
 LOG.debug("{} files moves found", electedMatches.size());
 for (Match validatedMatch : electedMatches) {
  movedFilesRepository.setOriginalFile(
   reportFilesByUuid.get(validatedMatch.getReportUuid()),
   toOriginalFile(dbFilesByUuid.get(validatedMatch.getDbUuid())));
  LOG.trace("File move found: {}", validatedMatch);
 }
}

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

@Override
 public void visitAny(org.sonar.ce.task.projectanalysis.component.Component component) {
  MeasureComputerContextImpl context = new MeasureComputerContextImpl(component, settings, measureRepository, metricRepository, componentIssuesRepository);
  for (MeasureComputerWrapper measureComputerWrapper : measureComputersHolder.getMeasureComputers()) {
   context.setDefinition(measureComputerWrapper.getDefinition());
   MeasureComputer measureComputer = measureComputerWrapper.getComputer();
   LOGGER.trace("Measure computer '{}' is computing component {}", measureComputer, component);
   measureComputer.compute(context);
  }
 }
}

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

private Optional<ScmInfo> getScmInfoForComponent(Component component) {
 ScannerReport.Changesets changesets = scannerReportReader.readChangesets(component.getReportAttributes().getRef());
 if (changesets == null) {
  LOGGER.trace("No SCM info for file '{}'", component.getDbKey());
  // SCM not available. It might have been available before - copy information for unchanged lines but don't keep author and revision.
  return generateAndMergeDb(component, false);
 }
 // will be empty if the flag "copy from previous" is set, or if the file is empty.
 if (changesets.getChangesetCount() == 0) {
  return generateAndMergeDb(component, changesets.getCopyFromPrevious());
 }
 return getScmInfoFromReport(component, changesets);
}

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

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
 HttpServletRequest request = (HttpServletRequest) servletRequest;
 HttpServletResponse response = (HttpServletResponse) servletResponse;
 DBSessions dbSessions = platform.getContainer().getComponentByType(DBSessions.class);
 ThreadLocalSettings settings = platform.getContainer().getComponentByType(ThreadLocalSettings.class);
 DefaultOrganizationCache defaultOrganizationCache = platform.getContainer().getComponentByType(DefaultOrganizationCache.class);
 UserSessionInitializer userSessionInitializer = platform.getContainer().getComponentByType(UserSessionInitializer.class);
 LOG.trace("{} serves {}", Thread.currentThread(), request.getRequestURI());
 dbSessions.enableCaching();
 try {
  defaultOrganizationCache.load();
  try {
   settings.load();
   try {
    doFilter(request, response, chain, userSessionInitializer);
   } finally {
    settings.unload();
   }
  } finally {
   defaultOrganizationCache.unload();
  }
 } finally {
  dbSessions.disableCaching();
 }
}

相关文章