Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ private static boolean isLoggerClass(String className) {
return className.equals("com.google.cloud.bigquery.jdbc.BigQueryJdbcCustomLogger")
|| className.equals("com.google.cloud.bigquery.jdbc.BigQueryJdbcResultSetLogger")
|| className.startsWith("com.google.cloud.bigquery.jdbc.BigQueryJdbcRootLogger")
|| className.equals("com.google.cloud.bigquery.jdbc.PerConnectionFileHandler")
Comment thread
Neenu1995 marked this conversation as resolved.
|| className.equals(BigQueryJdbcLogRecord.class.getName());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import com.google.cloud.bigquery.FieldValue.Attribute;
import com.google.cloud.bigquery.FieldValueList;
import com.google.cloud.bigquery.LegacySQLTypeName;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
Expand All @@ -41,6 +42,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

public class BigQueryJdbcCustomLoggerTest extends BigQueryJdbcLoggingBaseTest {

Expand Down Expand Up @@ -118,6 +120,28 @@ public void testLazyCallerInference() {
assertEquals("testLazyCallerInference", methodName);
}

@Test
public void testCallerInferenceWithPerConnectionFileHandler(@TempDir Path tempDir) {
PerConnectionFileHandler perConnHandler =
new PerConnectionFileHandler(tempDir.toString(), Level.ALL);
try {
logger.fine("Message through PerConnectionFileHandler");

List<LogRecord> records = testHandler.getRecords();
assertEquals(1, records.size());
LogRecord record = records.get(0);

// Publish record via PerConnectionFileHandler to put PerConnectionFileHandler on stack trace
perConnHandler.publish(record);

// Verify that caller inference skips PerConnectionFileHandler frame
assertEquals(BigQueryJdbcCustomLoggerTest.class.getName(), record.getSourceClassName());
assertEquals("testCallerInferenceWithPerConnectionFileHandler", record.getSourceMethodName());
} finally {
perConnHandler.close();
}
}

@Test
public void testHotPathLoggerLogToDefaultWhenContextIsNull() {
BigQueryJdbcCustomLogger hotpathLogger =
Expand Down
Loading