View Javadoc

1   /*   Open Source Java Caching Service
2   *    Copyright (C) 2002 Frank Karlstrøm
3   *    This library is free software; you can redistribute it and/or
4   *    modify it under the terms of the GNU Lesser General Public
5   *    License as published by the Free Software Foundation; either
6   *    version 2.1 of the License, or (at your option) any later version.
7   *
8   *    This library is distributed in the hope that it will be useful,
9   *    but WITHOUT ANY WARRANTY; without even the implied warranty of
10  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  *    Lesser General Public License for more details.
12  *
13  *    You should have received a copy of the GNU Lesser General Public
14  *    License along with this library; if not, write to the Free Software
15  *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16  *
17  *    The author can be contacted by email: fjankk@users.sourceforge.net
18  */
19  package org.fjank.jcache;
20  
21  import javax.util.jcache.CacheLogger;
22  
23  
24  /**
25   * Logs all messages to System.out for the moment. Reprogram to log to a file
26   * later. Does not implement loggerSeverity.
27   *
28   * @author Frank Karlstrøm
29   */
30  public final class DefaultCacheLogger extends CacheLogger {
31      /**
32       * Creates new DefaultCacheLogger
33       */
34      public DefaultCacheLogger() {
35      }
36  
37      /**
38       * application writers can implement this method and provide their own
39       * mechanism to log a message.
40       *
41       * @param message the message to log.
42       * @param cause the Exception responsible for causing an log event to
43       *        happen.
44       */
45      public void log(final String message, final Throwable cause) {
46          System.out.println(message + ", caused by:" + cause);
47      }
48  
49      /**
50       * log messages are buffered by the cache. This method will force the
51       * messages to be written out the destination and the buffer is reset.
52       *
53       * @todo NOT IMPLEMENTED.
54       */
55      public void flush() {
56      }
57  
58      /**
59       * application writers can implement this method and provide their own
60       * mechanism to log a message.
61       *
62       * @param message the message to log.
63       *
64       * @todo NOT IMPLEMENTED
65       */
66      public void log(final String message) {
67          System.out.println(message);
68      }
69  
70      /**
71       * is called by the caching system when the CacheLogger is instanciated to
72       * complete any initialization requirements.
73       *
74       * @param fileName the value from the CacheAttribute
75       * @param severity the value from the CacheAttributes.
76       *
77       * @todo NOT IMPLEMENTED
78       */
79      public void init(final String fileName, final int severity) {
80      }
81  }