KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > system > logging > Log


1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package net.sf.jftp.system.logging;
17
18 import net.sf.jftp.config.Settings;
19
20
21 public class Log
22 {
23     private static Logger logger = new SystemLogger();
24     private static Log log = new Log();
25     private static StringBuffer JavaDoc cache = new StringBuffer JavaDoc();
26
27     private Log()
28     {
29     }
30
31     public static void setLogger(Logger logger)
32     {
33         Log.logger = logger;
34     }
35
36     public static void debug(String JavaDoc msg)
37     {
38         if(Settings.getDisableLog())
39         {
40             return;
41         }
42
43         //System.out.println(msg);
44
logger.debug(msg);
45         cache.append(msg + "\n");
46
47         if(!Settings.getEnableDebug()) System.out.println("> " + msg);
48     }
49
50     public static void debugRaw(String JavaDoc msg)
51     {
52         if(Settings.getDisableLog())
53         {
54             return;
55         }
56
57         logger.debugRaw(msg);
58         cache.append(msg);
59
60         if(Settings.getEnableDebug()) System.out.print(msg);
61     }
62
63     public static void out(String JavaDoc msg)
64     {
65         if(!Settings.getEnableDebug())
66         {
67             return;
68         }
69
70         System.out.println("> " + msg);
71     }
72     
73     public static void devnull(Object JavaDoc msg)
74     {
75     }
76
77
78     public static String JavaDoc getCache()
79     {
80         return cache.toString();
81     }
82
83     public static void clearCache()
84     {
85         cache = new StringBuffer JavaDoc();
86     }
87 }
88
Popular Tags