Commit b2665cee by Abseil Team Committed by Copybara-Service

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
parent 69c46839
......@@ -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");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment