當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。