use of org.gradle.internal.logging.events.OutputEventListener in project gradle by gradle.
the class OutputEventListenerBackedLogger method log.
private void log(LogLevel logLevel, Throwable throwable, String message) {
OperationIdentifier buildOperationId = CurrentBuildOperationRef.instance().getId();
LogEvent logEvent = new LogEvent(clock.getCurrentTime(), name, logLevel, message, throwable, buildOperationId);
OutputEventListener outputEventListener = context.getOutputEventListener();
try {
outputEventListener.onOutput(logEvent);
} catch (Throwable e) {
// fall back to standard out
e.printStackTrace(System.out);
}
}
use of org.gradle.internal.logging.events.OutputEventListener in project gradle by gradle.
the class DefaultLoggingManager method start.
@Override
public DefaultLoggingManager start() {
started = true;
if (enableStdOutListeners) {
loggingRouter.loggingRouter.enableUserStandardOutputListeners();
}
for (StandardOutputListener stdoutListener : stdoutListeners) {
loggingOutput.addStandardOutputListener(stdoutListener);
}
for (StandardOutputListener stderrListener : stderrListeners) {
loggingOutput.addStandardErrorListener(stderrListener);
}
for (OutputEventListener outputEventListener : outputEventListeners) {
loggingOutput.addOutputEventListener(outputEventListener);
}
loggingRouter.start();
slf4jLoggingSystem.enableCapture();
slf4jLoggingSystem.start();
javaUtilLoggingSystem.start();
stdOutLoggingSystem.start();
stdErrLoggingSystem.start();
return this;
}
use of org.gradle.internal.logging.events.OutputEventListener in project gradle by gradle.
the class LoggingServiceRegistry method createLoggingManagerFactory.
protected DefaultLoggingManagerFactory createLoggingManagerFactory() {
OutputEventListener outputEventBroadcaster = outputEventListenerManager.getBroadcaster();
LoggingSourceSystem stdout = new DefaultStdOutLoggingSystem(getStdoutListener(), get(Clock.class));
stdout.setLevel(LogLevel.QUIET);
LoggingSourceSystem stderr = new DefaultStdErrLoggingSystem(new TextStreamOutputEventListener(outputEventBroadcaster), get(Clock.class));
stderr.setLevel(LogLevel.ERROR);
return new DefaultLoggingManagerFactory(renderer, new LoggingSystemAdapter(new Slf4jLoggingConfigurer(outputEventBroadcaster)), new JavaUtilLoggingSystem(), stdout, stderr);
}
use of org.gradle.internal.logging.events.OutputEventListener in project gradle by gradle.
the class OutputEventRenderer method enableUserStandardOutputListeners.
@Override
public void enableUserStandardOutputListeners() {
// Then, a pipeline can be added for each listener as required
synchronized (lock) {
if (userStdoutListeners == null) {
userStdoutListeners = new ListenerBroadcast<StandardOutputListener>(StandardOutputListener.class);
userStderrListeners = new ListenerBroadcast<StandardOutputListener>(StandardOutputListener.class);
final OutputEventListener stdOutChain = new StyledTextOutputBackedRenderer(new StreamingStyledTextOutput(userStdoutListeners.getSource()));
final OutputEventListener stdErrChain = new StyledTextOutputBackedRenderer(new StreamingStyledTextOutput(userStderrListeners.getSource()));
userListenerChain = new BuildLogLevelFilterRenderer(new ProgressLogEventGenerator(new OutputEventListener() {
@Override
public void onOutput(OutputEvent event) {
// Do not forward events for rendering when there are no listeners to receive
if (event instanceof LogLevelChangeEvent) {
stdOutChain.onOutput(event);
stdErrChain.onOutput(event);
} else if (event.getLogLevel() == LogLevel.ERROR && !userStderrListeners.isEmpty() && event instanceof RenderableOutputEvent) {
stdErrChain.onOutput(event);
} else if (event.getLogLevel() != LogLevel.ERROR && !userStdoutListeners.isEmpty() && event instanceof RenderableOutputEvent) {
stdOutChain.onOutput(event);
}
}
}));
addChain(userListenerChain);
}
}
}
use of org.gradle.internal.logging.events.OutputEventListener in project gradle by gradle.
the class OutputEventRenderer method addRichConsole.
public void addRichConsole(OutputStream stdout, Console stderr, boolean verbose) {
OutputEventListener stdoutChain = new StyledTextOutputBackedRenderer(new StreamingStyledTextOutput(new StreamBackedStandardOutputListener(stdout)));
OutputEventListener stderrChain = new FlushConsoleListener(stderr, new StyledTextOutputBackedRenderer(stderr.getBuildOutputArea()));
OutputEventListener consoleListener = new ErrorOutputDispatchingListener(stderrChain, stdoutChain);
OutputEventListener consoleChain = getConsoleChainWithoutDynamicStdout(consoleListener, verbose);
addConsoleChain(consoleChain);
}
Aggregations