Search in sources :

Example 71 with LogRecord

use of java.util.logging.LogRecord in project robovm by robovm.

the class OldFileHandlerTest method testPublish.

public void testPublish() throws Exception {
    LogRecord[] r = new LogRecord[] { new LogRecord(Level.CONFIG, "msg__"), new LogRecord(Level.WARNING, "message"), new LogRecord(Level.INFO, "message for"), new LogRecord(Level.FINE, "message for test") };
    for (int i = 0; i < r.length; i++) {
        handler = new FileHandler("%t/log/stringPublish");
        handler.publish(r[i]);
        handler.close();
        assertFileContent(TEMPPATH + SEP + "log", "stringPublish", new LogRecord[] { r[i] }, handler.getFormatter());
    }
}
Also used : LogRecord(java.util.logging.LogRecord) FileHandler(java.util.logging.FileHandler)

Example 72 with LogRecord

use of java.util.logging.LogRecord in project GCViewer by chewiebug.

the class TestDataReaderJRockit1_5_0 method testMalformedType.

/**
     * Test parsing of a malformed type. The test just expects an INFO to be logged - nothing else.
     */
@Test
public void testMalformedType() throws Exception {
    TestLogHandler handler = new TestLogHandler();
    handler.setLevel(Level.INFO);
    GCResource gcResource = new GcResourceFile("byteArray");
    gcResource.getLogger().addHandler(handler);
    ByteArrayInputStream in = new ByteArrayInputStream(("[memory ][Thu Feb 21 15:06:38 2013][11844] 6.290-6.424: GC-malformed 3128161K->296406K (3145728K), sum of pauses 59.084 ms").getBytes());
    DataReader reader = new DataReaderJRockit1_5_0(gcResource, in);
    reader.read();
    // 3 INFO events:
    // Reading JRockit ... format
    // Failed to determine type ...
    // Reading done.
    assertEquals("number of infos", 3, handler.getCount());
    List<LogRecord> logRecords = handler.getLogRecords();
    assertEquals("should start with 'Failed to determine type'", 0, logRecords.get(1).getMessage().indexOf("Failed to determine type"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LogRecord(java.util.logging.LogRecord) GCResource(com.tagtraum.perf.gcviewer.model.GCResource) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) Test(org.junit.Test)

Example 73 with LogRecord

use of java.util.logging.LogRecord in project GCViewer by chewiebug.

the class TestDataReaderJRockit1_6_0 method testMalformedType.

@Test
public void testMalformedType() throws Exception {
    TestLogHandler handler = new TestLogHandler();
    handler.setLevel(Level.INFO);
    GCResource gcResource = new GcResourceFile("byteArray");
    gcResource.getLogger().addHandler(handler);
    ByteArrayInputStream in = new ByteArrayInputStream(("[INFO ][memory ] [YC#1] 9.743-9.793: YC-malformed 294974KB->122557KB (524288KB), 0.050 s, sum of pauses 49.692 ms, longest pause 49.692 ms.").getBytes());
    DataReader reader = new DataReaderJRockit1_6_0(gcResource, in);
    reader.read();
    // 3 INFO events:
    // Reading JRockit ... format
    // Failed to determine type ...
    // Reading done.
    assertEquals("number of infos", 3, handler.getCount());
    List<LogRecord> logRecords = handler.getLogRecords();
    assertEquals("should start with 'Failed to determine type'", 0, logRecords.get(1).getMessage().indexOf("Failed to determine type"));
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) LogRecord(java.util.logging.LogRecord) GCResource(com.tagtraum.perf.gcviewer.model.GCResource) GcResourceFile(com.tagtraum.perf.gcviewer.model.GcResourceFile) Test(org.junit.Test)

Example 74 with LogRecord

use of java.util.logging.LogRecord in project buck by facebook.

the class JavaUtilsLoggingBuildListener method buildStarted.

@Subscribe
public void buildStarted(BuildEvent.Started started) {
    LogRecord record = new LogRecord(LEVEL, "Build started");
    record.setMillis(started.getTimestamp());
    LOG.log(record);
}
Also used : LogRecord(java.util.logging.LogRecord) Subscribe(com.google.common.eventbus.Subscribe)

Example 75 with LogRecord

use of java.util.logging.LogRecord in project buck by facebook.

the class JavaUtilsLoggingBuildListener method ruleStarted.

@Subscribe
public void ruleStarted(BuildRuleEvent.Started started) {
    LogRecord record = new LogRecord(LEVEL, started.toString());
    record.setMillis(started.getTimestamp());
    LOG.log(record);
}
Also used : LogRecord(java.util.logging.LogRecord) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

LogRecord (java.util.logging.LogRecord)370 Logger (java.util.logging.Logger)62 Test (org.junit.Test)61 Handler (java.util.logging.Handler)24 File (java.io.File)21 IOException (java.io.IOException)21 ByteArrayOutputStream (java.io.ByteArrayOutputStream)16 Level (java.util.logging.Level)16 StreamHandler (java.util.logging.StreamHandler)14 ConsoleHandler (java.util.logging.ConsoleHandler)13 ArrayList (java.util.ArrayList)12 Properties (java.util.Properties)11 Config (com.sun.enterprise.config.serverbeans.Config)10 Formatter (java.util.logging.Formatter)10 SimpleFormatter (java.util.logging.SimpleFormatter)10 LogRecordCollectingLogger (alma.acs.testsupport.LogRecordCollectingLogger)9 BlockingQueueHandler (fish.payara.nucleus.notification.BlockingQueueHandler)9 ActionReport (org.glassfish.api.ActionReport)9 HashMap (java.util.HashMap)7 Subscribe (com.google.common.eventbus.Subscribe)6