Java Code Examples for org.gradle.api.logging.LogLevel

The following examples show how to use org.gradle.api.logging.LogLevel. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: Pushjet-Android   Source File: SetupTab.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * This creates an array of wrapper objects suitable for passing to the constructor of the log level combo box.
 */
private Vector<LogLevelWrapper> getLogLevelWrappers() {
    Collection<LogLevel> collection = new LoggingCommandLineConverter().getLogLevels();

    Vector<LogLevelWrapper> wrappers = new Vector<LogLevelWrapper>();

    Iterator<LogLevel> iterator = collection.iterator();

    while (iterator.hasNext()) {
        LogLevel level = iterator.next();
        wrappers.add(new LogLevelWrapper(level));
    }

    Collections.sort(wrappers, new Comparator<LogLevelWrapper>() {
        public int compare(LogLevelWrapper o1, LogLevelWrapper o2) {
            return o1.toString().compareToIgnoreCase(o2.toString());
        }
    });

    return wrappers;
}
 
Example 2
Source Project: pushfish-android   Source File: SetupTab.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
/**
 * This creates an array of wrapper objects suitable for passing to the constructor of the log level combo box.
 */
private Vector<LogLevelWrapper> getLogLevelWrappers() {
    Collection<LogLevel> collection = new LoggingCommandLineConverter().getLogLevels();

    Vector<LogLevelWrapper> wrappers = new Vector<LogLevelWrapper>();

    Iterator<LogLevel> iterator = collection.iterator();

    while (iterator.hasNext()) {
        LogLevel level = iterator.next();
        wrappers.add(new LogLevelWrapper(level));
    }

    Collections.sort(wrappers, new Comparator<LogLevelWrapper>() {
        public int compare(LogLevelWrapper o1, LogLevelWrapper o2) {
            return o1.toString().compareToIgnoreCase(o2.toString());
        }
    });

    return wrappers;
}
 
Example 3
private void doConfigure(LogLevel logLevel) {
    LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
    Logger rootLogger = context.getLogger(Logger.ROOT_LOGGER_NAME);

    if (currentLevel == null) {
        context.reset();
        context.addTurboFilter(new GradleFilter());
        context.getLogger("org.apache.http.wire").setLevel(Level.OFF);
        GradleAppender appender = new GradleAppender();
        appender.setContext(context);
        appender.start();
        rootLogger.addAppender(appender);
    }

    currentLevel = logLevel;
    rootLogger.setLevel(LogLevelConverter.toLogbackLevel(logLevel));
}
 
Example 4
private void renderMultipleBuildExceptions(MultipleBuildFailures multipleFailures) {
    List<? extends Throwable> causes = multipleFailures.getCauses();

    StyledTextOutput output = textOutputFactory.create(BuildExceptionReporter.class, LogLevel.ERROR);
    output.println();
    output.withStyle(Failure).format("FAILURE: Build completed with %s failures.", causes.size());
    output.println();

    for (int i = 0; i < causes.size(); i++) {
        Throwable cause = causes.get(i);
        FailureDetails details = constructFailureDetails("Task", cause);

        output.println();
        output.withStyle(Failure).format("%s: ", i + 1);
        details.summary.writeTo(output.withStyle(Failure));
        output.println();
        output.text("-----------");

        writeFailureDetails(output, details);

        output.println("==============================================================================");
    }
}
 
Example 5
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);
    }
}
 
Example 6
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(new SimpleDateFormat("HH:mm:ss.SSS").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);
    }
}
 
Example 7
Source Project: atlas   Source File: AtlasMultiDexListTransform.java    License: Apache License 2.0 6 votes vote down vote up
public void transform(@NonNull TransformInvocation transformInvocation)
        throws TransformException, InterruptedException, IOException {
    if (mainDexListFile.exists() && !variantScope.getVariantData().getName().toLowerCase().endsWith("release")){
        return;
    }
    LoggingManager loggingManager = transformInvocation.getContext().getLogging();
    loggingManager.captureStandardOutput(LogLevel.INFO);
    loggingManager.captureStandardError(LogLevel.WARN);
    Collection<File> inputs =AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getAllMainDexJars();
    inputs.addAll(AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).getInputDirs());
    if (AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()) == null) {
        super.transform(transformInvocation);
    } else if (AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()).multiDexer == null) {
        super.transform(transformInvocation);
    }
    FastMultiDexer fastMultiDexer = (FastMultiDexer) AtlasBuildContext.androidBuilderMap.get(variantScope.getGlobalScope().getProject()).multiDexer;

    Collection<File>files = fastMultiDexer.repackageJarList(inputs, mainDexListFile,variantScope.getVariantData().getName().toLowerCase().endsWith("release"));

    if (files!= null && files.size() > 0){
        AtlasBuildContext.atlasMainDexHelperMap.get(variantScope.getFullVariantName()).addAllMainDexJars(files);

    }
}
 
Example 8
private void execute(InstallDeployTaskSupport deployTask) {
    LoggingManagerInternal loggingManager = loggingManagerFactory.create();
    loggingManager.captureStandardOutput(LogLevel.INFO).start();
    try {
        deployTask.execute();
    } finally {
        loggingManager.stop();
    }
}
 
Example 9
private void execute(InstallDeployTaskSupport deployTask) {
    loggingManager.captureStandardOutput(LogLevel.INFO).start();
    try {
        deployTask.execute();
    } finally {
        loggingManager.stop();
    }
}
 
Example 10
public DefaultBuildActionParameters(BuildClientMetaData clientMetaData, long startTime, Map<?, ?> systemProperties, Map<String, String> envVariables, File currentDir, LogLevel logLevel) {
    this.clientMetaData = clientMetaData;
    this.startTime = startTime;
    this.currentDir = currentDir;
    this.logLevel = logLevel;
    assert systemProperties != null;
    assert envVariables != null;
    this.systemProperties = new HashMap<String, String>();
    GUtil.addToMap(this.systemProperties, systemProperties);
    this.envVariables = new HashMap<String, String>(envVariables);
}
 
Example 11
Source Project: atlas   Source File: TransformReplacer.java    License: Apache License 2.0 5 votes vote down vote up
public void replaceDexTransform(AppVariantContext appVariantContext, BaseVariantOutput vod) {
    List<TransformTask> baseTransforms = TransformManager.findTransformTaskByTransformType(
            variantContext, DexTransform.class);

    DefaultDexOptions dexOptions = appVariantContext.getAppExtension().getDexOptions();
    DexingType dexingType = appVariantContext.getScope().getDexingType();
    DexByteCodeConverterHook dexByteCodeConverterHook = new DexByteCodeConverterHook(variantContext
            , variantContext.getAppVariantOutputContext(ApkDataUtils.get(vod))
            , LoggerWrapper.getLogger(DexByteCodeConverterHook.class)
            , appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo()
            , new GradleJavaProcessExecutor(appVariantContext.getProject())
            , appVariantContext.getProject().getLogger().isEnabled(LogLevel.INFO)
            , new ExtraModelInfo(appVariantContext.getScope().getGlobalScope().getProjectOptions(), appVariantContext.getProject().getLogger()));

    for (TransformTask transformTask : baseTransforms) {
        DexTransform newTransform = new DexTransform(dexOptions
                , dexingType
                , false
                , appVariantContext.getProject().files(variantContext.getScope().getMainDexListFile())
                , verifyNotNull(appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getTargetInfo(), "Target Info not set.")
                , dexByteCodeConverterHook
                , appVariantContext.getScope().getGlobalScope().getAndroidBuilder().getErrorReporter()
                , variantContext.getScope().getMinSdkVersion().getFeatureLevel());
        ReflectUtils.updateField(transformTask, "transform",
                newTransform);
    }

}
 
Example 12
public Snapshot on(final LogLevel level) {
    Snapshot snapshot = snapshot();
    install();
    this.logLevel = level;
    outputEventListener.onOutput(new LogLevelChangeEvent(logLevel));
    destination.set(listener);
    return snapshot;
}
 
Example 13
public ProgressStartEvent(long operationId, Long parentOperationId, long timestamp, String category, String description, String shortDescription, String loggingHeader, String status) {
    super(timestamp, category, LogLevel.LIFECYCLE);
    this.operationId = operationId;
    this.parentOperationId = parentOperationId;
    this.description = description;
    this.shortDescription = shortDescription;
    this.loggingHeader = loggingHeader;
    this.status = status;
}
 
Example 14
private void execute(InstallDeployTaskSupport deployTask) {
    loggingManager.captureStandardOutput(LogLevel.INFO).start();
    try {
        deployTask.execute();
    } finally {
        loggingManager.stop();
    }
}
 
Example 15
Source Project: pushfish-android   Source File: SetupTab.java    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
private LogLevelWrapper(LogLevel logLevel) {
    this.logLevel = logLevel;

    String temp = logLevel.toString().toLowerCase().replace('_', ' '); //replace underscores in the name with spaces
    this.toString = Character.toUpperCase(temp.charAt(0)) + temp.substring(1);

    //add the command line character to the end (so if an error message says use a log level, you can easily translate)
    String commandLineCharacter = new LoggingCommandLineConverter().getLogLevelCommandLine(logLevel);
    if (commandLineCharacter != null && !commandLineCharacter.equals("")) {
        this.toString += " (-" + commandLineCharacter + ")";
    }
}
 
Example 16
@Override
protected void append(ILoggingEvent event) {
    try {
        ThrowableProxy throwableProxy = (ThrowableProxy) event.getThrowableProxy();
        Throwable throwable = throwableProxy == null ? null : throwableProxy.getThrowable();
        String message = event.getFormattedMessage();
        LogLevel level = LogLevelConverter.toGradleLogLevel(event.getLevel(), event.getMarker());
        outputEventListener.onOutput(new LogEvent(event.getTimeStamp(), event.getLoggerName(), level, message, throwable));
    } catch (Throwable t) {
        // fall back to standard out
        t.printStackTrace(defaultStandardOut);
    }
}
 
Example 17
public DefaultLoggingManager(LoggingSystem loggingSystem, LoggingSystem stdOutLoggingSystem,
                             LoggingSystem stdErrLoggingSystem, LoggingOutputInternal loggingOutput) {
    this.loggingOutput = loggingOutput;
    this.loggingSystem = new StartableLoggingSystem(loggingSystem, null);
    this.stdOutLoggingSystem = new StartableLoggingSystem(stdOutLoggingSystem, LogLevel.QUIET);
    this.stdErrLoggingSystem = new StartableLoggingSystem(stdErrLoggingSystem, LogLevel.ERROR);
}
 
Example 18
public <R extends Serializable, P extends Serializable> RhinoWorkerHandle<R, P> create(Iterable<File> rhinoClasspath, RhinoWorkerSpec<R, P> workerSpec, LogLevel logLevel, Action<JavaExecSpec> javaExecSpecAction) {
    WorkerProcessBuilder builder = workerProcessBuilderFactory.create();
    builder.setBaseName("Gradle Rhino Worker");
    builder.setLogLevel(logLevel);
    builder.applicationClasspath(rhinoClasspath);
    builder.sharedPackages("org.mozilla.javascript");

    JavaExecHandleBuilder javaCommand = builder.getJavaCommand();
    if (javaExecSpecAction != null) {
        javaExecSpecAction.execute(javaCommand);
    }

    WorkerProcess workerProcess = builder.worker(new RhinoServer<R, P>(workerSpec)).build();
    return new DefaultRhinoWorkerHandle<R, P>(workerSpec.getResultType(), workerProcess);
}
 
Example 19
public ProgressStartEvent(long operationId, Long parentOperationId, long timestamp, String category, String description, String shortDescription, String loggingHeader, String status) {
    super(timestamp, category, LogLevel.LIFECYCLE);
    this.operationId = operationId;
    this.parentOperationId = parentOperationId;
    this.description = description;
    this.shortDescription = shortDescription;
    this.loggingHeader = loggingHeader;
    this.status = status;
}
 
Example 20
public DownPluginDefinition(String name) {
    this.name = name;

    try {
        this.plugin = DownPlugin.valueOf(name.replace('-', '_').toUpperCase(Locale.ROOT));
    } catch (IllegalArgumentException e) {
        LOGGER.log(LogLevel.ERROR, "Could not determine Charm Down Plugin for name '" + name + "'. The following plugins are available: " + Stream.of(DownPlugin.values()).map(DownPlugin::getPluginName).collect(Collectors.joining(", ")));
        throw new GradleException("Invalid name for Charm Down plugin: " + name, e);
    }
}
 
Example 21
private OutputEventListener onNonError(final OutputEventListener listener) {
    return new OutputEventListener() {
        public void onOutput(OutputEvent event) {
            if (event.getLogLevel() != LogLevel.ERROR || event.getLogLevel() == null) {
                listener.onOutput(event);
            }
        }
    };
}
 
Example 22
public DefaultLoggingManager(LoggingSystem loggingSystem, LoggingSystem stdOutLoggingSystem,
                             LoggingSystem stdErrLoggingSystem, LoggingOutputInternal loggingOutput) {
    this.loggingOutput = loggingOutput;
    this.loggingSystem = new StartableLoggingSystem(loggingSystem, null);
    this.stdOutLoggingSystem = new StartableLoggingSystem(stdOutLoggingSystem, LogLevel.QUIET);
    this.stdErrLoggingSystem = new StartableLoggingSystem(stdErrLoggingSystem, LogLevel.ERROR);
}
 
Example 23
@Override
public FilterReply decide(Marker marker, Logger logger, Level level, String format, Object[] params, Throwable t) {
    Level loggerLevel = logger.getEffectiveLevel();
    if (loggerLevel == Level.INFO && (level == Level.INFO || level == Level.WARN)
            || level == Level.INFO && (loggerLevel == Level.INFO || loggerLevel == Level.WARN)) {
        // Need to take into account Gradle's LIFECYCLE and QUIET markers. Whether those are set can only be determined
        // for the global log level, but not for the logger's log level (at least not without walking the logger's
        // hierarchy, which is something that Logback is designed to avoid for performance reasons).
        // Hence we base our decision on the global log level.
        LogLevel eventLevel = LogLevelConverter.toGradleLogLevel(level, marker);
        return eventLevel.compareTo(currentLevel) >= 0 ? FilterReply.ACCEPT : FilterReply.DENY;
    }

    return level.isGreaterOrEqual(loggerLevel) ? FilterReply.ACCEPT : FilterReply.DENY;
}
 
Example 24
public ProgressStartEvent(long operationId, Long parentOperationId, long timestamp, String category, String description, String shortDescription, String loggingHeader, String status) {
    super(timestamp, category, LogLevel.LIFECYCLE);
    this.operationId = operationId;
    this.parentOperationId = parentOperationId;
    this.description = description;
    this.shortDescription = shortDescription;
    this.loggingHeader = loggingHeader;
    this.status = status;
}
 
Example 25
public AbstractGradleServerProtocol(File currentDirectory, File gradleHomeDirectory, File customGradleExecutor, String fullCommandLine, LogLevel logLevel,
                                    ShowStacktrace stackTraceLevel) {
    this.currentDirectory = currentDirectory;
    this.gradleHomeDirectory = gradleHomeDirectory;
    this.customGradleExecutor = customGradleExecutor;
    this.commandLine = fullCommandLine;
    this.logLevel = logLevel;
    this.stackTraceLevel = stackTraceLevel;
}
 
Example 26
@Override
protected void append(ILoggingEvent event) {
    try {
        ThrowableProxy throwableProxy = (ThrowableProxy) event.getThrowableProxy();
        Throwable throwable = throwableProxy == null ? null : throwableProxy.getThrowable();
        String message = event.getFormattedMessage();
        LogLevel level = LogLevelConverter.toGradleLogLevel(event.getLevel(), event.getMarker());
        outputEventListener.onOutput(new LogEvent(event.getTimeStamp(), event.getLoggerName(), level, message, throwable));
    } catch (Throwable t) {
        // fall back to standard out
        t.printStackTrace(defaultStandardOut);
    }
}
 
Example 27
@Override
protected void append(ILoggingEvent event) {
    try {
        ThrowableProxy throwableProxy = (ThrowableProxy) event.getThrowableProxy();
        Throwable throwable = throwableProxy == null ? null : throwableProxy.getThrowable();
        String message = event.getFormattedMessage();
        LogLevel level = LogLevelConverter.toGradleLogLevel(event.getLevel(), event.getMarker());
        outputEventListener.onOutput(new LogEvent(event.getTimeStamp(), event.getLoggerName(), level, message, throwable));
    } catch (Throwable t) {
        // fall back to standard out
        t.printStackTrace(defaultStandardOut);
    }
}
 
Example 28
public void setLogLevel(LogLevel logLevel) {
    this.logLevel = logLevel;
}
 
Example 29
public LogLevel getNewLogLevel() {
    return newLogLevel;
}
 
Example 30
public StyledTextOutputEvent(long timestamp, String category, LogLevel logLevel, Span... spans) {
    this(timestamp, category, logLevel, Arrays.asList(spans));
}