Skip to content

Commit 8fa8cef

Browse files
stephankrugggStephan Krug
andauthored
Add and improve logs in ACS bootstrap process (#6890)
* Add and improve logs * Fix unnecessary calls --------- Co-authored-by: Stephan Krug <[email protected]>
1 parent 9e8f591 commit 8fa8cef

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

framework/spring/module/src/main/java/org/apache/cloudstack/spring/module/model/impl/DefaultModuleDefinitionSet.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,18 @@ protected void startContexts() {
9797
@Override
9898
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
9999
try {
100-
ApplicationContext context = getApplicationContext(def.getName());
100+
String moduleDefinitionName = def.getName();
101+
log.debug(String.format("Trying to obtain module [%s] context.", moduleDefinitionName));
102+
ApplicationContext context = getApplicationContext(moduleDefinitionName);
101103
try {
102104
Runnable runnable = context.getBean("moduleStartup", Runnable.class);
103-
log.info("Starting module [" + def.getName() + "]");
105+
log.info(String.format("Starting module [%s].", moduleDefinitionName));
104106
runnable.run();
105107
} catch (BeansException e) {
106-
// Ignore
108+
log.error(String.format("Failed to start module [%s] due to: [%s].", moduleDefinitionName, e.getMessage()), e);
107109
}
108110
} catch (EmptyStackException e) {
109-
// The root context is already loaded, so ignore the exception
111+
log.error(String.format("Failed to obtain module context due to [%s]. Using root context instead.", e.getMessage()), e);
110112
}
111113
}
112114
});
@@ -117,10 +119,15 @@ protected void loadContexts() {
117119
@Override
118120
public void with(ModuleDefinition def, Stack<ModuleDefinition> parents) {
119121
try {
122+
String moduleDefinitionName = def.getName();
123+
log.debug(String.format("Trying to obtain module [%s] context.", moduleDefinitionName));
120124
ApplicationContext parent = getApplicationContext(parents.peek().getName());
125+
log.debug(String.format("Trying to load module [%s] context.", moduleDefinitionName));
121126
loadContext(def, parent);
122127
} catch (EmptyStackException e) {
123-
// The root context is already loaded, so ignore the exception
128+
log.error(String.format("Failed to obtain module context due to [%s]. Using root context instead.", e.getMessage()), e);
129+
} catch (BeansException e) {
130+
log.error(String.format("Failed to load module [%s] due to: [%s].", def.getName(), e.getMessage()), e);
124131
}
125132
}
126133
});

0 commit comments

Comments
 (0)