remove logback loading messages

This commit is contained in:
Sebastian Sdorra
2011-05-23 08:38:02 +02:00
parent d1684ba729
commit 7e6572d60b
5 changed files with 133 additions and 27 deletions

View File

@@ -35,6 +35,9 @@ package sonia.scm.cli;
//~--- non-JDK imports --------------------------------------------------------
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import org.kohsuke.args4j.Argument;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
@@ -146,6 +149,7 @@ public class App
System.exit(1);
}
configureLogger();
loadConfig();
I18n i18n = new I18n();
@@ -164,6 +168,17 @@ public class App
IOUtil.close(output);
}
/**
* Method description
*
*/
private void configureLogger()
{
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
lc.getLogger(Logger.ROOT_LOGGER_NAME).setLevel(loggingLevel);
}
/**
* Method description
*
@@ -278,6 +293,15 @@ public class App
/** Field description */
private BufferedReader input;
/** Field description */
@Option(
name = "--logging-level",
usage = "optionLoggingLevel",
handler = LoggingLevelOptionHandler.class,
aliases = { "-l" }
)
private Level loggingLevel = Level.ERROR;
/** Field description */
private PrintWriter output;

View File

@@ -56,6 +56,9 @@ public class I18n
/** Field description */
public static final String GROUP_NOT_FOUND = "groupNotFound";
/** Field description */
public static final String LEVEL = "level";
/** Field description */
public static final String OPTIONS = "options";

View File

@@ -0,0 +1,104 @@
/**
* Copyright (c) 2010, Sebastian Sdorra
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of SCM-Manager; nor the names of its
* contributors may be used to endorse or promote products derived from this
* software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* http://bitbucket.org/sdorra/scm-manager
*
*/
package sonia.scm.cli;
//~--- non-JDK imports --------------------------------------------------------
import ch.qos.logback.classic.Level;
import org.kohsuke.args4j.CmdLineException;
import org.kohsuke.args4j.CmdLineParser;
import org.kohsuke.args4j.OptionDef;
import org.kohsuke.args4j.spi.OptionHandler;
import org.kohsuke.args4j.spi.Parameters;
import org.kohsuke.args4j.spi.Setter;
/**
*
* @author Sebastian Sdorra
*/
public class LoggingLevelOptionHandler extends OptionHandler<Level>
{
/**
* Constructs ...
*
*
* @param parser
* @param option
* @param setter
*/
public LoggingLevelOptionHandler(CmdLineParser parser, OptionDef option,
Setter<? super Level> setter)
{
super(parser, option, setter);
}
//~--- methods --------------------------------------------------------------
/**
* Method description
*
*
* @param params
*
* @return
*
* @throws CmdLineException
*/
@Override
public int parseArguments(Parameters params) throws CmdLineException
{
String value = params.getParameter(0);
Level l = Level.toLevel(value);
setter.addValue(l);
return 1;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @return
*/
@Override
public String getDefaultMetaVariable()
{
return I18n.LEVEL;
}
}

View File

@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Document : logback.xml
Created on : May 14, 2011, 5:00 PM
Author : sdorra
Description:
Purpose of the document follows.
-->
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<!-- encoders are by default assigned the type
ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<logger name="sonia.scm.cli" level="ERROR" />
<root level="ERROR">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@@ -38,6 +38,7 @@ optionServerUrl = SCM-Manager URL
optionUsername = Username
optionPassword = Password
optionHelpText = Shows this help
optionLoggingLevel = Logging level (DEBUG, INFO, WARN, ERROR)
optionTemplate = Template
optionTemplateFile = Template file
optionRepositoryId = Repository Id
@@ -80,6 +81,7 @@ misc = Miscellaneous
repository = Repository
group = Group
user = User
level = Logging-Level
options = Options
usage = scm-cli-client [options] command [command options]