KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > util > log > LogFilter


1 /* Copyright (C) 2003 Finalist IT Group
2  *
3  * This file is part of JAG - the Java J2EE Application Generator
4  *
5  * JAG is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * 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.text.SimpleDateFormat JavaDoc;
21 import java.util.Date JavaDoc;
22 import java.util.logging.Filter JavaDoc;
23 import java.util.logging.LogRecord JavaDoc;
24
25 /**
26  * A class for setting a filter
27  * @author Ronald Kramp - Finalist IT Group
28  * @version $Revision: 1.1 $, $Date: 2004/11/12 14:06:44 $
29  */

30 public final class LogFilter implements Filter JavaDoc {
31
32    /** a filter which should be logged */
33    private String JavaDoc logFilterValue = "";
34
35
36    /**
37     * Constrcutor for making a LogFormatter
38     * @param logFilterValue the filter for logging
39     */

40    public LogFilter(String JavaDoc logFilterValue) {
41       this.logFilterValue = logFilterValue;
42    }
43
44    /**
45     * Check to see if the filter is in the logrecord
46     * @param logRecord the log record to format
47     * @return boolean true if the filter exists in the logRecord
48     */

49    public boolean isLoggable(LogRecord JavaDoc logRecord) {
50       return (logRecord.getLoggerName().indexOf(logFilterValue) > -1);
51    }
52 }
Popular Tags