KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openinventions > webappfilter > processor > Logger


1 package com.openinventions.webappfilter.processor;
2
3 import com.openinventions.metaframework.*;
4 import org.apache.commons.logging.*;
5
6 public class Logger implements Processor {
7     private static final Log log = LogFactory.getLog(Logger.class);
8     
9     public void process(State state, Element context) throws Exception JavaDoc {
10         if (context.getValue("level").equals("debug")) {
11             Log debug = LogFactory.getLog(context.getValue("section"));
12             debug.debug(context.getValue("message"));
13         } else if (context.getValue("level").equals("info")) {
14             Log info = LogFactory.getLog(context.getValue("section"));
15             info.info(context.getValue("message"));
16         } else if (context.getValue("level").equals("warn")) {
17             Log warn = LogFactory.getLog(context.getValue("section"));
18             warn.warn(context.getValue("message"));
19         } else if (context.getValue("level").equals("error")) {
20             Log error = LogFactory.getLog(context.getValue("section"));
21             error.error(context.getValue("message"));
22         } else if (context.getValue("level").equals("fatal")) {
23             Log fatal = LogFactory.getLog(context.getValue("section"));
24             fatal.fatal(context.getValue("message"));
25         } else {
26             log.error("level not supported " + context.getValue("level"));
27         }
28     }
29 }
30 /* ====================================================================
31  * The webappfilter License, Version 1.1
32  *
33  * Copyright (c) 2002 Ivar Chan. All rights
34  * reserved.
35  *
36  * Redistribution and use in source and binary forms, with or without
37  * modification, are permitted provided that the following conditions
38  * are met:
39  *
40  * 1. Redistributions of source code must retain the above copyright
41  * notice, this list of conditions and the following disclaimer.
42  *
43  * 2. Redistributions in binary form must reproduce the above copyright
44  * notice, this list of conditions and the following disclaimer in
45  * the documentation and/or other materials provided with the
46  * distribution.
47  *
48  * 3. The end-user documentation included with the redistribution,
49  * if any, must include the following acknowledgment:
50  * "This product includes software developed by
51  * Ivar Chan (http://www.openinventions.com/webappfilter/)."
52  * Alternately, this acknowledgment may appear in the software itself,
53  * if and wherever such third-party acknowledgments normally appear.
54  *
55  * 4. The name "webappfilter" must not be used to endorse or promote products
56  * derived from this software without prior written permission. For
57  * written permission, please contact ivarchan@acm.org.
58  *
59  * 5. Products derived from this software may not be called "webappfilter",
60  * nor may "webappfilter" appear in their name, without
61  * prior written permission of Ivar Chan.
62  *
63  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
64  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
65  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
66  * DISCLAIMED. IN NO EVENT SHALL THE IVAR CHAN BE LIABLE FOR ANY
67  * DIRECT, INDIRECT, INCIDENTAL,
68  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
69  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
70  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
71  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
72  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
73  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
74  * SUCH DAMAGE.
75  * ====================================================================
76  *
77  * This software consists of voluntary contributions made by many
78  * individuals. For more information on webappfilter, please see
79  * <http://www.openinventions/webappfilter/>.
80  */

81
Popular Tags