Search in sources :

Example 1 with LogLevelChangeEvent

use of org.gradle.internal.logging.events.LogLevelChangeEvent in project gradle by gradle.

the class OutputEventRenderer method onOutput.

@Override
public void onOutput(OutputEvent event) {
    synchronized (lock) {
        if (event.getLogLevel() != null && event.getLogLevel().compareTo(logLevel) < 0) {
            return;
        }
        if (event instanceof LogLevelChangeEvent) {
            LogLevelChangeEvent changeEvent = (LogLevelChangeEvent) event;
            LogLevel newLogLevel = changeEvent.getNewLogLevel();
            if (newLogLevel == this.logLevel) {
                return;
            }
            this.logLevel = newLogLevel;
        }
        formatters.getSource().onOutput(event);
    }
}
Also used : LogLevelChangeEvent(org.gradle.internal.logging.events.LogLevelChangeEvent) LogLevel(org.gradle.api.logging.LogLevel)

Example 2 with LogLevelChangeEvent

use of org.gradle.internal.logging.events.LogLevelChangeEvent in project gradle by gradle.

the class StyledTextOutputBackedRenderer method onOutput.

public void onOutput(OutputEvent event) {
    if (event instanceof LogLevelChangeEvent) {
        LogLevelChangeEvent changeEvent = (LogLevelChangeEvent) event;
        debugOutput = changeEvent.getNewLogLevel() == LogLevel.DEBUG;
    }
    if (event instanceof RenderableOutputEvent) {
        RenderableOutputEvent outputEvent = (RenderableOutputEvent) event;
        textOutput.style(outputEvent.getLogLevel() == LogLevel.ERROR ? Error : Normal);
        if (debugOutput && (textOutput.atEndOfLine || lastEvent == null || !lastEvent.getCategory().equals(outputEvent.getCategory()))) {
            if (!textOutput.atEndOfLine) {
                textOutput.println();
            }
            textOutput.text(dateFormat.format(new Date(outputEvent.getTimestamp())));
            textOutput.text(" [");
            textOutput.text(outputEvent.getLogLevel());
            textOutput.text("] [");
            textOutput.text(outputEvent.getCategory());
            textOutput.text("] ");
        }
        outputEvent.render(textOutput);
        lastEvent = outputEvent;
        textOutput.style(Normal);
    }
}
Also used : LogLevelChangeEvent(org.gradle.internal.logging.events.LogLevelChangeEvent) RenderableOutputEvent(org.gradle.internal.logging.events.RenderableOutputEvent) Date(java.util.Date)

Example 3 with LogLevelChangeEvent

use of org.gradle.internal.logging.events.LogLevelChangeEvent in project gradle by gradle.

the class PrintStreamLoggingSystem method install.

private void install() {
    if (original == null) {
        PrintStream originalStream = get();
        original = new PrintStreamDestination(originalStream);
    }
    enabled = true;
    outstr.flush();
    outputEventListener.onOutput(new LogLevelChangeEvent(logLevel));
    destination.set(listener);
    if (get() != outstr) {
        set(outstr);
    }
}
Also used : LogLevelChangeEvent(org.gradle.internal.logging.events.LogLevelChangeEvent) PrintStream(java.io.PrintStream)

Example 4 with LogLevelChangeEvent

use of org.gradle.internal.logging.events.LogLevelChangeEvent in project gradle by gradle.

the class PrintStreamLoggingSystem method setLevel.

@Override
public Snapshot setLevel(LogLevel logLevel) {
    Snapshot snapshot = snapshot();
    if (logLevel != this.logLevel) {
        this.logLevel = logLevel;
        if (enabled) {
            outstr.flush();
            outputEventListener.onOutput(new LogLevelChangeEvent(logLevel));
        }
    }
    return snapshot;
}
Also used : LogLevelChangeEvent(org.gradle.internal.logging.events.LogLevelChangeEvent)

Example 5 with LogLevelChangeEvent

use of org.gradle.internal.logging.events.LogLevelChangeEvent in project gradle by gradle.

the class OutputEventRenderer method addConsole.

public OutputEventRenderer addConsole(Console console, boolean stdout, boolean stderr, ConsoleMetaData consoleMetaData) {
    final OutputEventListener consoleChain = new ThrottlingOutputEventListener(new BuildStatusRenderer(new WorkInProgressRenderer(new ProgressLogEventGenerator(new StyledTextOutputBackedRenderer(console.getBuildOutputArea()), true), console.getBuildProgressArea(), new DefaultWorkInProgressFormatter(consoleMetaData)), console.getStatusBar(), console, consoleMetaData), new TrueTimeProvider());
    synchronized (lock) {
        if (stdout && stderr) {
            this.console = consoleChain;
            removeStandardOutputListener();
            removeStandardErrorListener();
        } else if (stdout) {
            this.console = onNonError(consoleChain);
            removeStandardOutputListener();
        } else {
            this.console = onError(consoleChain);
            removeStandardErrorListener();
        }
        consoleChain.onOutput(new LogLevelChangeEvent(logLevel));
        formatters.add(this.console);
    }
    return this;
}
Also used : LogLevelChangeEvent(org.gradle.internal.logging.events.LogLevelChangeEvent) BuildStatusRenderer(org.gradle.internal.logging.console.BuildStatusRenderer) ThrottlingOutputEventListener(org.gradle.internal.logging.console.ThrottlingOutputEventListener) StyledTextOutputBackedRenderer(org.gradle.internal.logging.console.StyledTextOutputBackedRenderer) TrueTimeProvider(org.gradle.internal.time.TrueTimeProvider) WorkInProgressRenderer(org.gradle.internal.logging.console.WorkInProgressRenderer) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener) BatchOutputEventListener(org.gradle.internal.logging.events.BatchOutputEventListener) ThrottlingOutputEventListener(org.gradle.internal.logging.console.ThrottlingOutputEventListener) DefaultWorkInProgressFormatter(org.gradle.internal.logging.console.DefaultWorkInProgressFormatter)

Aggregations

LogLevelChangeEvent (org.gradle.internal.logging.events.LogLevelChangeEvent)5 PrintStream (java.io.PrintStream)1 Date (java.util.Date)1 LogLevel (org.gradle.api.logging.LogLevel)1 BuildStatusRenderer (org.gradle.internal.logging.console.BuildStatusRenderer)1 DefaultWorkInProgressFormatter (org.gradle.internal.logging.console.DefaultWorkInProgressFormatter)1 StyledTextOutputBackedRenderer (org.gradle.internal.logging.console.StyledTextOutputBackedRenderer)1 ThrottlingOutputEventListener (org.gradle.internal.logging.console.ThrottlingOutputEventListener)1 WorkInProgressRenderer (org.gradle.internal.logging.console.WorkInProgressRenderer)1 BatchOutputEventListener (org.gradle.internal.logging.events.BatchOutputEventListener)1 OutputEventListener (org.gradle.internal.logging.events.OutputEventListener)1 RenderableOutputEvent (org.gradle.internal.logging.events.RenderableOutputEvent)1 TrueTimeProvider (org.gradle.internal.time.TrueTimeProvider)1