01: /**
02: * Copyright (C) 2004 France Telecom R&D
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2 of the License, or (at your option) any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */package org.objectweb.util.monolog;
18:
19: import junit.framework.TestCase;
20: import org.objectweb.util.monolog.api.MonologFactory;
21: import org.objectweb.util.monolog.api.Logger;
22: import org.objectweb.util.monolog.api.BasicLevel;
23:
24: /**
25: *
26: * @author S.Chassande-Barrioz
27: */
28: public class TestSimple extends TestCase {
29:
30: static MonologFactory mf = null;
31:
32: public TestSimple(String s) {
33: super (s);
34: }
35:
36: protected void setUp() throws Exception {
37: if (mf == null) {
38: synchronized (TestSimple.class) {
39: if (mf == null) {
40: mf = Monolog
41: .getMonologFactory("monolog.properties");
42: }
43: }
44: }
45: }
46:
47: public void test1() {
48: logAllLevel(mf
49: .getLogger("org.objectweb.util.monolog.test.fatal"));
50: logAllLevel(mf
51: .getLogger("org.objectweb.util.monolog.test.error"));
52: logAllLevel(mf
53: .getLogger("org.objectweb.util.monolog.test.warn"));
54: logAllLevel(mf
55: .getLogger("org.objectweb.util.monolog.test.info"));
56: logAllLevel(mf
57: .getLogger("org.objectweb.util.monolog.test.debug"));
58: }
59:
60: private void logAllLevel(Logger logger) {
61: logger.log(BasicLevel.FATAL, "-----------------"
62: + "\n\tlogger.name: " + logger.getName()
63: + "\n\tlogger.class: " + logger.getClass().getName()
64: + "\n\tlevel=" + logger.getCurrentLevel().getName());
65: logger.log(BasicLevel.FATAL, "message FATAL ...");
66: logger.log(BasicLevel.ERROR, "message ERROR ...");
67: logger.log(BasicLevel.WARN, "message WARN ...");
68: logger.log(BasicLevel.INFO, "message INFO ...");
69: logger.log(BasicLevel.DEBUG, "message DEBUG ...");
70: }
71:
72: }
|