01: /*
02: * This program is free software; you can redistribute it and/or
03: * modify it under the terms of the GNU General Public License
04: * as published by the Free Software Foundation; either version 2
05: * of the License, or (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * 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: public class Log {
21: private static Logger logger = new SystemLogger();
22: private static Log log = new Log();
23: private static StringBuffer cache = new StringBuffer();
24:
25: private Log() {
26: }
27:
28: public static void setLogger(Logger logger) {
29: Log.logger = logger;
30: }
31:
32: public static void debug(String msg) {
33: if (Settings.getDisableLog()) {
34: return;
35: }
36:
37: //System.out.println(msg);
38: logger.debug(msg);
39: cache.append(msg + "\n");
40:
41: if (!Settings.getEnableDebug())
42: System.out.println("> " + msg);
43: }
44:
45: public static void debugRaw(String msg) {
46: if (Settings.getDisableLog()) {
47: return;
48: }
49:
50: logger.debugRaw(msg);
51: cache.append(msg);
52:
53: if (Settings.getEnableDebug())
54: System.out.print(msg);
55: }
56:
57: public static void out(String msg) {
58: if (!Settings.getEnableDebug()) {
59: return;
60: }
61:
62: System.out.println("> " + msg);
63: }
64:
65: public static void devnull(Object msg) {
66: }
67:
68: public static String getCache() {
69: return cache.toString();
70: }
71:
72: public static void clearCache() {
73: cache = new StringBuffer();
74: }
75: }
|