View Javadoc
1   package net.avcompris.commons3.yaml;
2   
3   import static com.google.common.base.Preconditions.checkNotNull;
4   import static com.google.common.collect.Maps.newHashMap;
5   
6   import java.util.Map;
7   
8   import javax.annotation.Nullable;
9   
10  public abstract class LoggerFactory {
11  
12  	private static final Map<Class<?>, Logger> loggers = newHashMap();
13  
14  	public static final boolean DEBUG = false;
15  
16  	public static Logger getLogger(final Class<?> clazz) {
17  
18  		checkNotNull(clazz, "clazz");
19  
20  		final Logger cached = loggers.get(clazz);
21  
22  		if (cached != null) {
23  
24  			return cached;
25  		}
26  
27  		final Logger logger = new Logger() {
28  
29  			@Override
30  			public void debug(@Nullable final String message) {
31  
32  				if (DEBUG) {
33  
34  					System.out.println("DEBUG: " + message);
35  				}
36  			}
37  		};
38  
39  		loggers.put(clazz, logger);
40  
41  		return logger;
42  	}
43  }