/**
* Copyright (C) 2004 France Telecom R&D
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.objectweb.util.monolog;
import org.objectweb.util.monolog.api.MonologFactory;
import org.objectweb.util.monolog.api.TopicalLogger;
import org.objectweb.util.monolog.api.Handler;
import org.objectweb.util.monolog.api.BasicLevel;
import junit.framework.TestCase;
/**
*
* @author S.Chassande-Barrioz
*/
public class TestHandlerLevel extends TestCase {
public TestHandlerLevel(String s) {
super(s);
}
public void testProgConfig() throws Exception {
String className = System.getProperty(Monolog.MONOLOG_CLASS_NAME, Monolog.JDK_WRAPPER_CLASS_NAME);
Monolog.monologFactory = Monolog.getDefaultMonologFactory();
MonologFactory mf = Monolog.instanciateMonologFactory(className);
TopicalLogger l = (TopicalLogger) mf.getLogger(
"org.objectweb.util.monolog.TestHandlerLevel.testA");
l.setIntLevel(BasicLevel.DEBUG);
l.setAdditivity(false);
Handler h1 = mf.createHandler("h1", "console");
h1.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
h1.setAttribute(Handler.LEVEL_ATTRIBUTE, "WARN");
h1.setAttribute(Handler.PATTERN_ATTRIBUTE, "first handler: %m");
h1.setAttribute("activation",mf);
l.addHandler(h1);
Handler h2 = mf.createHandler("h2", "console");
h2.setAttribute(Handler.OUTPUT_ATTRIBUTE, "System.out");
h2.setAttribute(Handler.PATTERN_ATTRIBUTE, "second handler: %m");
h2.setAttribute("activation",mf);
l.addHandler(h2);
l = (TopicalLogger) mf.getLogger(
"org.objectweb.util.monolog.TestHandlerLevel.testA.l1");
l.log(BasicLevel.DEBUG, "(" + className + ") this message must be printed only one time");
}
}