KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > finalist > jag > util > Log


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.jag.util;
19
20
21 import com.finalist.jaggenerator.ConsoleLogger;
22
23 import java.io.*;
24
25
26 /**
27  * Class Log
28  *
29  * @author Wendel D. de Witte
30  */

31 public class Log {
32
33    /** Field out */
34    private static PrintStream out = System.out;
35
36    private static ConsoleLogger console;
37
38    /**
39     * Method log
40     *
41     * @param s
42     */

43    public static void log(String JavaDoc s) {
44       if (console == null) {
45          out.println(s);
46       } else {
47          console.log(s);
48       }
49    }
50
51    public static void setLogger(ConsoleLogger logger) {
52       console = logger;
53    }
54
55    /**
56     * Appends an red error log to the end of the console.
57     *
58     * @param message
59     * the log message.
60     */

61     public static void error(String JavaDoc message) {
62         if (console == null) {
63             out.println(message);
64         } else {
65             console.error(message);
66         }
67     }
68
69     /**
70      * Appends an yellow debug log to the end of the console.
71      *
72      * @param message
73      * the log message.
74      */

75      public static void debug(String JavaDoc message) {
76          if (console == null) {
77              out.println(message);
78          } else {
79              console.debug(message);
80          }
81      }
82     
83 }
Popular Tags