Search in sources :

Example 1 with LogEvent

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

the class LogEventSerializer method read.

@Override
public LogEvent read(Decoder decoder) throws Exception {
    long timestamp = decoder.readLong();
    String category = decoder.readString();
    LogLevel logLevel = logLevelSerializer.read(decoder);
    String message = decoder.readString();
    Throwable throwable = throwableSerializer.read(decoder);
    return new LogEvent(timestamp, category, logLevel, message, throwable);
}
Also used : LogEvent(org.gradle.internal.logging.events.LogEvent) LogLevel(org.gradle.api.logging.LogLevel)

Example 2 with LogEvent

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

the class OutputEventListenerBackedLogger method log.

private void log(LogLevel logLevel, Throwable throwable, String message) {
    LogEvent logEvent = new LogEvent(timeProvider.getCurrentTime(), name, logLevel, message, throwable);
    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) OutputEventListener(org.gradle.internal.logging.events.OutputEventListener)

Example 3 with LogEvent

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

the class LoggingTest method expectLogMessage.

private void expectLogMessage(final LogLevel level, final String text) {
    final Matcher<LogEvent> matcher = new BaseMatcher<LogEvent>() {

        public void describeTo(Description description) {
            description.appendText("level: ").appendValue(level).appendText(", text:").appendValue(text);
        }

        public boolean matches(Object o) {
            LogEvent event = (LogEvent) o;
            return event.getLogLevel() == level && event.getMessage().equals(text);
        }
    };
    context.checking(new Expectations() {

        {
            one(outputEventListener).onOutput(with(matcher));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) LogEvent(org.gradle.internal.logging.events.LogEvent)

Aggregations

LogEvent (org.gradle.internal.logging.events.LogEvent)3 LogLevel (org.gradle.api.logging.LogLevel)1 OutputEventListener (org.gradle.internal.logging.events.OutputEventListener)1 BaseMatcher (org.hamcrest.BaseMatcher)1 Description (org.hamcrest.Description)1 Expectations (org.jmock.Expectations)1