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

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

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

Logger.error介绍

[英]Logs an ERROR level message.
[中]记录错误级别消息。

代码示例

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

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

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

  1. private static Consumer<ProjectLifeCycleListener> safelyCallListener(Consumer<ProjectLifeCycleListener> task) {
  2. return listener -> {
  3. try {
  4. task.accept(listener);
  5. } catch (Error | Exception e) {
  6. LOG.error("Call on ProjectLifeCycleListener \"{}\" failed", listener.getClass(), e);
  7. }
  8. };
  9. }
  10. }

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

  1. private boolean attemptStartup() {
  2. try {
  3. startup();
  4. return true;
  5. } catch (org.sonar.api.utils.MessageException | org.sonar.process.MessageException e) {
  6. LOG.error("Compute Engine startup failed: " + e.getMessage());
  7. return false;
  8. } catch (Throwable e) {
  9. LOG.error("Compute Engine startup failed", e);
  10. return false;
  11. }
  12. }

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

  1. public void clean() {
  2. try {
  3. if (tempDir.exists()) {
  4. Files.walkFileTree(tempDir.toPath(), DeleteRecursivelyFileVisitor.INSTANCE);
  5. }
  6. } catch (IOException e) {
  7. LOG.error("Failed to delete temp folder", e);
  8. }
  9. }

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

  1. private void callListeners(Consumer<ExecutionListener> call) {
  2. listeners.forEach(listener -> {
  3. try {
  4. call.accept(listener);
  5. } catch (Throwable t) {
  6. LOG.error(format("Call to listener %s failed.", listener.getClass().getSimpleName()), t);
  7. }
  8. });
  9. }
  10. }

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

  1. private static void closeJar(@Nullable JarFile jar, String jarPath) {
  2. if (jar != null) {
  3. try {
  4. jar.close();
  5. } catch (Exception e) {
  6. Loggers.get(ClassLoaderUtils.class).error("Fail to close JAR file: " + jarPath, e);
  7. }
  8. }
  9. }

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

  1. private static void executeTask(ProjectAnalysisImpl projectAnalysis, PostProjectAnalysisTask postProjectAnalysisTask) {
  2. try {
  3. postProjectAnalysisTask.finished(projectAnalysis);
  4. } catch (Exception e) {
  5. LOG.error("Execution of task " + postProjectAnalysisTask.getClass() + " failed", e);
  6. }
  7. }

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

  1. private Optional<CeTask> tryAndFindTaskToExecute() {
  2. try {
  3. return queue.peek(uuid);
  4. } catch (Exception e) {
  5. LOG.error("Failed to pop the queue of analysis reports", e);
  6. }
  7. return Optional.empty();
  8. }

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

  1. private void executeListener(boolean allStepsExecuted) {
  2. try {
  3. listener.finished(allStepsExecuted);
  4. } catch (Throwable e) {
  5. // any Throwable throws by the listener going up the stack might hide an Exception/Error thrown by the step and
  6. // cause it be swallowed. We don't wan't that => we catch Throwable
  7. LOGGER.error("Execution of listener failed", e);
  8. }
  9. }

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

  1. @Override
  2. public void failure(Throwable t) {
  3. LOGGER.error("Background initialization failed. Stopping SonarQube", t);
  4. processCommandWrapper.requestStop();
  5. this.running = false;
  6. }

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

  1. @Override
  2. public void addToQueue(Runnable r) {
  3. requireNonNull(r);
  4. executorService.addToQueue(() -> {
  5. try {
  6. r.run();
  7. } catch (Exception e) {
  8. LOG.error("Asynchronous task failed", e);
  9. }
  10. });
  11. }
  12. }

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

  1. @Override
  2. public void afterBulk(long executionId, BulkRequest request, Throwable e) {
  3. LOGGER.error("Fail to execute bulk index request: " + request, e);
  4. stopProfiler(request);
  5. }

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

  1. private void processMeasure(FileLinesContext context, File measureFile, int lineNumber, String line) {
  2. try {
  3. String metricKey = StringUtils.substringBefore(line, ":");
  4. String value = line.substring(metricKey.length() + 1);
  5. saveMeasure(context, metricKey, KeyValueFormat.parseIntInt(value));
  6. } catch (Exception e) {
  7. LOG.error("Error processing line " + lineNumber + " of file " + measureFile.getAbsolutePath(), e);
  8. throw new IllegalStateException("Error processing line " + lineNumber + " of file " + measureFile.getAbsolutePath(), e);
  9. }
  10. }

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

  1. public void unload(Collection<Plugin> plugins) {
  2. for (Plugin plugin : plugins) {
  3. ClassLoader classLoader = plugin.getClass().getClassLoader();
  4. if (classLoader instanceof Closeable && classLoader != classloaderFactory.baseClassLoader()) {
  5. try {
  6. ((Closeable) classLoader).close();
  7. } catch (Exception e) {
  8. Loggers.get(getClass()).error("Fail to close classloader " + classLoader.toString(), e);
  9. }
  10. }
  11. }
  12. }

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

  1. private Optional<FileBlocks> toFileBlocks(String componentKey, Collection<Block> fileBlocks) {
  2. DefaultInputFile component = (DefaultInputFile) componentStore.getByKey(componentKey);
  3. if (component == null) {
  4. LOG.error("Resource not found in component store: {}. Skipping CPD computation for it", componentKey);
  5. return Optional.empty();
  6. }
  7. return Optional.of(new FileBlocks(component, fileBlocks));
  8. }

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

  1. @Override
  2. public void close() {
  3. try {
  4. stopComponents();
  5. } catch (Throwable t) {
  6. Loggers.get(TaskContainerImpl.class).error("Cleanup of container failed", t);
  7. }
  8. }
  9. }

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

  1. private static DistributedCall<Object> setLogLevelForNode(LoggerLevel level) {
  2. return () -> {
  3. try {
  4. ServerLogging.changeLevelFromHazelcastDistributedQuery(level);
  5. } catch (Exception e) {
  6. LOGGER.error("Setting log level to '" + level.name() + "' in this cluster node failed", e);
  7. throw new IllegalStateException("Setting log level to '" + level.name() + "' in this cluster node failed", e);
  8. }
  9. return null;
  10. };
  11. }
  12. }

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

  1. private void insertPermissionForAdministrators(DbSession dbSession, PermissionTemplateDto template) {
  2. Optional<GroupDto> admins = dbClient.groupDao().selectByName(dbSession, template.getOrganizationUuid(), DefaultGroups.ADMINISTRATORS);
  3. if (admins.isPresent()) {
  4. insertGroupPermission(dbSession, template, UserRole.ADMIN, admins.get());
  5. insertGroupPermission(dbSession, template, UserRole.ISSUE_ADMIN, admins.get());
  6. insertGroupPermission(dbSession, template, UserRole.SECURITYHOTSPOT_ADMIN, admins.get());
  7. insertGroupPermission(dbSession, template, OrganizationPermission.APPLICATION_CREATOR.getKey(), admins.get());
  8. insertGroupPermission(dbSession, template, OrganizationPermission.PORTFOLIO_CREATOR.getKey(), admins.get());
  9. } else {
  10. LOG.error("Cannot setup default permission for group: " + DefaultGroups.ADMINISTRATORS);
  11. }
  12. }

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

  1. private void attemptShutdown() {
  2. try {
  3. LOG.info("Compute Engine is stopping...");
  4. computeEngine.shutdown();
  5. LOG.info("Compute Engine is stopped");
  6. } catch (Throwable e) {
  7. LOG.error("Compute Engine failed to stop", e);
  8. } finally {
  9. // release thread waiting for CeServer
  10. stopAwait();
  11. }
  12. }

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

  1. void terminate() {
  2. if (tomcat.getServer().getState().isAvailable()) {
  3. try {
  4. tomcat.stop();
  5. tomcat.destroy();
  6. } catch (Exception e) {
  7. Loggers.get(EmbeddedTomcat.class).error("Fail to stop web server", e);
  8. }
  9. }
  10. deleteQuietly(tomcatBasedir());
  11. }

相关文章