configure logging if verbose
This commit is contained in:
parent
a96ad26012
commit
579cb164af
|
@ -2,6 +2,7 @@ package net.hyperic.sigar.test;
|
||||||
|
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
import junit.framework.AssertionFailedError;
|
import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
|
@ -13,6 +14,8 @@ import junit.textui.TestRunner;
|
||||||
|
|
||||||
import net.hyperic.sigar.cmd.Version;
|
import net.hyperic.sigar.cmd.Version;
|
||||||
|
|
||||||
|
import org.apache.log4j.PropertyConfigurator;
|
||||||
|
|
||||||
public class SigarTestPrinter extends ResultPrinter {
|
public class SigarTestPrinter extends ResultPrinter {
|
||||||
|
|
||||||
private static String PACKAGE_NAME =
|
private static String PACKAGE_NAME =
|
||||||
|
@ -21,6 +24,25 @@ public class SigarTestPrinter extends ResultPrinter {
|
||||||
private HashMap failures = new HashMap();
|
private HashMap failures = new HashMap();
|
||||||
private int maxNameLen = 0;
|
private int maxNameLen = 0;
|
||||||
|
|
||||||
|
private static final String[][] LOG_PROPS = {
|
||||||
|
{
|
||||||
|
"log4j.rootLogger",
|
||||||
|
"DEBUG, R"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"log4j.appender.R",
|
||||||
|
"org.apache.log4j.ConsoleAppender"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"log4j.appender.R.layout",
|
||||||
|
"org.apache.log4j.PatternLayout"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"log4j.appender.R.layout.ConversionPattern",
|
||||||
|
"%d [%t] %-5p %c - %m%n"
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
public SigarTestPrinter(PrintStream writer) {
|
public SigarTestPrinter(PrintStream writer) {
|
||||||
super(writer);
|
super(writer);
|
||||||
}
|
}
|
||||||
|
@ -88,6 +110,13 @@ public class SigarTestPrinter extends ResultPrinter {
|
||||||
printer.printVersionInfo();
|
printer.printVersionInfo();
|
||||||
|
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
|
Properties props = new Properties();
|
||||||
|
for (int i=0; i<LOG_PROPS.length; i++) {
|
||||||
|
props.setProperty(LOG_PROPS[i][0],
|
||||||
|
LOG_PROPS[i][1]);
|
||||||
|
}
|
||||||
|
PropertyConfigurator.configure(props);
|
||||||
|
|
||||||
SigarTestCase.setVerbose(true);
|
SigarTestCase.setVerbose(true);
|
||||||
SigarTestCase.setWriter(printer.getWriter());
|
SigarTestCase.setWriter(printer.getWriter());
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue