View Javadoc

1   /*
2    * $Id: ConsoleLogger.java 124 2004-11-01 18:09:40Z josem $
3    *
4    * Tarsis
5    * Copyright (C) 2002 Talika Open Source Group
6    *
7    * This program is free software; you can redistribute it and/or modify
8    * it under the terms of the GNU General Public License as published by
9    * the Free Software Foundation; either version 2 of the License, or
10   * (at your option) any later version.
11   *
12   * This program is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   * GNU General Public License for more details.
16   *
17   * You should have received a copy of the GNU General Public License
18   * along with this program; if not, write to the Free Software
19   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20   *
21   */
22  
23  package org.talika.tarsis.log;
24  
25  /**
26   * Implementation of <code>Logger</code> interface that writes messages to default
27   * output.
28   *
29   * @author  Jose M. Palomar
30   * @version $Revision: 124 $
31   */
32  public final class ConsoleLogger extends LoggerService {
33  
34      // Constants
35  
36      // Fields
37  
38      // Constructors
39      /**
40       * Creates a new <code>ConsoleLogger</code>.
41       */
42      public ConsoleLogger() {
43      }
44  
45      // Methods
46      /**
47       * Returns name of service.
48       *
49       * @return String name of service.
50       * @see org.talika.tarsis.service.Service#getName()
51       */
52      public String getName() {
53          return "ConsoleLoggerService";
54      }
55  
56      /**
57       * Writes a log message to console.
58       *
59       * @param level int log level.
60       * @param msg String message.
61       */
62      protected void writeLog(int level, String msg) {
63          System.err.print(msg);
64      }
65  
66      /**
67       * Writes an error log message to console.
68       *
69       * @param level int log level.
70       * @param msg String message.
71       * @param t Throwable a <code>Throwable</code> object.
72       */
73      protected void writeLog(int level, String msg, Throwable t) {
74          System.err.print(msg);
75          t.printStackTrace(System.err);
76      }
77  
78  }