本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}