org.gradle.api.logging.LogLevel Java Examples

The following examples show how to use org.gradle.api.logging.LogLevel. 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 File: SetupTab.java    From Pushjet-Android with 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 File: AtlasMultiDexListTransform.java    From atlas with 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 #3
Source File: StyledTextOutputBackedRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #4
Source File: OutputEventRenderer.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #5
Source File: LogbackLoggingConfigurer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #6
Source File: SetupTab.java    From pushfish-android with 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 #7
Source File: BuildExceptionReporter.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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 #8
Source File: LogbackLoggingConfigurer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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 #9
Source File: AbstractMavenResolver.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void execute(InstallDeployTaskSupport deployTask) {
    loggingManager.captureStandardOutput(LogLevel.INFO).start();
    try {
        deployTask.execute();
    } finally {
        loggingManager.stop();
    }
}
 
Example #10
Source File: DefaultBuildActionParameters.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 File: TransformReplacer.java    From atlas with 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
Source File: PrintStreamLoggingSystem.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: SetupTab.java    From pushfish-android with 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 #14
Source File: ProgressStartEvent.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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 #15
Source File: AbstractAntTaskBackedMavenPublisher.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void execute(InstallDeployTaskSupport deployTask) {
    LoggingManagerInternal loggingManager = loggingManagerFactory.create();
    loggingManager.captureStandardOutput(LogLevel.INFO).start();
    try {
        deployTask.execute();
    } finally {
        loggingManager.stop();
    }
}
 
Example #16
Source File: LogbackLoggingConfigurer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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
Source File: DefaultLoggingManager.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: DefaultRhinoWorkerHandleFactory.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: ProgressStartEvent.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: DownPluginDefinition.java    From javafxmobile-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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
Source File: OutputEventRenderer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: DefaultLoggingManager.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: LogbackLoggingConfigurer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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
Source File: ProgressStartEvent.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: AbstractGradleServerProtocol.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
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
Source File: LogbackLoggingConfigurer.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@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
Source File: AbstractMavenResolver.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void execute(InstallDeployTaskSupport deployTask) {
    loggingManager.captureStandardOutput(LogLevel.INFO).start();
    try {
        deployTask.execute();
    } finally {
        loggingManager.stop();
    }
}
 
Example #28
Source File: LoggingConfiguration.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public LogLevel getLogLevel() {
    return logLevel;
}
 
Example #29
Source File: StyledTextOutputEvent.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public StyledTextOutputEvent(long timestamp, String category, LogLevel logLevel, Span... spans) {
    this(timestamp, category, logLevel, Arrays.asList(spans));
}
 
Example #30
Source File: WorkerProcessBuilder.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void setLogLevel(LogLevel logLevel) {
    this.logLevel = logLevel;
}