01: /* ----- BEGIN LICENSE BLOCK -----
02: * Version: MPL 1.1
03: *
04: * The contents of this file are subject to the Mozilla Public License Version
05: * 1.1 (the "License"); you may not use this file except in compliance with
06: * the License. You may obtain a copy of the License at
07: * http://www.mozilla.org/MPL/
08: *
09: * 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: * this is the method that should be used for all console messages of DataShare
47: * so that filtering at runtime may be implemented.
48: * @param level valid values are defined in this class and are as follows:
49: * "DEBUG", "WARNING", "ERROR", "FATALERROR"
50: * @param category valid values are defined in this class and are as follows:
51: * "CLIENT", "SESSION", "DATABASE", "NETWORK"
52: */
53: public void debugMsg(int level, int category, String msg) {
54: switch (level) {
55: case LoggingInterface.DEBUG:
56: case LoggingInterface.WARNING:
57: if (SessionUtilities.getVerbose())
58: System.out.println(levelStrings[level] + " "
59: + categoryStrings[category] + " " + msg);
60: break;
61: case LoggingInterface.ERROR:
62: case LoggingInterface.FATALERROR:
63: System.err.println(levelStrings[level] + " "
64: + categoryStrings[category] + " " + msg);
65: }
66: }
67:
68: /**
69: * should be used to log/capture Exceptions
70: * @param level valid values are defined in this class and are as follows:
71: * "DEBUG", "WARNING", "ERROR", "FATALERROR"
72: */
73: public void logException(int level, Exception e) {
74: switch (level) {
75: case LoggingInterface.DEBUG:
76: case LoggingInterface.WARNING:
77: if (SessionUtilities.getVerbose())
78: e.printStackTrace();
79: break;
80: case LoggingInterface.ERROR:
81: case LoggingInterface.FATALERROR:
82: e.printStackTrace(System.err);
83: break;
84: }
85: }
86:
87: }
|