当前位置: 首页>>代码示例>>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;未经允许,请勿转载。