01: /* Copyright (C) 2003 Finalist IT Group
02: *
03: * This file is part of JAG - the Java J2EE Application Generator
04: *
05: * JAG is free software; you can redistribute it and/or modify
06: * it under the terms of the GNU General Public License as published by
07: * the Free Software Foundation; either version 2 of the License, or
08: * (at your option) any later version.
09: * JAG 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
12: * GNU General Public License for more details.
13: * You should have received a copy of the GNU General Public License
14: * along with JAG; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16: */
17:
18: package com.finalist.util.log;
19:
20: import java.util.logging.Level;
21:
22: /**
23: * A class for making custom levels for logging.
24: *
25: * @author Ronald Kramp - Finalist IT Group
26: * @version $Revision: 1.1 $, $Date: 2004/11/12 14:06:44 $
27: */
28: class CustomLevel extends Level {
29:
30: /** a Level for DEBUG */
31: public static final Level DEBUG = new CustomLevel("DEBUG",
32: Level.INFO.intValue() - 1);
33:
34: /** a Level for ERROR */
35: public static final Level ERROR = new CustomLevel("ERROR",
36: Level.SEVERE.intValue() - 1);
37:
38: /** a Level for FATAL */
39: public static final Level FATAL = new CustomLevel("FATAL",
40: Level.SEVERE.intValue() + 1);
41:
42: /**
43: * Constrcutor for making a custom level.
44: * @param name, the name of the Level
45: * @param value, the value for the level
46: */
47: public CustomLevel(String name, int value) {
48: super (name, value);
49: }
50:
51: /**
52: * Parse a levelName to a Level object.
53: * @param levelName the name of the Level to parse to a Level obhect
54: * @return Level the Level object parsed
55: */
56: public static Level parse(String levelName) {
57: if (levelName.equals("DEBUG")) {
58: return DEBUG;
59: } else if (levelName.equals("ERROR")) {
60: return ERROR;
61: } else if (levelName.equals("FATAL")) {
62: return FATAL;
63: } else {
64: return Level.parse(levelName);
65: }
66: }
67: }
|