1 23 24 package org.objectweb.medor.lib; 25 26 import junit.framework.TestCase; 27 import org.objectweb.util.monolog.api.Logger; 28 import org.objectweb.util.monolog.api.LoggerFactory; 29 import org.objectweb.util.monolog.wrapper.printwriter.LoggerImpl; 30 31 34 35 public class TestMedorHelper extends TestCase { 36 37 public static boolean isOn; 38 public Logger logger; 39 40 public TestMedorHelper(String n) { 41 super(n); 42 logger = getLoggerFactory("log.properties").getLogger(Log.MEDOR_PREFIX); 43 } 44 45 public TestMedorHelper(String testName, String loggerName) { 46 super(testName); 47 logger = getLoggerFactory().getLogger(loggerName); 48 } 49 50 public void changeLogger(String loggerName) { 51 logger = getLoggerFactory().getLogger(loggerName); 52 } 53 54 public static LoggerFactory getLoggerFactory() { 55 if (Log.loggerFactory == null 56 || Log.loggerFactory instanceof LoggerImpl) { 57 getLoggerFactory("log.properties"); 58 } 59 return Log.loggerFactory; 60 } 61 62 public static LoggerFactory getLoggerFactory(String fileName) { 63 try { 64 Log.loggerFactory = Log.loadLoggerFactory(fileName); 65 } 66 catch (Exception e) { 67 try { 68 Log.loggerFactory = Log.loadLoggerFactory((String ) null); 69 } 70 catch (Exception e1) { 71 } 72 } 73 return Log.loggerFactory; 74 } 75 } 76 | Popular Tags |