当前位置: 首页>>代码示例>>Java>>正文


Java Logger.logrb方法代码示例

本文整理汇总了Java中java.util.logging.Logger.logrb方法的典型用法代码示例。如果您正苦于以下问题:Java Logger.logrb方法的具体用法?Java Logger.logrb怎么用?Java Logger.logrb使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.logging.Logger的用法示例。


在下文中一共展示了Logger.logrb方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: logrb

import java.util.logging.Logger; //导入方法依赖的package包/类
public void logrb(Logger logger, ResourceBundle bundle) {
    switch(this) {
        case LOGRB_NO_ARGS:
            logger.logrb(Level.CONFIG,
                    TestLogrbResourceBundle.class.getName(),
                    "main", bundle, "dummy");
            break;
        case LOGRB_SINGLE_ARG:
            logger.logrb(Level.CONFIG,
                    TestLogrbResourceBundle.class.getName(),
                    "main", bundle, "dummy", "bar");
            break;
        case LOGRB_ARG_ARRAY:
            logger.logrb(Level.CONFIG,
                    TestLogrbResourceBundle.class.getName(),
                    "main", bundle, "dummy",
                    new Object[] { "bar", "baz"} );
            break;
        case LOGRB_VARARGS:
            logger.logrb(Level.CONFIG,
                    TestLogrbResourceBundle.class.getName(),
                    "main", bundle, "dummy",
                    "bar", "baz" );
            break;
        case LOGRB_THROWABLE:
            logger.logrb(Level.CONFIG,
                    TestLogrbResourceBundle.class.getName(),
                    "main", bundle, "dummy",
                    new Exception("dummy exception") );
            break;
        default:
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:34,代码来源:TestLogrbResourceBundle.java

示例2: test2

import java.util.logging.Logger; //导入方法依赖的package包/类
void test2(Logger logger) {
    AtomicInteger count = new AtomicInteger();
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
    logger.setLevel(Level.ALL);
    assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");

    for (Level l : Arrays.asList(Level.SEVERE, Level.WARNING, Level.INFO,
            Level.CONFIG, Level.FINE, Level.FINER, Level.FINEST)) {
        System.out.println("test2: " + loggerName(logger) + " " + l);
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");

        logger.log(l, "message " + count.incrementAndGet());
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        LogEvent event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

        logger.log(l, "message " + count.incrementAndGet(), "param");
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

        logger.log(l, "message " + count.incrementAndGet(), new Object[] {"foo", "bar"});
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

        logger.log(l, "message " + count.incrementAndGet(), new RuntimeException());
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

        // JDK 8 & 9 only (uses lambda)
        logger.log(l, () -> "message " + count.incrementAndGet());
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

        // JDK 8 & 9 only (uses lambda)
        logger.log(l, new RuntimeException(), () -> "message " + count.incrementAndGet());
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

        // JDK 9 only: new API
        logger.logrb(l, (ResourceBundle)null, "message " + count.incrementAndGet(), (Object[]) null);
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

        // JDK 9 only: new API
        logger.logrb(l, (ResourceBundle)null, "message " + count.incrementAndGet(), new RuntimeException());
        assertEquals(1, TestHandler.PUBLISHED.size(), "No event in queue: ");
        event = TestHandler.PUBLISHED.remove();
        assertEquals(0, TestHandler.PUBLISHED.size(), "Queue should be empty: ");
        checkEvent(event, this.getClass().getName(), "test2", "message " + count.get());

    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:TestInferCaller.java


注:本文中的java.util.logging.Logger.logrb方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。