01: package ch.ethz.ssh2.log;
02:
03: /**
04: * Logger - a very simple logger, mainly used during development.
05: * Is not based on log4j (to reduce external dependencies).
06: * However, if needed, something like log4j could easily be
07: * hooked in.
08: *
09: * @author Christian Plattner, plattner@inf.ethz.ch
10: * @version $Id: Logger.java,v 1.8 2006/10/06 12:55:40 cplattne Exp $
11: */
12:
13: public class Logger {
14: private static final boolean enabled = false;
15: private static final int logLevel = 99;
16:
17: private String className;
18:
19: public final static Logger getLogger(Class x) {
20: return new Logger(x);
21: }
22:
23: public Logger(Class x) {
24: this .className = x.getName();
25: }
26:
27: public final boolean isEnabled() {
28: return enabled;
29: }
30:
31: public final void log(int level, String message) {
32: if ((enabled) && (level <= logLevel)) {
33: long now = System.currentTimeMillis();
34:
35: synchronized (this ) {
36: System.err.println(now + " : " + className + ": "
37: + message);
38: // or send it to log4j or whatever...
39: }
40: }
41: }
42: }
|