Skip to content

Commit 3da4733

Browse files
Eric Dalloelo7-developer
authored andcommitted
Add log when profile not loaded
1 parent 5e66bdc commit 3da4733

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=2.2.4
1+
version=2.2.5

src/main/java/com/spring/loader/configuration/S3PropertiesLocationRegistrar.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import static com.spring.loader.util.WordUtils.classNameloweredCaseFirstLetter;
44

5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
57
import org.springframework.beans.factory.config.BeanDefinition;
68
import org.springframework.beans.factory.config.RuntimeBeanReference;
79
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
@@ -27,6 +29,8 @@
2729
*/
2830
public class S3PropertiesLocationRegistrar implements EnvironmentAware, ImportBeanDefinitionRegistrar {
2931

32+
private static final Logger LOGGER = LoggerFactory.getLogger(S3PropertiesLocationRegistrar.class);
33+
3034
private Environment environment;
3135
private SystemPropertyResolver resolver;
3236

@@ -45,6 +49,7 @@ public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, B
4549
String[] profiles = attributes.getStringArray("profiles");
4650

4751
if (profiles.length > 0 && !environment.acceptsProfiles(profiles)) {
52+
LOGGER.warn("S3 Properties not loaded. Current application profile: {}. Acceptable profiles: {}", environment.getActiveProfiles(), profiles);
4853
return;
4954
}
5055

src/main/java/com/spring/loader/configuration/S3PropertiesSourceConfigurer.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
6868

6969
Properties[] propertiesToAdd = new Properties[locations.length];
7070

71+
LOGGER.info("Starting to load properties from S3 into application");
72+
7173
for (int i = 0; i < locations.length; i++) {
7274
Properties properties = new Properties();
7375
try {
@@ -87,7 +89,7 @@ public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory)
8789
try {
8890
propertiesFactory.afterPropertiesSet();
8991
propertySources.addFirst(new S3PropertySource(propertiesFactory.getObject()));
90-
92+
9193
LOGGER.info("Successfully loaded properties from S3 into application");
9294
} catch (IOException e) {
9395
LOGGER.error("Could not read properties from s3Location", e);

0 commit comments

Comments
 (0)