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

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

本文整理了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

  1. private void logTrace(String msg, @Nullable Object[] args) {
  2. if (args == null) {
  3. logger.trace(msg);
  4. } else {
  5. logger.trace(msg, args);
  6. }
  7. }

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

  1. private void silentlySendError(HttpServletResponse response, int error) {
  2. if (system.isCommitted(response)) {
  3. LOG.trace("Response is committed. Cannot send error response code {}", error);
  4. return;
  5. }
  6. try {
  7. system.sendError(response, error);
  8. } catch (IOException e) {
  9. LOG.trace("Failed to send error code {}: {}", error, e);
  10. }
  11. }

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

  1. @Override
  2. public void startIt() {
  3. if (semaphore.tryAcquire()) {
  4. try {
  5. executorService.execute(this::doDatabaseMigration);
  6. } catch (RuntimeException e) {
  7. semaphore.release();
  8. throw e;
  9. }
  10. } else {
  11. LOGGER.trace("{}: lock is already taken or process is already running", Thread.currentThread().getName());
  12. }
  13. }

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

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

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

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

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

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

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

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

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

  1. private void cancelWornOuts() {
  2. try {
  3. LOG.trace("Cancelling any worn out task");
  4. internalCeQueue.cancelWornOuts();
  5. } catch (Exception e) {
  6. LOG.warn("Failed to cancel worn out tasks", e);
  7. }
  8. }
  9. }

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

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

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

  1. @Override
  2. public void visitFile(Component file) {
  3. List<CpdTextBlock> cpdTextBlocks;
  4. try (CloseableIterator<CpdTextBlock> blocksIt = reportReader.readCpdTextBlocks(file.getReportAttributes().getRef())) {
  5. cpdTextBlocks = newArrayList(blocksIt);
  6. LOGGER.trace("Found {} cpd blocks on file {}", cpdTextBlocks.size(), file.getDbKey());
  7. if (cpdTextBlocks.isEmpty()) {
  8. return;
  9. }
  10. }
  11. Collection<String> hashes = from(cpdTextBlocks).transform(CpdTextBlockToHash.INSTANCE).toList();
  12. List<DuplicationUnitDto> dtos = selectDuplicates(file, hashes);
  13. if (dtos.isEmpty()) {
  14. return;
  15. }
  16. Collection<Block> duplicatedBlocks = from(dtos).transform(DtoToBlock.INSTANCE).toList();
  17. Collection<Block> originBlocks = from(cpdTextBlocks).transform(new CpdTextBlockToBlock(file.getDbKey())).toList();
  18. LOGGER.trace("Found {} duplicated cpd blocks on file {}", duplicatedBlocks.size(), file.getDbKey());
  19. integrateCrossProjectDuplications.computeCpd(file, originBlocks, duplicatedBlocks);
  20. }

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

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

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

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

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

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

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

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

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

  1. private boolean isConnectedToDB() {
  2. try (DbSession dbSession = dbClient.openSession(false)) {
  3. return dbSession.getMapper(IsAliveMapper.class).isAlive() == IsAliveMapper.IS_ALIVE_RETURNED_VALUE;
  4. } catch (RuntimeException e) {
  5. LOGGER.trace("DB connection is down: {}", e);
  6. return false;
  7. }
  8. }
  9. }

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

  1. public Optional<DbScmInfo> getScmInfo(Component file) {
  2. Optional<String> uuid = getFileUUid(file);
  3. if (!uuid.isPresent()) {
  4. return Optional.empty();
  5. }
  6. LOGGER.trace("Reading SCM info from DB for file '{}'", uuid.get());
  7. try (DbSession dbSession = dbClient.openSession(false)) {
  8. FileSourceDto dto = dbClient.fileSourceDao().selectByFileUuid(dbSession, uuid.get());
  9. if (dto == null) {
  10. return Optional.empty();
  11. }
  12. return DbScmInfo.create(dto.getSourceData().getLinesList(), dto.getSrcHash());
  13. }
  14. }

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

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

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

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

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

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

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

  1. @Override
  2. public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain chain) throws IOException, ServletException {
  3. HttpServletRequest request = (HttpServletRequest) servletRequest;
  4. HttpServletResponse response = (HttpServletResponse) servletResponse;
  5. DBSessions dbSessions = platform.getContainer().getComponentByType(DBSessions.class);
  6. ThreadLocalSettings settings = platform.getContainer().getComponentByType(ThreadLocalSettings.class);
  7. DefaultOrganizationCache defaultOrganizationCache = platform.getContainer().getComponentByType(DefaultOrganizationCache.class);
  8. UserSessionInitializer userSessionInitializer = platform.getContainer().getComponentByType(UserSessionInitializer.class);
  9. LOG.trace("{} serves {}", Thread.currentThread(), request.getRequestURI());
  10. dbSessions.enableCaching();
  11. try {
  12. defaultOrganizationCache.load();
  13. try {
  14. settings.load();
  15. try {
  16. doFilter(request, response, chain, userSessionInitializer);
  17. } finally {
  18. settings.unload();
  19. }
  20. } finally {
  21. defaultOrganizationCache.unload();
  22. }
  23. } finally {
  24. dbSessions.disableCaching();
  25. }
  26. }

相关文章