8319554: Select LogOutput* directly for stdout and stderr
Reviewed-by: jsjolen, dholmes
This commit is contained in:
parent
68110b7a82
commit
d7b0ba9d7c
@ -505,6 +505,12 @@ bool LogConfiguration::parse_log_arguments(const char* outputstr,
|
||||
errstream->print_cr("Invalid output index '%s'", outputstr);
|
||||
return false;
|
||||
}
|
||||
} else if (strcmp(outputstr, StdoutLog->name()) == 0) { // stdout
|
||||
idx = 0;
|
||||
assert(find_output(outputstr) == idx, "sanity check");
|
||||
} else if (strcmp(outputstr, StderrLog->name()) == 0) { // stderr
|
||||
idx = 1;
|
||||
assert(find_output(outputstr) == idx, "sanity check");
|
||||
} else { // Output specified using name
|
||||
// Normalize the name, stripping quotes and ensures it includes type prefix
|
||||
size_t len = strlen(outputstr) + strlen(implicit_output_prefix) + 1;
|
||||
|
@ -256,7 +256,10 @@ TEST_VM_F(AsyncLogTest, droppingMessage) {
|
||||
TEST_VM_F(AsyncLogTest, stdoutOutput) {
|
||||
testing::internal::CaptureStdout();
|
||||
fprintf(stdout, "header");
|
||||
set_log_config("stdout", "logging=debug");
|
||||
|
||||
if (!set_log_config("stdout", "logging=debug")) {
|
||||
return;
|
||||
}
|
||||
|
||||
test_asynclog_ls();
|
||||
test_asynclog_drop_messages();
|
||||
@ -264,22 +267,27 @@ TEST_VM_F(AsyncLogTest, stdoutOutput) {
|
||||
AsyncLogWriter::flush();
|
||||
fflush(nullptr);
|
||||
|
||||
if (write_to_file(testing::internal::GetCapturedStdout())) {
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "header"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
||||
if (!write_to_file(testing::internal::GetCapturedStdout())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AsyncLogWriter::instance() != nullptr) {
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
||||
}
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "header"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
||||
|
||||
if (AsyncLogWriter::instance() != nullptr) {
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
||||
}
|
||||
}
|
||||
|
||||
TEST_VM_F(AsyncLogTest, stderrOutput) {
|
||||
testing::internal::CaptureStderr();
|
||||
fprintf(stderr, "header");
|
||||
set_log_config("stderr", "logging=debug");
|
||||
|
||||
if (!set_log_config("stderr", "logging=debug")) {
|
||||
return;
|
||||
}
|
||||
|
||||
test_asynclog_ls();
|
||||
test_asynclog_drop_messages();
|
||||
@ -287,14 +295,16 @@ TEST_VM_F(AsyncLogTest, stderrOutput) {
|
||||
AsyncLogWriter::flush();
|
||||
fflush(nullptr);
|
||||
|
||||
if (write_to_file(testing::internal::GetCapturedStderr())) {
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "header"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
||||
if (!write_to_file(testing::internal::GetCapturedStderr())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (AsyncLogWriter::instance() != nullptr) {
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
||||
}
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "header"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "LogStreamWithAsyncLogImpl"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream msg1-msg2-msg3"));
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "logStream newline"));
|
||||
|
||||
if (AsyncLogWriter::instance() != nullptr) {
|
||||
EXPECT_TRUE(file_contains_substring(TestLogFileName, "messages dropped due to async logging"));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user