mirror of
https://github.com/abseil/abseil-cpp.git
synced 2026-06-04 12:07:05 +08:00
Do not truncate ABSL_RAW_LOG output at null bytes
This fixes the behavior of ```c++ ABSL_RAW_LOG(INFO, "RAW INFO: %s%c%s", "Hello", 0, "World"); ``` which would previously truncate at the `\0`. The new behavior is consistent with `printf`. PiperOrigin-RevId: 663049889 Change-Id: I171dcb8a61b19873b88920e383f03acf7fb112d7
This commit is contained in:
committed by
Copybara-Service
parent
69c4683962
commit
b2665cee02
@@ -175,7 +175,7 @@ void RawLogVA(absl::LogSeverity severity, const char* file, int line,
|
||||
} else {
|
||||
DoRawLog(&buf, &size, "%s", kTruncated);
|
||||
}
|
||||
AsyncSignalSafeWriteError(buffer, strlen(buffer));
|
||||
AsyncSignalSafeWriteError(buffer, static_cast<size_t>(buf - buffer));
|
||||
}
|
||||
#else
|
||||
static_cast<void>(format);
|
||||
|
||||
@@ -35,6 +35,10 @@ TEST(RawLoggingCompilationTest, Log) {
|
||||
ABSL_RAW_LOG(ERROR, "RAW ERROR: %d", 1);
|
||||
}
|
||||
|
||||
TEST(RawLoggingCompilationTest, LogWithNulls) {
|
||||
ABSL_RAW_LOG(INFO, "RAW INFO: %s%c%s", "Hello", 0, "World");
|
||||
}
|
||||
|
||||
TEST(RawLoggingCompilationTest, PassingCheck) {
|
||||
ABSL_RAW_CHECK(true, "RAW CHECK");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user