Search in sources :

Example 1 with WriteOption

use of com.google.cloud.logging.Logging.WriteOption in project google-cloud-java by GoogleCloudPlatform.

the class LoggingAppenderTest method testDefaultWriteOptionsHasExpectedDefaults.

@Test
public void testDefaultWriteOptionsHasExpectedDefaults() {
    logging.setFlushSeverity(Severity.ERROR);
    Capture<WriteOption> logNameArg = Capture.newInstance();
    Capture<WriteOption> resourceArg = Capture.newInstance();
    logging.write((Iterable<LogEntry>) anyObject(), capture(logNameArg), capture(resourceArg));
    expectLastCall().once();
    replay(logging);
    loggingAppender.start();
    Timestamp timestamp = Timestamp.ofTimeSecondsAndNanos(100000, 0);
    LoggingEvent loggingEvent = createLoggingEvent(Level.ERROR, timestamp.getSeconds());
    loggingAppender.doAppend(loggingEvent);
    Assert.assertTrue(logNameArg.getValue().equals(defaultWriteOptions[0]));
    Assert.assertTrue(resourceArg.getValue().equals(defaultWriteOptions[1]));
}
Also used : LoggingEvent(ch.qos.logback.classic.spi.LoggingEvent) Timestamp(com.google.cloud.Timestamp) LogEntry(com.google.cloud.logging.LogEntry) WriteOption(com.google.cloud.logging.Logging.WriteOption) Test(org.junit.Test)

Example 2 with WriteOption

use of com.google.cloud.logging.Logging.WriteOption in project google-cloud-java by GoogleCloudPlatform.

the class LoggingTest method testWriteOption.

@Test
public void testWriteOption() {
    WriteOption writeOption = WriteOption.labels(LABELS);
    assertEquals(LABELS, writeOption.getValue());
    assertEquals(WriteOption.OptionType.LABELS, writeOption.getOptionType());
    writeOption = WriteOption.logName(LOG_NAME);
    assertEquals(LOG_NAME, writeOption.getValue());
    assertEquals(WriteOption.OptionType.LOG_NAME, writeOption.getOptionType());
    writeOption = WriteOption.resource(RESOURCE);
    assertEquals(RESOURCE, writeOption.getValue());
    assertEquals(WriteOption.OptionType.RESOURCE, writeOption.getOptionType());
}
Also used : WriteOption(com.google.cloud.logging.Logging.WriteOption) Test(org.junit.Test)

Aggregations

WriteOption (com.google.cloud.logging.Logging.WriteOption)2 Test (org.junit.Test)2 LoggingEvent (ch.qos.logback.classic.spi.LoggingEvent)1 Timestamp (com.google.cloud.Timestamp)1 LogEntry (com.google.cloud.logging.LogEntry)1