Search in sources :

Example 1 with SystemLogAdapter

use of org.nutz.log.impl.SystemLogAdapter in project nutz by nutzam.

the class SystemLogAdapterTest method testGetLogger.

@Test
public void testGetLogger() {
    LogAdapter logAdapter = new SystemLogAdapter();
    assertNotNull(logAdapter.getLogger(Log.class.getName()));
}
Also used : SystemLogAdapter(org.nutz.log.impl.SystemLogAdapter) SystemLogAdapter(org.nutz.log.impl.SystemLogAdapter) Test(org.junit.Test)

Example 2 with SystemLogAdapter

use of org.nutz.log.impl.SystemLogAdapter in project nutz by nutzam.

the class PlugsTest method test_get_plugin_from_ioc.

@Test
public void test_get_plugin_from_ioc() {
    Ioc ioc = new NutIoc(new JsonLoader("org/nutz/plugin/plugin.js"));
    PluginManager<Log> manager = new IocPluginManager<Log>(ioc, "pluB", "pluA", "pluC");
    assertNotNull(manager.get());
    assertTrue(manager.get() instanceof SystemLogAdapter);
    ioc.depose();
}
Also used : NutIoc(org.nutz.ioc.impl.NutIoc) Log(org.nutz.log.Log) SystemLogAdapter(org.nutz.log.impl.SystemLogAdapter) JsonLoader(org.nutz.ioc.loader.json.JsonLoader) Ioc(org.nutz.ioc.Ioc) NutIoc(org.nutz.ioc.impl.NutIoc) Test(org.junit.Test)

Example 3 with SystemLogAdapter

use of org.nutz.log.impl.SystemLogAdapter in project nutz by nutzam.

the class Logs method init.

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

Aggregations

SystemLogAdapter (org.nutz.log.impl.SystemLogAdapter)3 Test (org.junit.Test)2 Ioc (org.nutz.ioc.Ioc)1 NutIoc (org.nutz.ioc.impl.NutIoc)1 JsonLoader (org.nutz.ioc.loader.json.JsonLoader)1 Log (org.nutz.log.Log)1 Log4jLogAdapter (org.nutz.log.impl.Log4jLogAdapter)1 SimplePluginManager (org.nutz.plugin.SimplePluginManager)1