use of org.jvnet.hudson.reactor.ReactorListener in project hudson-2.x by hudson.
the class Hudson method buildReactorListener.
/**
* Aggregates all the listeners into one and returns it.
*
* <p>
* At this point plugins are not loaded yet, so we fall back to the META-INF/services look up to discover implementations.
* As such there's no way for plugins to participate into this process.
*/
private ReactorListener buildReactorListener() throws IOException {
List<ReactorListener> r = (List) Service.loadInstances(Thread.currentThread().getContextClassLoader(), InitReactorListener.class);
r.add(new ReactorListener() {
final Level level = Level.parse(System.getProperty(Hudson.class.getName() + ".initLogLevel", "FINE"));
public void onTaskStarted(Task t) {
LOGGER.log(level, "Started " + t.getDisplayName());
}
public void onTaskCompleted(Task t) {
LOGGER.log(level, "Completed " + t.getDisplayName());
}
public void onTaskFailed(Task t, Throwable err, boolean fatal) {
LOGGER.log(Level.SEVERE, "Failed " + t.getDisplayName(), err);
}
public void onAttained(Milestone milestone) {
Level lv = level;
String s = "Attained " + milestone.toString();
if (milestone instanceof InitMilestone) {
// noteworthy milestones --- at least while we debug problems further
lv = Level.INFO;
initLevel = (InitMilestone) milestone;
s = initLevel.toString();
}
LOGGER.log(lv, s);
}
});
return new ReactorListener.Aggregator(r);
}
Aggregations