本文整理了Java中org.sonar.api.utils.log.Logger.warn()
方法的一些代码示例,展示了Logger.warn()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Logger.warn()
方法的具体详情如下:
包路径:org.sonar.api.utils.log.Logger
类名称:Logger
方法名:warn
[英]Logs a WARN level message.
[中]记录警告级别的消息。
代码示例来源:origin: SonarSource/sonarqube
@Override
public void handleAll(char c) {
if (!alreadyLoggedInvalidCharacter && c == '\ufffd') {
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,
lines, encoding, CoreProperties.ENCODING_PROPERTY);
alreadyLoggedInvalidCharacter = true;
}
}
代码示例来源:origin: SonarSource/sonarqube
private static void logWarningIf(boolean condition, String message) {
if (condition) {
LOGGER.warn(message);
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException {
if (exc instanceof FileSystemLoopException) {
LOG.warn("Not indexing due to symlink loop: {}", file.toFile());
return FileVisitResult.CONTINUE;
}
throw exc;
}
代码示例来源:origin: SonarSource/sonarqube
private void logOnce(String metricKey, String msg, Object... params) {
if (alreadyLogged.add(metricKey)) {
LOG.warn(msg, params);
}
}
代码示例来源:origin: SonarSource/sonarqube
private void warnOnceUnsupportedIssueExclusions(String msg) {
if (!warnExclusionsAlreadyLogged) {
LOG.warn(msg);
analysisWarnings.addUnique(msg);
warnExclusionsAlreadyLogged = true;
}
}
代码示例来源:origin: SonarSource/sonarqube
private void warnOnceDeprecatedIssuePattern(String msg) {
if (!warnDeprecatedIssuePatternAlreadyLogged) {
LOG.warn(msg);
analysisWarnings.addUnique(msg);
warnDeprecatedIssuePatternAlreadyLogged = true;
}
}
代码示例来源:origin: SonarSource/sonarqube
private void warnOnceDeprecatedIssuePattern(String msg) {
if (!warnDeprecatedIssuePatternAlreadyLogged) {
LOG.warn(msg);
analysisWarnings.addUnique(msg);
warnDeprecatedIssuePatternAlreadyLogged = true;
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void start() {
configuration.get(PROPERTY_SONAR_CE_WORKER_COUNT)
.ifPresent(workerCount -> LOG.warn("Property {} is not supported anymore and will be ignored." +
" Remove it from sonar.properties to remove this warning.",
PROPERTY_SONAR_CE_WORKER_COUNT));
}
代码示例来源:origin: SonarSource/sonarqube
private void warnOnce(String propKey, String filePath, BooleanSupplier alreadyLoggedGetter, Runnable markAsLogged) {
if (!alreadyLoggedGetter.getAsBoolean()) {
String msg = "Specifying module-relative paths at project level in the property '" + propKey + "' is deprecated. " +
"To continue matching files like '" + filePath + "', update this property so that patterns refer to project-relative paths.";
LOG.warn(msg);
analysisWarnings.addUnique(msg);
markAsLogged.run();
}
}
代码示例来源:origin: SonarSource/sonarqube
public static void closeQuietly(@Nullable ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException e) {
Loggers.get(DatabaseUtils.class).warn("Fail to close result set", e);
// ignore
}
}
}
代码示例来源:origin: SonarSource/sonarqube
private String format(boolean logIfMissing, String key, Object... args) {
try {
String message = getString(key);
return String.format(locale, message, args);
} catch (MissingResourceException e) {
if (logIfMissing) {
LOG.warn("Missing translation: key==" + key + ",locale=" + locale);
}
return key;
}
}
代码示例来源:origin: SonarSource/sonarqube
private EmailMessage format(Notification notification) {
for (EmailTemplate template : templates) {
EmailMessage email = template.format(notification);
if (email != null) {
return email;
}
}
LOG.warn("Email template not found for notification: {}", notification);
return null;
}
代码示例来源: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
private static Path initWorkingDir(ProjectDefinition module) {
File workingDirAsFile = module.getWorkDir();
Path workingDir = workingDirAsFile.getAbsoluteFile().toPath().normalize();
if (SystemUtils.IS_OS_WINDOWS) {
try {
Files.setAttribute(workingDir, "dos:hidden", true, LinkOption.NOFOLLOW_LINKS);
} catch (IOException e) {
LOGGER.warn("Failed to set working directory hidden: {}", e.getMessage());
}
}
return workingDir;
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public boolean apply(@Nonnull ClonePart input) {
if (counter == MAX_CLONE_PART_PER_GROUP) {
LOGGER.warn("Too many duplication references on file {} for block at line {}. Keeping only the first {} references.",
file.getDbKey(), originPart.getStartLine(), MAX_CLONE_PART_PER_GROUP);
}
boolean res = counter <= MAX_CLONE_GROUP_PER_FILE;
counter++;
return res;
}
}
代码示例来源:origin: SonarSource/sonarqube
private static Rule create(String repositoryKey, Class annotatedClass) {
org.sonar.check.Rule ruleAnnotation = AnnotationUtils.getAnnotation(annotatedClass, org.sonar.check.Rule.class);
if (ruleAnnotation != null) {
return toRule(repositoryKey, annotatedClass, ruleAnnotation);
}
LOG.warn("The class " + annotatedClass.getCanonicalName() + " should be annotated with " + Rule.class);
return null;
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public void init(DatabaseMetaData metaData) throws SQLException {
checkState(!initialized, "onInit() must be called once");
Version version = checkDbVersion(metaData, MIN_SUPPORTED_VERSION);
supportsUpsert = version.compareTo(MIN_UPSERT_VERSION) >= 0;
if (!supportsUpsert) {
Loggers.get(getClass()).warn("Upgrading PostgreSQL to {} or greater is recommended for better performances", MIN_UPSERT_VERSION);
}
initialized = true;
}
}
代码示例来源:origin: SonarSource/sonarqube
@Override
public ProtobufSystemInfo.Section toProtobuf() {
ProtobufSystemInfo.Section.Builder protobuf = ProtobufSystemInfo.Section.newBuilder();
protobuf.setName("Search Indexes");
try {
completeIndexAttributes(protobuf);
} catch (Exception es) {
Loggers.get(EsIndexesSection.class).warn("Failed to retrieve ES attributes. There will be only a single \"Error\" attribute.", es);
setAttribute(protobuf, "Error", es.getCause() instanceof ElasticsearchException ? es.getCause().getMessage() : es.getMessage());
}
return protobuf.build();
}
代码示例来源: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
@Test
public void should_log_warning_if_toString_is_not_overridden() {
Logger log = mock(Logger.class);
keys.of(new Object(), log);
verifyZeroInteractions(log);
// only on non-first runs, to avoid false-positives on singletons
keys.of(new Object(), log);
verify(log).warn(startsWith("Bad component key"));
}
内容来源于网络,如有侵权,请联系作者删除!