KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > util > Trace


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  *
21  * --------------------------------------------------------------------------
22  * $Id: Trace.java,v 1.1 2003/04/17 13:40:28 coqp Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package util;
27
28 import org.objectweb.util.monolog.api.BasicLevel;
29 import org.objectweb.util.monolog.api.Logger;
30 import org.objectweb.util.monolog.api.LoggerFactory;
31 import org.objectweb.util.monolog.Monolog;
32
33
34 /**
35  * This class is provided only for backward compatibility for old test suite.
36  * @author Philippe Durieux
37  */

38 public class Trace {
39
40
41
42     public static final int DB_1 = (1<<1);
43     public static final int DB_31 = (1<<31);
44
45     public static String filename = "trace.properties";
46     public static LoggerFactory loggerFactory = null;
47     private static Logger logger = null;
48  
49     // constructor is private to prevent client program from instanciating a 'Trace'
50
private Trace() {
51     }
52
53     /**
54      * @return the logger instance for tests
55      */

56     public static Logger getLogger() {
57     if (logger == null) {
58         logger = loggerFactory.getLogger("org.objectweb.jonas_tests");
59     }
60     return logger;
61     }
62
63     /**
64      *
65      */

66     public static void configure() {
67         loggerFactory = Monolog.init(filename);
68     }
69
70     /**
71      * Sends the trace message to the trace output device if flag is configured
72      * @param f this flag must be configured to get the message on output
73      * @param s message to send
74      */

75     public static void outln(int f, String s) {
76         getLogger().log(f == DB_1 ? BasicLevel.DEBUG : BasicLevel.WARN, s);
77     }
78
79     /**
80      * Sends the trace message to the trace output device.
81      * @param s message to send
82      */

83     public static void outln(String s) {
84         getLogger().log(BasicLevel.WARN, s);
85     }
86
87     /**
88      * Sends the trace message to the trace output device.
89      * @param s message to send
90      */

91     public static void out(String s) {
92         outln(s);
93     }
94
95     /**
96      * Sends the trace message to the jonas logger as error level.
97      * @param s message to send
98      */

99     public static void errln(String s) {
100         getLogger().log(BasicLevel.ERROR, s);
101     }
102
103 }
104
105
Popular Tags