package org.nutz.log;

import org.nutz.plugin.SimplePluginManager;

/**
 * 获取 Log 的静态工厂方法
 * 
 * @author Young(sunonfire@gmail.com)
 * @author zozoh(zozohtnt@gmail.com)
 * @author Wendal(wendal1985@gmail.com)
 */
public final class Logs {

	private static LogAdapter adapter;

	static {
		init();
	}

	/**
	 * Get a Log by Class
	 * 
	 * @param clazz
	 *            your class
	 * @return Log
	 * @throws NullPointerException
	 *             when clazz is null
	 */
	public static Log getLog(Class<?> clazz) {
		return getLog(clazz.getName());
	}

	/**
	 * Get a Log by name
	 * 
	 * @param className
	 *            the name of Log
	 * @return Log
	 * @throws NullPointerException
	 *             when className is null, maybe it will case NPE
	 */
	public static Log getLog(String className) {
		return adapter.getLogger(className);
	}

	/**
	 * 返回以调用者的类命名的Log,是获取Log对象最简单的方法!
	 */
	public static Log get() {
		return adapter.getLogger(Thread.currentThread().getStackTrace()[2].getClassName());
	}

	/**
	 * 初始化NutLog,检查全部Log的可用性,选择可用的Log适配器
	 * <p/>
	 * <b>加载本类时,该方法已经在静态构造函数中调用,用户无需主动调用.</b>
	 * <p/>
	 * <b>除非迫不得已,请不要调用本方法<b/>
	 */
	public static void init() {
		try {
			adapter = new SimplePluginManager<LogAdapter>(	"org.nutz.log.impl.Log4jLogAdapter",
															"org.nutz.log.impl.SystemLogAdapter").get();
		}
		catch (Throwable e) {
			e.printStackTrace();
		}
	}
}

@@ -92,16 +92,45 @@
 %E5%8E%82%E6%96%B9%E6%B3%95%0D%0A * 
+%3Cp/%3E%3Cb%3E%E5%88%87%E5%8B%BF%E6%94%B9%E5%8F%98log%E5%8C%85%E7%9A%84package%E5%AE%9A%E4%B9%89%3C/b%3E
 %0D%0A * @au
@@ -1211,16 +1211,26 @@
 %E6%96%B9%E6%B3%95%3Cb/%3E%0D%0A
+%09 * %3Cp/%3E%0D%0A
 %09 */%0D%0A%09p
@@ -1445,16 +1445,133 @@
 e e) %7B%0D%0A
+%09%09%09//%E8%BF%99%E6%98%AF%E4%B8%8D%E5%BA%94%E8%AF%A5%E5%8F%91%E7%94%9F%E7%9A%84,SystemLogAdapter%E5%BA%94%E8%AF%A5%E6%B0%B8%E8%BF%9C%E8%BF%94%E5%9B%9Etrue%0D%0A%09%09%09//%E5%94%AF%E4%B8%80%E7%9A%84%E5%8F%AF%E8%83%BD%E6%80%A7%E6%98%AF%E6%89%80%E8%AF%B7%E6%B1%82%E7%9A%84org.nutz.log.impl.SystemLogAdapter%E6%A0%B9%E6%9C%AC%E4%B8%8D%E5%AD%98%E5%9C%A8%0D%0A%09%09%09//%E4%BE%8B%E5%A6%82%E6%94%B9%E4%BA%86package%0D%0A
 %09%09%09e.pri

add notes in Logs