Search in sources :

Example 6 with LogLevel

use of org.gradle.api.logging.LogLevel in project gradle by gradle.

the class ResolveBuildCacheKeyExecuter method doResolve.

private TaskOutputCachingBuildCacheKey doResolve(TaskInternal task, TaskExecutionContext context) {
    TaskArtifactState taskState = context.getTaskArtifactState();
    TaskOutputCachingBuildCacheKey cacheKey = taskState.calculateCacheKey();
    if (context.getTaskProperties().hasDeclaredOutputs()) {
        // A task with no outputs and no cache key.
        if (cacheKey.isValid()) {
            LogLevel logLevel = buildCacheDebugLogging ? LogLevel.LIFECYCLE : LogLevel.INFO;
            LOGGER.log(logLevel, "Build cache key for {} is {}", task, cacheKey.getHashCode());
        }
    }
    return cacheKey;
}
Also used : TaskArtifactState(org.gradle.api.internal.changedetection.TaskArtifactState) TaskOutputCachingBuildCacheKey(org.gradle.caching.internal.tasks.TaskOutputCachingBuildCacheKey) LogLevel(org.gradle.api.logging.LogLevel)

Example 7 with LogLevel

use of org.gradle.api.logging.LogLevel in project gradle by gradle.

the class ProviderConnection method configure.

public void configure(ProviderConnectionParameters parameters, GradleVersion consumerVersion) {
    this.consumerVersion = consumerVersion;
    LogLevel providerLogLevel = parameters.getVerboseLogging() ? LogLevel.DEBUG : LogLevel.INFO;
    LOGGER.debug("Configuring logging to level: {}", providerLogLevel);
    LoggingManagerInternal loggingManager = sharedServices.newInstance(LoggingManagerInternal.class);
    loggingManager.setLevelInternal(providerLogLevel);
    loggingManager.start();
}
Also used : LoggingManagerInternal(org.gradle.internal.logging.LoggingManagerInternal) LogLevel(org.gradle.api.logging.LogLevel)

Example 8 with LogLevel

use of org.gradle.api.logging.LogLevel in project gradle by gradle.

the class AntLoggingAdapter method messageLogged.

@Override
public void messageLogged(BuildEvent event) {
    final StringBuffer message = new StringBuffer();
    if (event.getTask() != null) {
        String taskName = event.getTask().getTaskName();
        message.append("[ant:").append(taskName).append("] ");
    }
    final String messageText = event.getMessage();
    message.append(messageText);
    LogLevel level = getLogLevelForMessagePriority(event.getPriority());
    if (event.getException() != null) {
        logger.log(level, message.toString(), event.getException());
    } else {
        logger.log(level, message.toString());
    }
}
Also used : LogLevel(org.gradle.api.logging.LogLevel)

Example 9 with LogLevel

use of org.gradle.api.logging.LogLevel in project gradle by gradle.

the class AbstractTestTask method executeTests.

@TaskAction
public void executeTests() {
    LogLevel currentLevel = determineCurrentLogLevel();
    TestLogging levelLogging = getTestLogging().get(currentLevel);
    TestExceptionFormatter exceptionFormatter = getExceptionFormatter(levelLogging);
    TestEventLogger eventLogger = new TestEventLogger(getTextOutputFactory(), currentLevel, levelLogging, exceptionFormatter);
    addTestListener(eventLogger);
    addTestOutputListener(eventLogger);
    TestExecutionSpec executionSpec = createTestExecutionSpec();
    final File binaryResultsDir = getBinaryResultsDirectory().getAsFile().get();
    FileSystemOperations fs = getFileSystemOperations();
    fs.delete(new Action<DeleteSpec>() {

        @Override
        public void execute(DeleteSpec spec) {
            spec.delete(binaryResultsDir);
        }
    });
    binaryResultsDir.mkdirs();
    Map<String, TestClassResult> results = new HashMap<String, TestClassResult>();
    TestOutputStore testOutputStore = new TestOutputStore(binaryResultsDir);
    TestOutputStore.Writer outputWriter = testOutputStore.writer();
    TestReportDataCollector testReportDataCollector = new TestReportDataCollector(results, outputWriter);
    addTestListener(testReportDataCollector);
    addTestOutputListener(testReportDataCollector);
    TestCountLogger testCountLogger = new TestCountLogger(getProgressLoggerFactory());
    addTestListener(testCountLogger);
    getTestListenerInternalBroadcaster().add(new TestListenerAdapter(testListenerBroadcaster.getSource(), getTestOutputListenerBroadcaster().getSource()));
    ProgressLogger parentProgressLogger = getProgressLoggerFactory().newOperation(AbstractTestTask.class);
    parentProgressLogger.setDescription("Test Execution");
    parentProgressLogger.started();
    TestWorkerProgressListener testWorkerProgressListener = new TestWorkerProgressListener(getProgressLoggerFactory(), parentProgressLogger);
    getTestListenerInternalBroadcaster().add(testWorkerProgressListener);
    TestExecuter<TestExecutionSpec> testExecuter = Cast.uncheckedNonnullCast(createTestExecuter());
    TestListenerInternal resultProcessorDelegate = getTestListenerInternalBroadcaster().getSource();
    if (failFast) {
        resultProcessorDelegate = new FailFastTestListenerInternal(testExecuter, resultProcessorDelegate);
    }
    TestResultProcessor resultProcessor = new StateTrackingTestResultProcessor(resultProcessorDelegate);
    try {
        testExecuter.execute(executionSpec, resultProcessor);
    } finally {
        parentProgressLogger.completed();
        testWorkerProgressListener.completeAll();
        testListenerBroadcaster.removeAll();
        getTestOutputListenerBroadcaster().removeAll();
        getTestListenerInternalBroadcaster().removeAll();
        outputWriter.close();
    }
    new TestResultSerializer(binaryResultsDir).write(results.values());
    createReporting(results, testOutputStore);
    handleCollectedResults(testCountLogger);
}
Also used : TestResultSerializer(org.gradle.api.internal.tasks.testing.junit.result.TestResultSerializer) HashMap(java.util.HashMap) TestResultProcessor(org.gradle.api.internal.tasks.testing.TestResultProcessor) StateTrackingTestResultProcessor(org.gradle.api.internal.tasks.testing.results.StateTrackingTestResultProcessor) TestClassResult(org.gradle.api.internal.tasks.testing.junit.result.TestClassResult) TestCountLogger(org.gradle.api.internal.tasks.testing.logging.TestCountLogger) ProgressLogger(org.gradle.internal.logging.progress.ProgressLogger) StateTrackingTestResultProcessor(org.gradle.api.internal.tasks.testing.results.StateTrackingTestResultProcessor) TestExecutionSpec(org.gradle.api.internal.tasks.testing.TestExecutionSpec) FileSystemOperations(org.gradle.api.file.FileSystemOperations) LogLevel(org.gradle.api.logging.LogLevel) TestEventLogger(org.gradle.api.internal.tasks.testing.logging.TestEventLogger) TestWorkerProgressListener(org.gradle.api.internal.tasks.testing.logging.TestWorkerProgressListener) DeleteSpec(org.gradle.api.file.DeleteSpec) FailFastTestListenerInternal(org.gradle.api.internal.tasks.testing.FailFastTestListenerInternal) TestReportDataCollector(org.gradle.api.internal.tasks.testing.junit.result.TestReportDataCollector) TestLogging(org.gradle.api.tasks.testing.logging.TestLogging) TestListenerInternal(org.gradle.api.internal.tasks.testing.results.TestListenerInternal) FailFastTestListenerInternal(org.gradle.api.internal.tasks.testing.FailFastTestListenerInternal) TestListenerAdapter(org.gradle.api.internal.tasks.testing.results.TestListenerAdapter) TestOutputStore(org.gradle.api.internal.tasks.testing.junit.result.TestOutputStore) TestExceptionFormatter(org.gradle.api.internal.tasks.testing.logging.TestExceptionFormatter) File(java.io.File) TaskAction(org.gradle.api.tasks.TaskAction)

Example 10 with LogLevel

use of org.gradle.api.logging.LogLevel in project gradle by gradle.

the class OutputEventRenderer method onOutput.

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

Aggregations

LogLevel (org.gradle.api.logging.LogLevel)20 File (java.io.File)6 IOException (java.io.IOException)3 UncheckedIOException (org.gradle.api.UncheckedIOException)3 TaskAction (org.gradle.api.tasks.TaskAction)3 LogEventSerializer (org.gradle.internal.logging.serializer.LogEventSerializer)3 LogLevelChangeEventSerializer (org.gradle.internal.logging.serializer.LogLevelChangeEventSerializer)3 Injector (com.google.inject.Injector)2 GroovyClassLoader (groovy.lang.GroovyClassLoader)2 BufferedWriter (java.io.BufferedWriter)2 DataOutputStream (java.io.DataOutputStream)2 FileOutputStream (java.io.FileOutputStream)2 OutputStreamWriter (java.io.OutputStreamWriter)2 URL (java.net.URL)2 Charset (java.nio.charset.Charset)2 Map (java.util.Map)2 FileCollection (org.gradle.api.file.FileCollection)2 StreamByteBuffer (org.gradle.internal.io.StreamByteBuffer)2 LoggingManagerInternal (org.gradle.internal.logging.LoggingManagerInternal)2 StyledTextOutputEvent (org.gradle.internal.logging.events.StyledTextOutputEvent)2