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

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

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

Logger.warn介绍

[英]Logs a WARN level message.
[中]记录警告级别的消息。

代码示例

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

  1. @Override
  2. public void handleAll(char c) {
  3. if (!alreadyLoggedInvalidCharacter && c == '\ufffd') {
  4. LOG.warn("Invalid character encountered in file {} at line {} for encoding {}. Please fix file content or configure the encoding to be used using property '{}'.", filePath,
  5. lines, encoding, CoreProperties.ENCODING_PROPERTY);
  6. alreadyLoggedInvalidCharacter = true;
  7. }
  8. }

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

  1. private static void logWarningIf(boolean condition, String message) {
  2. if (condition) {
  3. LOGGER.warn(message);
  4. }
  5. }

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

  1. @Override
  2. public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
  3. if (exc instanceof FileSystemLoopException) {
  4. LOG.warn("Not indexing due to symlink loop: {}", file.toFile());
  5. return FileVisitResult.CONTINUE;
  6. }
  7. throw exc;
  8. }

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

  1. private void logOnce(String metricKey, String msg, Object... params) {
  2. if (alreadyLogged.add(metricKey)) {
  3. LOG.warn(msg, params);
  4. }
  5. }

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

  1. private void warnOnceUnsupportedIssueExclusions(String msg) {
  2. if (!warnExclusionsAlreadyLogged) {
  3. LOG.warn(msg);
  4. analysisWarnings.addUnique(msg);
  5. warnExclusionsAlreadyLogged = true;
  6. }
  7. }

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

  1. private void warnOnceDeprecatedIssuePattern(String msg) {
  2. if (!warnDeprecatedIssuePatternAlreadyLogged) {
  3. LOG.warn(msg);
  4. analysisWarnings.addUnique(msg);
  5. warnDeprecatedIssuePatternAlreadyLogged = true;
  6. }
  7. }

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

  1. private void warnOnceDeprecatedIssuePattern(String msg) {
  2. if (!warnDeprecatedIssuePatternAlreadyLogged) {
  3. LOG.warn(msg);
  4. analysisWarnings.addUnique(msg);
  5. warnDeprecatedIssuePatternAlreadyLogged = true;
  6. }
  7. }

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

  1. @Override
  2. public void start() {
  3. configuration.get(PROPERTY_SONAR_CE_WORKER_COUNT)
  4. .ifPresent(workerCount -> LOG.warn("Property {} is not supported anymore and will be ignored." +
  5. " Remove it from sonar.properties to remove this warning.",
  6. PROPERTY_SONAR_CE_WORKER_COUNT));
  7. }

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

  1. private void warnOnce(String propKey, String filePath, BooleanSupplier alreadyLoggedGetter, Runnable markAsLogged) {
  2. if (!alreadyLoggedGetter.getAsBoolean()) {
  3. String msg = "Specifying module-relative paths at project level in the property '" + propKey + "' is deprecated. " +
  4. "To continue matching files like '" + filePath + "', update this property so that patterns refer to project-relative paths.";
  5. LOG.warn(msg);
  6. analysisWarnings.addUnique(msg);
  7. markAsLogged.run();
  8. }
  9. }

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

  1. public static void closeQuietly(@Nullable ResultSet rs) {
  2. if (rs != null) {
  3. try {
  4. rs.close();
  5. } catch (SQLException e) {
  6. Loggers.get(DatabaseUtils.class).warn("Fail to close result set", e);
  7. // ignore
  8. }
  9. }
  10. }

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

  1. private String format(boolean logIfMissing, String key, Object... args) {
  2. try {
  3. String message = getString(key);
  4. return String.format(locale, message, args);
  5. } catch (MissingResourceException e) {
  6. if (logIfMissing) {
  7. LOG.warn("Missing translation: key==" + key + ",locale=" + locale);
  8. }
  9. return key;
  10. }
  11. }

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

  1. private EmailMessage format(Notification notification) {
  2. for (EmailTemplate template : templates) {
  3. EmailMessage email = template.format(notification);
  4. if (email != null) {
  5. return email;
  6. }
  7. }
  8. LOG.warn("Email template not found for notification: {}", notification);
  9. return null;
  10. }

代码示例来源: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. private static Path initWorkingDir(ProjectDefinition module) {
  2. File workingDirAsFile = module.getWorkDir();
  3. Path workingDir = workingDirAsFile.getAbsoluteFile().toPath().normalize();
  4. if (SystemUtils.IS_OS_WINDOWS) {
  5. try {
  6. Files.setAttribute(workingDir, "dos:hidden", true, LinkOption.NOFOLLOW_LINKS);
  7. } catch (IOException e) {
  8. LOGGER.warn("Failed to set working directory hidden: {}", e.getMessage());
  9. }
  10. }
  11. return workingDir;
  12. }

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

  1. @Override
  2. public boolean apply(@Nonnull ClonePart input) {
  3. if (counter == MAX_CLONE_PART_PER_GROUP) {
  4. LOGGER.warn("Too many duplication references on file {} for block at line {}. Keeping only the first {} references.",
  5. file.getDbKey(), originPart.getStartLine(), MAX_CLONE_PART_PER_GROUP);
  6. }
  7. boolean res = counter <= MAX_CLONE_GROUP_PER_FILE;
  8. counter++;
  9. return res;
  10. }
  11. }

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

  1. private static Rule create(String repositoryKey, Class annotatedClass) {
  2. org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClass, org.sonar.check.Rule.class);
  3. if (ruleAnnotation != null) {
  4. return toRule(repositoryKey, annotatedClass, ruleAnnotation);
  5. }
  6. LOG.warn("The class " + annotatedClass.getCanonicalName() + " should be annotated with " + Rule.class);
  7. return null;
  8. }

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

  1. @Override
  2. public void init(DatabaseMetaData metaData) throws SQLException {
  3. checkState(!initialized, "onInit() must be called once");
  4. Version version = checkDbVersion(metaData, MIN_SUPPORTED_VERSION);
  5. supportsUpsert = version.compareTo(MIN_UPSERT_VERSION) >= 0;
  6. if (!supportsUpsert) {
  7. Loggers.get(getClass()).warn("Upgrading PostgreSQL to {} or greater is recommended for better performances", MIN_UPSERT_VERSION);
  8. }
  9. initialized = true;
  10. }
  11. }

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

  1. @Override
  2. public ProtobufSystemInfo.Section toProtobuf() {
  3. ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
  4. protobuf.setName("Search Indexes");
  5. try {
  6. completeIndexAttributes(protobuf);
  7. } catch (Exception es) {
  8. Loggers.get(EsIndexesSection.class).warn("Failed to retrieve ES attributes. There will be only a single \"Error\" attribute.", es);
  9. setAttribute(protobuf, "Error", es.getCause() instanceof ElasticsearchException ? es.getCause().getMessage() : es.getMessage());
  10. }
  11. return protobuf.build();
  12. }

代码示例来源: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. @Test
  2. public void should_log_warning_if_toString_is_not_overridden() {
  3. Logger log = mock(Logger.class);
  4. keys.of(new Object(), log);
  5. verifyZeroInteractions(log);
  6. // only on non-first runs, to avoid false-positives on singletons
  7. keys.of(new Object(), log);
  8. verify(log).warn(startsWith("Bad component key"));
  9. }

相关文章