package com.oneliang.util.logging;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author oneliang
 */
public final class LoggerManager {

	private static final Map<Class<?>, Logger> loggerMap=new ConcurrentHashMap<Class<?>, Logger>();

	/**
	 * get logger
	 * @param clazz
	 * @return Logger
	 */
	public static Logger getLogger(Class<?> clazz) {
		Logger logger = loggerMap.get(clazz);
		return logger == null ? new BaseLogger(Logger.Level.ERROR) : logger;
	}

	/**
	 * register logger
	 * @param clazz
	 * @param logger
	 */
	public static void registerLogger(Class<?> clazz, Logger logger){
		loggerMap.put(clazz, logger);
	}

	/**
	 * unregister logger
	 * @param clazz
	 */
	public static void unregisterLogger(Class<?> clazz){
		loggerMap.remove(clazz);
	}
}

@@ -51,16 +51,38 @@
 il.Map;%0A
+import java.util.Set;%0A
 import j
@@ -119,16 +119,112 @@
 HashMap;
+%0Aimport java.util.concurrent.ConcurrentSkipListSet;%0A%0Aimport com.oneliang.util.common.StringUtil;
 %0A%0A/**%0A *
@@ -382,530 +382,1445 @@
 ();%0A
-%0A%09/**%0A%09 * get logger%0A%09 * @param clazz%0A%09 * @return Logger%0A%09 */%0A%09public static Logger getLogger(Class%3C?%3E clazz) %7B%0A%09%09Logger logger = loggerMap.get(clazz);%0A%09%09return logger == null ? new BaseLogger(Logger.Level.ERROR) : logger;%0A%09%7D%0A%0A%09/**%0A%09 * register logger%0A%09 * @param clazz%0A%09 * @param logger%0A%09 */%0A%09public static void registerLogger(Class%3C?%3E clazz, Logger logger)%7B%0A%09%09loggerMap.put(clazz, logger);%0A%09%7D%0A%0A%09/**%0A%09 * unregister logger%0A%09 * @param clazz%0A%09 */%0A%09public static void unregisterLogger(Class%3C?%3E clazz)%7B%0A%09%09loggerMap.remove(clazz
+%09private static final Map%3CString, Logger%3E loggerPatternMap=new ConcurrentHashMap%3CString, Logger%3E();%0A%09private static final Set%3CString%3E loggerPatternSet=new ConcurrentSkipListSet%3CString%3E();%0A%0A%09/**%0A%09 * get logger%0A%09 * @param clazz%0A%09 * @return Logger%0A%09 */%0A%09public static Logger getLogger(Class%3C?%3E clazz) %7B%0A%09%09if(clazz==null)%7B%0A%09%09%09throw new NullPointerException(%22parameter%5BClass%3C?%3E class%5D can no be null%22);%0A%09%09%7D%0A%09%09Logger logger = loggerMap.get(clazz);%0A%09%09if(logger==null)%7B%0A%09%09%09String className=clazz.getName();%0A%09%09%09for(String patternKey:loggerPatternSet)%7B%0A%09%09%09%09if(StringUtil.isMatchPattern(className, patternKey))%7B%0A%09%09%09%09%09logger=loggerPatternMap.get(patternKey);%0A%09%09%09%09%09break;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09return logger == null ? new BaseLogger(Logger.Level.ERROR) : logger;%0A%09%7D%0A%0A%09/**%0A%09 * register logger%0A%09 * @param clazz%0A%09 * @param logger%0A%09 */%0A%09public static void registerLogger(Class%3C?%3E clazz, Logger logger)%7B%0A%09%09loggerMap.put(clazz, logger);%0A%09%7D%0A%0A%09/**%0A%09 * register logger%0A%09 * @param pattern%0A%09 * @param logger%0A%09 */%0A%09public static void registerLogger(String pattern, Logger logger)%7B%0A%09%09loggerPatternMap.put(pattern, logger);%0A%09%09loggerPatternSet.add(pattern);%0A%09%7D%0A%0A%09/**%0A%09 * unregister logger%0A%09 * @param clazz%0A%09 */%0A%09public static void unregisterLogger(Class%3C?%3E clazz)%7B%0A%09%09loggerMap.remove(clazz);%0A%09%7D%0A%0A%09/**%0A%09 * unregister logger%0A%09 * @param pattern%0A%09 */%0A%09public static void unregisterLogger(String pattern)%7B%0A%09%09loggerPatternMap.remove(pattern);%0A%09%09loggerPatternSet.remove(pattern
 );%0A%09

add pattern match to LoggerManager.java