Merge pull request #13512 from izeye:config-file-application-listener-log-level-guard
* pr/13512: Add log level guards in ConfigFileApplicationListener
This commit is contained in:
commit
deea8ebc0d
|
|
@ -386,8 +386,10 @@ public class ConfigFileApplicationListener
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (this.activatedProfiles) {
|
if (this.activatedProfiles) {
|
||||||
this.logger.debug("Profiles already activated, '" + profiles
|
if (this.logger.isDebugEnabled()) {
|
||||||
+ "' will not be applied");
|
this.logger.debug("Profiles already activated, '" + profiles
|
||||||
|
+ "' will not be applied");
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.profiles.addAll(profiles);
|
this.profiles.addAll(profiles);
|
||||||
|
|
@ -501,23 +503,28 @@ public class ConfigFileApplicationListener
|
||||||
DocumentFilter filter, DocumentConsumer consumer) {
|
DocumentFilter filter, DocumentConsumer consumer) {
|
||||||
try {
|
try {
|
||||||
Resource resource = this.resourceLoader.getResource(location);
|
Resource resource = this.resourceLoader.getResource(location);
|
||||||
String description = getDescription(location, resource);
|
|
||||||
if (profile != null) {
|
|
||||||
description = description + " for profile " + profile;
|
|
||||||
}
|
|
||||||
if (resource == null || !resource.exists()) {
|
if (resource == null || !resource.exists()) {
|
||||||
this.logger.trace("Skipped missing config " + description);
|
if (this.logger.isTraceEnabled()) {
|
||||||
|
this.logger.trace("Skipped missing config "
|
||||||
|
+ getDescription(location, resource, profile));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!StringUtils.hasText(
|
if (!StringUtils.hasText(
|
||||||
StringUtils.getFilenameExtension(resource.getFilename()))) {
|
StringUtils.getFilenameExtension(resource.getFilename()))) {
|
||||||
this.logger.trace("Skipped empty config extension " + description);
|
if (this.logger.isTraceEnabled()) {
|
||||||
|
this.logger.trace("Skipped empty config extension "
|
||||||
|
+ getDescription(location, resource, profile));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String name = "applicationConfig: [" + location + "]";
|
String name = "applicationConfig: [" + location + "]";
|
||||||
List<Document> documents = loadDocuments(loader, name, resource);
|
List<Document> documents = loadDocuments(loader, name, resource);
|
||||||
if (CollectionUtils.isEmpty(documents)) {
|
if (CollectionUtils.isEmpty(documents)) {
|
||||||
this.logger.trace("Skipped unloaded config " + description);
|
if (this.logger.isTraceEnabled()) {
|
||||||
|
this.logger.trace("Skipped unloaded config "
|
||||||
|
+ getDescription(location, resource, profile));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
List<Document> loaded = new ArrayList<>();
|
List<Document> loaded = new ArrayList<>();
|
||||||
|
|
@ -531,7 +538,10 @@ public class ConfigFileApplicationListener
|
||||||
Collections.reverse(loaded);
|
Collections.reverse(loaded);
|
||||||
if (!loaded.isEmpty()) {
|
if (!loaded.isEmpty()) {
|
||||||
loaded.forEach((document) -> consumer.accept(profile, document));
|
loaded.forEach((document) -> consumer.accept(profile, document));
|
||||||
this.logger.debug("Loaded config file " + description);
|
if (this.logger.isDebugEnabled()) {
|
||||||
|
this.logger.debug("Loaded config file "
|
||||||
|
+ getDescription(location, resource, profile));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
|
|
@ -576,6 +586,13 @@ public class ConfigFileApplicationListener
|
||||||
}).collect(Collectors.toList());
|
}).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getDescription(String location, Resource resource,
|
||||||
|
Profile profile) {
|
||||||
|
String description = getDescription(location, resource);
|
||||||
|
return (profile != null ? description + " for profile " + profile
|
||||||
|
: description);
|
||||||
|
}
|
||||||
|
|
||||||
private String getDescription(String location, Resource resource) {
|
private String getDescription(String location, Resource resource) {
|
||||||
try {
|
try {
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue