From b7a0ebf5053548c52bdba560320b38087c447ced Mon Sep 17 00:00:00 2001 From: Costin Leau Date: Wed, 18 Jul 2012 16:18:33 +0300 Subject: [PATCH] polishing --- .../shell/core/JLineLogHandler.java | 5 +- .../shell/support/api/AddOnSearch.java | 53 ------------------- .../shell/support/logging/HandlerUtils.java | 5 +- src/main/resources/log4j.properties | 12 ++++- src/test/resources/log4j.properties | 12 ++++- 5 files changed, 29 insertions(+), 58 deletions(-) delete mode 100644 src/main/java/org/springframework/shell/support/api/AddOnSearch.java diff --git a/src/main/java/org/springframework/shell/core/JLineLogHandler.java b/src/main/java/org/springframework/shell/core/JLineLogHandler.java index 6597a865..b2727f69 100644 --- a/src/main/java/org/springframework/shell/core/JLineLogHandler.java +++ b/src/main/java/org/springframework/shell/core/JLineLogHandler.java @@ -39,7 +39,10 @@ import org.springframework.shell.support.util.StringUtils; public class JLineLogHandler extends Handler { // Constants - private static final boolean BRIGHT_COLORS = Boolean.getBoolean("roo.bright"); + private static final boolean ROO_BRIGHT_COLORS = Boolean.getBoolean("roo.bright"); + private static final boolean SHELL_BRIGHT_COLORS = Boolean.getBoolean("spring.shell.bright"); + private static final boolean BRIGHT_COLORS = ROO_BRIGHT_COLORS || SHELL_BRIGHT_COLORS; + // Fields private ConsoleReader reader; diff --git a/src/main/java/org/springframework/shell/support/api/AddOnSearch.java b/src/main/java/org/springframework/shell/support/api/AddOnSearch.java deleted file mode 100644 index 071b9043..00000000 --- a/src/main/java/org/springframework/shell/support/api/AddOnSearch.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 2011-2012 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.shell.support.api; - -import java.util.logging.Logger; - -/** - * Interface defining an add-on search service. - * - *

- * This interface is included in the support module because several of Roo's core - * infrastructure modules require add-on search capabilities. - * - * @author Ben Alex - * @author Stefan Schmidt - * @since 1.1.1 - */ -public interface AddOnSearch { - - /** - * Search all add-ons presently known this Roo instance, including add-ons which have - * not been downloaded or installed by the user. - * - *

- * Information is optionally emitted to the console via {@link Logger#info}. - * - * @param showFeedback if false will never output any messages to the console (required) - * @param searchTerms comma separated list of search terms (required) - * @param refresh attempt a fresh download of roobot.xml (optional) - * @param linesPerResult maximum number of lines per add-on (optional) - * @param maxResults maximum number of results to display (optional) - * @param trustedOnly display only trusted add-ons in search results (optional) - * @param compatibleOnly display only compatible add-ons in search results (optional) - * @param communityOnly display only community-provided add-ons in search results (optional) - * @param requiresCommand display only add-ons which offer the specified command (optional) - * @return the total number of matches found, even if only some of these are displayed due to maxResults - * (or null if the add-on list is unavailable for some reason, eg network problems etc) - */ - Integer searchAddOns(boolean showFeedback, String searchTerms, boolean refresh, int linesPerResult, int maxResults, boolean trustedOnly, boolean compatibleOnly, boolean communityOnly, String requiresCommand); -} diff --git a/src/main/java/org/springframework/shell/support/logging/HandlerUtils.java b/src/main/java/org/springframework/shell/support/logging/HandlerUtils.java index 998a4123..a60f4846 100644 --- a/src/main/java/org/springframework/shell/support/logging/HandlerUtils.java +++ b/src/main/java/org/springframework/shell/support/logging/HandlerUtils.java @@ -47,8 +47,9 @@ public abstract class HandlerUtils { */ public static Logger getLogger(final Class clazz) { Assert.notNull(clazz, "Class required"); - Logger logger = Logger.getLogger(clazz.getName()); - if (logger.getLevel() == null && clazz.getName().startsWith("org.springframework.shell")) { + String name = clazz.getName(); + Logger logger = Logger.getLogger(name); + if (logger.getLevel() == null && name.startsWith("org.springframework.shell")) { logger.setLevel(Level.FINE); } return logger; diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties index 89c2a130..85417af0 100644 --- a/src/main/resources/log4j.properties +++ b/src/main/resources/log4j.properties @@ -1,6 +1,16 @@ -log4j.rootCategory=ERROR, stdout +# configure shell first +log4j.category.org.springframework.shell=INFO, out +# then everything else +log4j.rootCategory=WARN, stdout + +# standard logging including calling site log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %40.40c:%4L - %m%n + +# standard logging including calling site +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%m%n \ No newline at end of file diff --git a/src/test/resources/log4j.properties b/src/test/resources/log4j.properties index 11492f19..85417af0 100644 --- a/src/test/resources/log4j.properties +++ b/src/test/resources/log4j.properties @@ -1,6 +1,16 @@ -log4j.rootCategory=INFO, stdout +# configure shell first +log4j.category.org.springframework.shell=INFO, out +# then everything else +log4j.rootCategory=WARN, stdout + +# standard logging including calling site log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %40.40c:%4L - %m%n + +# standard logging including calling site +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%m%n \ No newline at end of file