KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > kjoram > JoramTracing


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - Dyade
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  * Initial developer(s): Nicolas Tachker (ScalAgent)
22  * Contributor(s):
23  */

24 package com.scalagent.kjoram;
25
26 /**
27  * The <code>JoramTracing</code> class centralizes the log tracing for joram.
28  */

29 public class JoramTracing {
30   public static int ERROR = 1;
31   public static int WARN = 2;
32   public static int INFO = 3;
33   public static int DEBUG = 4;
34
35   public static int traceLevel = 1;
36
37   public static boolean dbgClient = false;
38   public static boolean dbgAdmin = false;
39   public static boolean dbg = false;
40
41   static {
42     String JavaDoc l = System.getProperty("traceLevel");
43     if (l != null && l != "") {
44       traceLevel = Integer.parseInt(l);
45     }
46     if (System.getProperty("dbgClient") != null)
47       dbgClient = true;
48     if (System.getProperty("dbgAdmin") != null)
49       dbgAdmin = true;
50     if (System.getProperty("dbg") != null)
51       dbg = true;
52   }
53   
54   public static void log(int level, String JavaDoc trace) {
55     if (level <= traceLevel)
56       System.out.println(trace);
57   }
58
59   public static void log(int level, Exception JavaDoc exc) {
60     log(level,exc.toString());
61   }
62 }
63
Popular Tags