SteNicholas opened a new pull request, #457:
URL: https://github.com/apache/paimon-cpp/pull/457
<!-- PR titles must follow Conventional Commits: <type>(<optional-scope>):
<description> -->
### Purpose
<!-- Linking this pull request to the issue -->
Linked issue: close #456
<!-- What is the purpose of the change -->
`GlogAdaptor::LogV` passed its `va_list` directly to `google::RawLog__`.
`RawLog__` is a printf-style
variadic function with no `va_list` overload, so the `va_list` object was
passed as a single
variadic argument. Every format conversion read the wrong argument: messages
logged with arguments
through the default logger came out garbled (`%s` printed `0`, for example),
and later conversions
could read arbitrary memory.
- **`GlogAdaptor::LogV`**: expands the arguments with `std::vsnprintf`
first, then passes the result
to `RawLog__` through a fixed `"%s"` format. A `%` inside an argument is
printed literally instead
of being read as another conversion.
- **Buffer size**: 2048 bytes, below glog's 3000-byte raw log buffer. glog
replaces any message that
does not fit its buffer with `RAW_LOG ERROR: The Message was too long!`,
so a larger buffer would
lose long messages entirely. With 2048 bytes, a long message is truncated
to its first 2047 bytes
instead.
- **`GlogForwardingLogger`** in `logging_test.cpp` copied the same pattern
and gets the same fix.
### Tests
<!-- List UT and IT cases to verify this change -->
UT in `src/paimon/common/logging/logging_test.cpp`:
- `TestLogFormatsArguments`: `%s` and `%d` are expanded, and a `%` inside an
argument is printed
literally.
- `TestLogTruncatesLongMessage`: a 2047-byte message is printed whole, and a
4097-byte message keeps
exactly its first 2047 bytes.
- `TestRegisterCustomLoggerCreator`: now registers the custom creator in a
separate death test
process (`threadsafe` style). A registered creator cannot be unset.
Registered in the shared test
process, it replaced the default logger for every later test in
`common_test`, so under
`--gtest_shuffle` or `--gtest_repeat` the tests above could run against
the test helper instead
of `GlogAdaptor`.
### API and Format
<!-- Does this change affect API in include dir or storage format or
protocol -->
No change in `include/`, storage format or protocol. Messages logged through
the default logger now
show their arguments correctly, and messages longer than 2047 bytes are
truncated.
### Documentation
<!-- Does this change introduce a new feature -->
No new feature, no documentation change.
### Generative AI tooling
<!--
If generative AI tooling has been used in the process of authoring this
patch, please include the
phrase: 'Generated-by: ' followed by the name of the tool and its version.
If no, write 'No'.
Please refer to the [ASF Generative Tooling
Guidance](https://www.apache.org/legal/generative-tooling.html) for details.
-->
Generated-by: Claude Code 2.1.303 (Claude Opus 5.5)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]