aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/trilead/ssh2/log/Logger.java
blob: 20ab397fd5809fd5dcf8eb61b9000d87cde85404 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.trilead.ssh2.log;

import com.trilead.ssh2.DebugLogger;

/**
 * Logger - a very simple logger, mainly used during development.
 * Is not based on log4j (to reduce external dependencies).
 * However, if needed, something like log4j could easily be
 * hooked in.
 * <p>
 * For speed reasons, the static variables are not protected
 * with semaphores. In other words, if you dynamicaly change the
 * logging settings, then some threads may still use the old setting.
 * 
 * @author Christian Plattner, plattner@trilead.com
 * @version $Id: Logger.java,v 1.2 2008/03/03 07:01:36 cplattne Exp $
 */

public class Logger
{
	public static boolean enabled = false;
	public static DebugLogger logger = null;
	
	private String className;

	public final static Logger getLogger(Class x)
	{
		return new Logger(x);
	}

	public Logger(Class x)
	{
		this.className = x.getName();
	}

	public final boolean isEnabled()
	{
		return enabled;
	}

	public final void log(int level, String message)
	{
		if (!enabled)
			return;
		
		DebugLogger target = logger;
		
		if (target == null)
			return;
		
		target.log(level, className, message);
	}
}