當前位置: 首頁>>代碼示例>>Java>>正文


Java LogRecord.setMillis方法代碼示例

本文整理匯總了Java中java.util.logging.LogRecord.setMillis方法的典型用法代碼示例。如果您正苦於以下問題:Java LogRecord.setMillis方法的具體用法?Java LogRecord.setMillis怎麽用?Java LogRecord.setMillis使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.logging.LogRecord的用法示例。


在下文中一共展示了LogRecord.setMillis方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUp

import java.util.logging.LogRecord; //導入方法依賴的package包/類
@Override
@Before
protected void setUp() throws Exception {
    super.setUp();
    System.setProperty("netbeans.user", getWorkDirPath());
    UIHandler.flushImmediatelly();
    clearWorkDir();

    Installer.clearLogs();

    Installer installer = Installer.findObject(Installer.class, true);
    assertNotNull(installer);
    installer.restored();

    now = System.currentTimeMillis();
    LogRecord rec = new LogRecord(Level.FINE, "UI_ACTION_EDITOR");
    Object[] params = new Object[]{null, null, null, null, "undo"};
    rec.setMillis(now - SlownessReporter.LATEST_ACTION_LIMIT/2);
    rec.setParameters(params);
    Logger.getLogger(TEST_LOGGER).log(rec);
    LogRecord rec2 = new LogRecord(Level.FINE, "UI_ACTION_EDITOR");
    params = new Object[]{null, null, null, null, "redo"};
    rec2.setMillis(now - SlownessReporter.LATEST_ACTION_LIMIT/5);
    rec2.setParameters(params);
    Logger.getLogger(TEST_LOGGER).log(rec2);
    LogRecord rec3 = new LogRecord(Level.FINE, "SOME OTHER LOG");
    params = new Object[]{null, null, null, null, "redo"};
    rec3.setMillis(now - SlownessReporter.LATEST_ACTION_LIMIT/10);
    rec3.setParameters(params);
    Logger.getLogger(TEST_LOGGER).log(rec3);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:32,代碼來源:SlownessReporterTest.java

示例2: asLogRecord

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public static LogRecord asLogRecord(SerializableLogRecord serializableLogRecord) {
    LogRecord logRecord = new LogRecord(Level.parse(serializableLogRecord.level), serializableLogRecord.message);
    logRecord.setLoggerName(serializableLogRecord.loggerName);
    logRecord.setMillis(serializableLogRecord.millis);
    logRecord.setThrown(JsonLogRecordThrowable.fromJsonString(serializableLogRecord.thrown));
    return logRecord;
}
 
開發者ID:GwtDomino,項目名稱:domino,代碼行數:8,代碼來源:SerializableLogRecordMapper.java

示例3: annotate

import java.util.logging.LogRecord; //導入方法依賴的package包/類
/** Calls all delegates. */
public Throwable annotate(
    Throwable t, int severity, String message, final String localizedMessage, Throwable stackTrace,
    java.util.Date date
) {
    if (delegates.isEmpty()) {
        LogRecord rec = new LogRecord(convertSeverity(severity, true, Level.ALL), message);
        if (stackTrace != null) {
            rec.setThrown(stackTrace);
        }
        if (date != null) {
            rec.setMillis(date.getTime());
        }
        if (localizedMessage != null) {
            ResourceBundle rb = new ResourceBundle() {
                public Object handleGetObject(String key) {
                    if ("msg".equals(key)) { // NOI18N
                        return localizedMessage;
                    } else {
                        return null;
                    }
                }
                
                public Enumeration<String> getKeys() {
                    return Enumerations.singleton("msg"); // NOI18N
                }
            };
            rec.setResourceBundle(rb);
            rec.setMessage("msg"); // NOI18N
        }
        
        AnnException ann = AnnException.findOrCreate(t, true);
        if (ann != null) {  //#148778 - Although ann should not be null, it was reported it can happen.
            ann.addRecord(rec);
        }
        
        return t;
    }
    
    for (ErrorManager em : delegates) {
        em.annotate(t, severity, message, localizedMessage, stackTrace, date);
    }

    return t;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:46,代碼來源:ErrorManager.java

示例4: asLogRecord

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public LogRecord asLogRecord() {
	LogRecord result = new LogRecord(getLevel(), getMessage());
	result.setMillis(getMillis());
    result.setLoggerName(getCategory());
	return result;
}
 
開發者ID:kefik,項目名稱:Pogamut3,代碼行數:7,代碼來源:NetworkLogEnvelope.java

示例5: test

import java.util.logging.LogRecord; //導入方法依賴的package包/類
public static void test(Properties props) {
    Configuration conf = Configuration.apply(props);

    LogRecord record = new LogRecord(Level.INFO, "Test Name: {0}");
    record.setLoggerName("test");
    record.setParameters(new Object[] {conf.testName()});
    int nanos = record.getInstant().getNano() % NANOS_IN_MILLI;
    long millis = record.getMillis();
    // make sure we don't have leading zeros when printing below
    // the second precision
    if (millis % MILLIS_IN_SECOND < 100) millis = millis + 100;
    // make sure we some nanos - and make sure we don't have
    // trailing zeros
    if (nanos % 10 == 0) nanos = nanos + 7;

    record.setMillis(millis);
    setNanoAdjustment(record, nanos);
    final Instant instant = record.getInstant();
    if (nanos < 0) {
        throw new RuntimeException("Unexpected negative nano adjustment: "
                + getNanoAdjustment(record));
    }
    if (nanos >= NANOS_IN_MILLI) {
        throw new RuntimeException("Nano adjustment exceeds 1ms: "
                + getNanoAdjustment(record));
    }
    if (millis != record.getMillis()) {
        throw new RuntimeException("Unexpected millis: " + millis + " != "
                + record.getMillis());
    }
    if (millis != record.getInstant().toEpochMilli()) {
        throw new RuntimeException("Unexpected millis: "
                + record.getInstant().toEpochMilli());
    }
    long expectedNanos = (millis % MILLIS_IN_SECOND) * NANOS_IN_MILLI + nanos;
    assertEquals(expectedNanos, instant.getNano(), "Instant.getNano()");

    XMLFormatter formatter = new XMLFormatter();
    testMatching(formatter, record, instant, expectedNanos, conf.useInstant(formatter));

    XMLFormatter custom = new CustomXMLFormatter();
    testMatching(custom, record, instant, expectedNanos, conf.useInstant(custom));
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:44,代碼來源:XmlFormatterNanos.java


注:本文中的java.util.logging.LogRecord.setMillis方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。