01: package net.sourceforge.squirrel_sql.fw.util.log;
02:
03: import java.util.Vector;
04:
05: /*
06: * Copyright (C) 2001-2002 Colin Bell
07: * colbell@users.sourceforge.net
08: *
09: * This library is free software; you can redistribute it and/or
10: * modify it under the terms of the GNU Lesser General Public
11: * License as published by the Free Software Foundation; either
12: * version 2.1 of the License, or (at your option) any later version.
13: *
14: * This library is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17: * Lesser General Public License for more details.
18: *
19: * You should have received a copy of the GNU Lesser General Public
20: * License along with this library; if not, write to the Free Software
21: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22: */
23: public class LoggerController {
24: private static Vector<ILoggerFactory> s_oldfactories = new Vector<ILoggerFactory>();
25: private static ILoggerFactory s_factory = new Log4jLoggerFactory();
26:
27: public static void registerLoggerFactory(ILoggerFactory factory) {
28: s_oldfactories.add(s_factory);
29: s_factory = factory != null ? factory
30: : new Log4jLoggerFactory();
31: }
32:
33: public static ILogger createLogger(Class<?> clazz) {
34: return s_factory.createLogger(clazz);
35: }
36:
37: public static void shutdown() {
38: s_factory.shutdown();
39: }
40:
41: public static void addLoggerListener(ILoggerListener l) {
42: s_factory.addLoggerListener(l);
43:
44: for (int i = 0; i < s_oldfactories.size(); i++) {
45: ILoggerFactory iLoggerFactory = s_oldfactories.get(i);
46: iLoggerFactory.addLoggerListener(l);
47: }
48: }
49:
50: public static void removeLoggerListener(ILoggerListener l) {
51: s_factory.removeLoggerListener(l);
52:
53: for (int i = 0; i < s_oldfactories.size(); i++) {
54: ILoggerFactory iLoggerFactory = s_oldfactories.get(i);
55: iLoggerFactory.removeLoggerListener(l);
56: }
57:
58: }
59:
60: }
|