Skip to content

Commit fdb92d6

Browse files
committed
1) use std::stringstream::view; 2) add comment to test
1 parent f874ed9 commit fdb92d6

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

cpp/src/arrow/util/logging.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class CerrLog {
7171
if (has_logged_) {
7272
static std::mutex cerr_mutex;
7373
std::lock_guard<std::mutex> lock(cerr_mutex);
74-
std::cerr << buffer_.str() << std::endl;
74+
std::cerr << buffer_.view() << std::endl;
7575
}
7676
if (severity_ == ArrowLogLevel::ARROW_FATAL) {
7777
PrintBackTrace();

cpp/src/arrow/util/logging_test.cc

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,11 @@ int64_t current_time_ms() {
4242
// This file just print some information using the logging macro.
4343

4444
void PrintLog() {
45-
ARROW_LOG(DEBUG) << "This is the"
46-
<< " DEBUG"
47-
<< " message";
48-
ARROW_LOG(INFO) << "This is the"
49-
<< " INFO message";
50-
ARROW_LOG(WARNING) << "This is the"
51-
<< " WARNING message";
52-
ARROW_LOG(ERROR) << "This is the"
53-
<< " ERROR message";
54-
ARROW_CHECK(true) << "This is a ARROW_CHECK"
55-
<< " message but it won't show up";
45+
ARROW_LOG(DEBUG) << "This is the" << " DEBUG" << " message";
46+
ARROW_LOG(INFO) << "This is the" << " INFO message";
47+
ARROW_LOG(WARNING) << "This is the" << " WARNING message";
48+
ARROW_LOG(ERROR) << "This is the" << " ERROR message";
49+
ARROW_CHECK(true) << "This is a ARROW_CHECK" << " message but it won't show up";
5650
// The following 2 lines should not run since it will cause program failure.
5751
// ARROW_LOG(FATAL) << "This is the FATAL message";
5852
// ARROW_CHECK(false) << "This is a ARROW_CHECK message but it won't show up";
@@ -98,6 +92,8 @@ TEST(ArrowCheck, PayloadEvaluatedOnFailure) {
9892
}
9993

10094
TEST(ArrowLog, MultiThreadedLogging) {
95+
// This is mostly a visual test that logging from multiple threads produces
96+
// a clean output without interleaving messages (GH-49433).
10197
constexpr int kNumThreads = 10;
10298
constexpr int kNumMessges = 10;
10399
std::vector<std::thread> threads;
@@ -107,7 +103,7 @@ TEST(ArrowLog, MultiThreadedLogging) {
107103
for (int i = 0; i < kNumThreads; ++i) {
108104
threads.emplace_back([i]() {
109105
for (int j = 0; j < kNumMessges; ++j) {
110-
ARROW_LOG(INFO) << "Thread" << i << " message " << j
106+
ARROW_LOG(INFO) << "Thread " << i << " message " << j
111107
<< " - testing thread safety.";
112108
}
113109
});

0 commit comments

Comments
 (0)