|
|
|
@ -28,6 +28,7 @@ import org.apache.commons.logging.Log;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
import org.springframework.util.ClassUtils;
|
|
|
|
|
import org.springframework.util.StopWatch;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -44,7 +45,7 @@ class StartupInfoLogger {
|
|
|
|
|
this.sourceClass = sourceClass;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void log(Log log) {
|
|
|
|
|
public void logStarting(Log log) {
|
|
|
|
|
Assert.notNull(log, "Log must not be null");
|
|
|
|
|
if (log.isInfoEnabled()) {
|
|
|
|
|
log.info(getStartupMessage());
|
|
|
|
@ -54,6 +55,12 @@ class StartupInfoLogger {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void logStarted(Log log, StopWatch stopWatch) {
|
|
|
|
|
if (log.isInfoEnabled()) {
|
|
|
|
|
log.info(getStartedMessage(stopWatch));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getStartupMessage() {
|
|
|
|
|
StringBuilder message = new StringBuilder();
|
|
|
|
|
message.append("Starting ");
|
|
|
|
@ -74,6 +81,16 @@ class StartupInfoLogger {
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private StringBuilder getStartedMessage(StopWatch stopWatch) {
|
|
|
|
|
StringBuilder message = new StringBuilder();
|
|
|
|
|
message.append("Started ");
|
|
|
|
|
message.append(getApplicationName());
|
|
|
|
|
message.append(" in ");
|
|
|
|
|
message.append(stopWatch.getTotalTimeSeconds());
|
|
|
|
|
message.append(" seconds");
|
|
|
|
|
return message;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private String getApplicationName() {
|
|
|
|
|
return (this.sourceClass != null ? ClassUtils.getShortName(this.sourceClass)
|
|
|
|
|
: "application");
|
|
|
|
@ -163,4 +180,5 @@ class StartupInfoLogger {
|
|
|
|
|
}
|
|
|
|
|
return defaultValue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|