1 18 package org.objectweb.util.monolog; 19 20 import org.objectweb.util.monolog.api.MonologFactory; 21 import org.objectweb.util.monolog.api.TopicalLogger; 22 import org.objectweb.util.monolog.api.Handler; 23 import org.objectweb.util.monolog.api.BasicLevel; 24 import junit.framework.TestCase; 25 26 30 public class TestHandlerLevel extends TestCase { 31 32 public TestHandlerLevel(String s) { 33 super(s); 34 } 35 36 public void testProgConfig() throws Exception { 37 String className = System.getProperty(Monolog.MONOLOG_CLASS_NAME, Monolog.JDK_WRAPPER_CLASS_NAME); 38 Monolog.monologFactory = Monolog.getDefaultMonologFactory(); 39 MonologFactory mf = Monolog.instanciateMonologFactory(className); 40 TopicalLogger l = (TopicalLogger) mf.getLogger( 41 "org.objectweb.util.monolog.TestHandlerLevel.testA"); 42 l.setIntLevel(BasicLevel.DEBUG); 43 l.setAdditivity(false); 44 45 Handler h1 = mf.createHandler("h1", "console"); 46 h1.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out"); 47 h1.setAttribute(Handler.LEVEL_ATTRIBUTE, "WARN"); 48 h1.setAttribute(Handler.PATTERN_ATTRIBUTE, "first handler: %m"); 49 h1.setAttribute("activation",mf); 50 l.addHandler(h1); 51 52 Handler h2 = mf.createHandler("h2", "console"); 53 h2.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out"); 54 h2.setAttribute(Handler.PATTERN_ATTRIBUTE, "second handler: %m"); 55 h2.setAttribute("activation",mf); 56 l.addHandler(h2); 57 l = (TopicalLogger) mf.getLogger( 58 "org.objectweb.util.monolog.TestHandlerLevel.testA.l1"); 59 l.log(BasicLevel.DEBUG, "(" + className + ") this message must be printed only one time"); 60 } 61 } 62 | Popular Tags |