Search in sources :

Example 1 with LogLevel

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

the class SetupTab method createLogLevelPanel.

/**
     * Creates a panel that has a combo box to select a log level
     */
private Component createLogLevelPanel() {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    logLevelComboBox = new JComboBox(getLogLevelWrappers());
    panel.add(Utility.addLeftJustifiedComponent(new JLabel("Log Level")));
    panel.add(Utility.addLeftJustifiedComponent(logLevelComboBox));
    //initialize our value
    String logLevelName = settingsNode.getValueOfChild(LOG_LEVEL, null);
    LogLevel logLevel = gradlePluginLord.getLogLevel();
    if (logLevelName != null) {
        try {
            logLevel = LogLevel.valueOf(logLevelName);
        } catch (IllegalArgumentException e) {
            //this may happen if the enum changes. We don't want this to stop the whole UI
            logger.error("Converting log level text to log level enum '" + logLevelName + "'", e);
        }
    }
    gradlePluginLord.setLogLevel(logLevel);
    setLogLevelComboBoxSetting(logLevel);
    logLevelComboBox.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            LogLevelWrapper wrapper = (LogLevelWrapper) logLevelComboBox.getSelectedItem();
            if (wrapper != null) {
                gradlePluginLord.setLogLevel(wrapper.logLevel);
                settingsNode.setValueOfChild(LOG_LEVEL, wrapper.logLevel.name());
            }
        }
    });
    return panel;
}
Also used : ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) LogLevel(org.gradle.api.logging.LogLevel)

Example 2 with LogLevel

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

the class SetupTab method getLogLevelWrappers.

/**
     * 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;
}
Also used : LoggingCommandLineConverter(org.gradle.internal.logging.LoggingCommandLineConverter) LogLevel(org.gradle.api.logging.LogLevel)

Example 3 with LogLevel

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

the class DaemonMessageSerializer method create.

public static Serializer<Message> create() {
    BaseSerializerFactory factory = new BaseSerializerFactory();
    Serializer<LogLevel> logLevelSerializer = factory.getSerializerFor(LogLevel.class);
    Serializer<Throwable> throwableSerializer = factory.getSerializerFor(Throwable.class);
    DefaultSerializerRegistry registry = new DefaultSerializerRegistry();
    registry.register(BuildEvent.class, new BuildEventSerializer());
    registry.register(Failure.class, new FailureSerializer(throwableSerializer));
    // Input events
    registry.register(ForwardInput.class, new ForwardInputSerializer());
    registry.register(CloseInput.class, new CloseInputSerializer());
    // Output events
    registry.register(LogEvent.class, new LogEventSerializer(logLevelSerializer, throwableSerializer));
    registry.register(StyledTextOutputEvent.class, new StyledTextOutputEventSerializer(logLevelSerializer, new ListSerializer<StyledTextOutputEvent.Span>(new SpanSerializer(factory.getSerializerFor(StyledTextOutput.Style.class)))));
    registry.register(ProgressStartEvent.class, new ProgressStartEventSerializer());
    registry.register(ProgressCompleteEvent.class, new ProgressCompleteEventSerializer());
    registry.register(ProgressEvent.class, new ProgressEventSerializer());
    registry.register(LogLevelChangeEvent.class, new LogLevelChangeEventSerializer(logLevelSerializer));
    registry.register(OutputMessage.class, new OutputMessageSerializer(registry.build(OutputEvent.class)));
    // Default for everything else
    registry.useJavaSerialization(Message.class);
    return registry.build(Message.class);
}
Also used : LogLevelChangeEventSerializer(org.gradle.internal.logging.serializer.LogLevelChangeEventSerializer) ListSerializer(org.gradle.internal.serialize.ListSerializer) SpanSerializer(org.gradle.internal.logging.serializer.SpanSerializer) DefaultSerializerRegistry(org.gradle.internal.serialize.DefaultSerializerRegistry) StyledTextOutput(org.gradle.internal.logging.text.StyledTextOutput) ProgressEventSerializer(org.gradle.internal.logging.serializer.ProgressEventSerializer) ProgressCompleteEventSerializer(org.gradle.internal.logging.serializer.ProgressCompleteEventSerializer) LogLevel(org.gradle.api.logging.LogLevel) LogEventSerializer(org.gradle.internal.logging.serializer.LogEventSerializer) BaseSerializerFactory(org.gradle.internal.serialize.BaseSerializerFactory) StyledTextOutputEventSerializer(org.gradle.internal.logging.serializer.StyledTextOutputEventSerializer) StyledTextOutputEvent(org.gradle.internal.logging.events.StyledTextOutputEvent)

Example 4 with LogLevel

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

the class ProviderConnection method configure.

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

Example 5 with LogLevel

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

the class TemplateCompilerTask method compileImpl.

public void compileImpl(TemplateCompileOptions options) throws IOException {
    File buildDir = getProject().getBuildDir();
    //need to make customizable...
    File groovySrcGen = new File(buildDir, "groovysrc");
    System.out.println("groovy src directory=" + groovySrcGen);
    Charset encoding = Charset.forName(options.getEncoding());
    TemplateCompileConfig config = new TemplateCompileConfig(false);
    config.setFileEncoding(encoding);
    config.setPluginClient(true);
    config.setGroovySrcWriteDirectory(groovySrcGen);
    System.out.println("custom tags=" + options.getCustomTags());
    config.setCustomTagsFromPlugin(options.getCustomTags());
    LogLevel logLevel = getProject().getGradle().getStartParameter().getLogLevel();
    File destinationDir = getDestinationDir();
    System.out.println("destDir=" + destinationDir);
    File routeIdFile = new File(destinationDir, ProdTemplateModule.ROUTE_META_FILE);
    if (routeIdFile.exists())
        routeIdFile.delete();
    routeIdFile.createNewFile();
    System.out.println("routeId.txt file=" + routeIdFile.getAbsolutePath());
    FileCollection srcCollection = getSource();
    Set<File> files = srcCollection.getFiles();
    File firstFile = files.iterator().next();
    File baseDir = findBase(firstFile);
    try (FileOutputStream routeOut = new FileOutputStream(routeIdFile);
        OutputStreamWriter write = new OutputStreamWriter(routeOut, encoding.name());
        BufferedWriter bufWrite = new BufferedWriter(write)) {
        Injector injector = Guice.createInjector(new StubModule(), new DevTemplateModule(config, new PluginCompileCallback(destinationDir, bufWrite)));
        HtmlToJavaClassCompiler compiler = injector.getInstance(HtmlToJavaClassCompiler.class);
        GroovyClassLoader cl = new GroovyClassLoader();
        for (File f : files) {
            System.out.println("file=" + f);
            String fullName = findFullName(baseDir, f);
            System.out.println("name=" + fullName);
            String source = readSource(f);
            compiler.compile(cl, fullName, source);
        }
    }
    setDidWork(true);
}
Also used : Charset(java.nio.charset.Charset) HtmlToJavaClassCompiler(org.webpieces.templatingdev.impl.HtmlToJavaClassCompiler) FileCollection(org.gradle.api.file.FileCollection) LogLevel(org.gradle.api.logging.LogLevel) BufferedWriter(java.io.BufferedWriter) GroovyClassLoader(groovy.lang.GroovyClassLoader) StubModule(org.webpieces.templatingdev.api.StubModule) DevTemplateModule(org.webpieces.templatingdev.api.DevTemplateModule) Injector(com.google.inject.Injector) FileOutputStream(java.io.FileOutputStream) TemplateCompileConfig(org.webpieces.templatingdev.api.TemplateCompileConfig) OutputStreamWriter(java.io.OutputStreamWriter) File(java.io.File)

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