KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > datashare > plugins > LoggingManager > LoggingAdapter


1 /* ----- BEGIN LICENSE BLOCK -----
2  * Version: MPL 1.1
3  *
4  * The contents of this file are subject to the Mozilla Public License Version
5  * 1.1 (the "License"); you may not use this file except in compliance with
6  * the License. You may obtain a copy of the License at
7  * http://www.mozilla.org/MPL/
8  *
9  * Software distributed under the License is distributed on an "AS IS" basis,
10  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11  * for the specific language governing rights and limitations under the
12  * License.
13  *
14  * The Original Code is the DataShare server.
15  *
16  * The Initial Developer of the Original Code is
17  * Ball Aerospace & Technologies Corp, Fairborn, Ohio
18  * Portions created by the Initial Developer are Copyright (C) 2001
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s): Charles Wood <cwood@ball.com>
22  *
23  * ----- END LICENSE BLOCK ----- */

24 /* RCS $Id: LoggingAdapter.java,v 1.1 2002/01/29 20:58:36 lizellaman Exp $
25  * $Log: LoggingAdapter.java,v $
26  * Revision 1.1 2002/01/29 20:58:36 lizellaman
27  * Added LoggingInterface, modified the PropertiesInterface implementation
28  *
29  *
30  */

31
32 package org.datashare.plugins.LoggingManager;
33
34 import org.datashare.LoggingInterface;
35 import org.datashare.SessionUtilities;
36
37 /**
38  * this class implements the LoggingInterface of DataShare
39  * @date January 25, 2002
40  * @author Charles Wood
41  * @version 1.0
42  */

43 public class LoggingAdapter implements LoggingInterface
44    {
45    
46    /**
47     * this is the method that should be used for all console messages of DataShare
48     * so that filtering at runtime may be implemented.
49     * @param level valid values are defined in this class and are as follows:
50     * "DEBUG", "WARNING", "ERROR", "FATALERROR"
51     * @param category valid values are defined in this class and are as follows:
52     * "CLIENT", "SESSION", "DATABASE", "NETWORK"
53     */

54    public void debugMsg(int level, int category, String JavaDoc msg)
55       {
56       switch(level)
57          {
58          case LoggingInterface.DEBUG:
59          case LoggingInterface.WARNING:
60             if(SessionUtilities.getVerbose())
61                System.out.println(levelStrings[level] + " " + categoryStrings[category] + " " + msg);
62             break;
63          case LoggingInterface.ERROR:
64          case LoggingInterface.FATALERROR:
65             System.err.println(levelStrings[level] + " " + categoryStrings[category] + " " + msg);
66          }
67       }
68       
69    /**
70     * should be used to log/capture Exceptions
71     * @param level valid values are defined in this class and are as follows:
72     * "DEBUG", "WARNING", "ERROR", "FATALERROR"
73     */

74    public void logException(int level, Exception JavaDoc e)
75       {
76       switch(level)
77          {
78          case LoggingInterface.DEBUG:
79          case LoggingInterface.WARNING:
80             if(SessionUtilities.getVerbose())
81                e.printStackTrace();
82             break;
83          case LoggingInterface.ERROR:
84          case LoggingInterface.FATALERROR:
85             e.printStackTrace(System.err);
86             break;
87          }
88       }
89       
90    }
91
92
Popular Tags