Search in sources :

Example 6 with OutputEventListener

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);
    }
}
Also used : LogEvent(org.gradle.internal.logging.events.LogEvent) OperationIdentifier(org.gradle.internal.operations.OperationIdentifier) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener)

Example 7 with OutputEventListener

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;
}
Also used : StreamBackedStandardOutputListener(org.gradle.internal.logging.text.StreamBackedStandardOutputListener) StandardOutputListener(org.gradle.api.logging.StandardOutputListener) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener)

Example 8 with OutputEventListener

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);
}
Also used : JavaUtilLoggingSystem(org.gradle.internal.logging.source.JavaUtilLoggingSystem) LoggingSourceSystem(org.gradle.internal.logging.config.LoggingSourceSystem) Slf4jLoggingConfigurer(org.gradle.internal.logging.slf4j.Slf4jLoggingConfigurer) DefaultStdErrLoggingSystem(org.gradle.internal.logging.source.DefaultStdErrLoggingSystem) LoggingSystemAdapter(org.gradle.internal.logging.config.LoggingSystemAdapter) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener) Clock(org.gradle.internal.time.Clock) DefaultStdOutLoggingSystem(org.gradle.internal.logging.source.DefaultStdOutLoggingSystem)

Example 9 with OutputEventListener

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);
        }
    }
}
Also used : LogLevelChangeEvent(org.gradle.internal.logging.events.LogLevelChangeEvent) OutputEvent(org.gradle.internal.logging.events.OutputEvent) EndOutputEvent(org.gradle.internal.logging.events.EndOutputEvent) RenderableOutputEvent(org.gradle.internal.logging.events.RenderableOutputEvent) FlushOutputEvent(org.gradle.internal.logging.events.FlushOutputEvent) StandardOutputListener(org.gradle.api.logging.StandardOutputListener) StreamBackedStandardOutputListener(org.gradle.internal.logging.text.StreamBackedStandardOutputListener) StyledTextOutputBackedRenderer(org.gradle.internal.logging.console.StyledTextOutputBackedRenderer) StreamingStyledTextOutput(org.gradle.internal.logging.text.StreamingStyledTextOutput) RenderableOutputEvent(org.gradle.internal.logging.events.RenderableOutputEvent) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener) ThrottlingOutputEventListener(org.gradle.internal.logging.console.ThrottlingOutputEventListener) BuildLogLevelFilterRenderer(org.gradle.internal.logging.console.BuildLogLevelFilterRenderer)

Example 10 with OutputEventListener

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);
}
Also used : StyledTextOutputBackedRenderer(org.gradle.internal.logging.console.StyledTextOutputBackedRenderer) StreamingStyledTextOutput(org.gradle.internal.logging.text.StreamingStyledTextOutput) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener) ThrottlingOutputEventListener(org.gradle.internal.logging.console.ThrottlingOutputEventListener) FlushConsoleListener(org.gradle.internal.logging.console.FlushConsoleListener) StreamBackedStandardOutputListener(org.gradle.internal.logging.text.StreamBackedStandardOutputListener)

Aggregations

OutputEventListener (org.gradle.internal.logging.events.OutputEventListener)14 StyledTextOutputBackedRenderer (org.gradle.internal.logging.console.StyledTextOutputBackedRenderer)9 ThrottlingOutputEventListener (org.gradle.internal.logging.console.ThrottlingOutputEventListener)9 StreamBackedStandardOutputListener (org.gradle.internal.logging.text.StreamBackedStandardOutputListener)7 StreamingStyledTextOutput (org.gradle.internal.logging.text.StreamingStyledTextOutput)6 StandardOutputListener (org.gradle.api.logging.StandardOutputListener)3 BuildLogLevelFilterRenderer (org.gradle.internal.logging.console.BuildLogLevelFilterRenderer)2 FlushConsoleListener (org.gradle.internal.logging.console.FlushConsoleListener)2 LogEvent (org.gradle.internal.logging.events.LogEvent)2 LogLevelChangeEvent (org.gradle.internal.logging.events.LogLevelChangeEvent)2 LoggingSourceSystem (org.gradle.internal.logging.config.LoggingSourceSystem)1 LoggingSystemAdapter (org.gradle.internal.logging.config.LoggingSystemAdapter)1 BuildStatusRenderer (org.gradle.internal.logging.console.BuildStatusRenderer)1 DefaultWorkInProgressFormatter (org.gradle.internal.logging.console.DefaultWorkInProgressFormatter)1 UserInputStandardOutputRenderer (org.gradle.internal.logging.console.UserInputStandardOutputRenderer)1 WorkInProgressRenderer (org.gradle.internal.logging.console.WorkInProgressRenderer)1 BatchOutputEventListener (org.gradle.internal.logging.events.BatchOutputEventListener)1 EndOutputEvent (org.gradle.internal.logging.events.EndOutputEvent)1 FlushOutputEvent (org.gradle.internal.logging.events.FlushOutputEvent)1 OutputEvent (org.gradle.internal.logging.events.OutputEvent)1