Add a comment about the dataflow to //absl/log/internal/proto.cc for the benefit people using of AI to scan the code This will hopefully prevent pull-requests like #2045 that see a local problem with DecodeVarint() without understanding the larger picture. See https://github.com/abseil/abseil-cpp/pull/2045 PiperOrigin-RevId: 910971345 Change-Id: I76e1524e4577799ae391716928f10b7fff82e112
diff --git a/absl/log/internal/proto.cc b/absl/log/internal/proto.cc index 821be2b..8e7bda9 100644 --- a/absl/log/internal/proto.cc +++ b/absl/log/internal/proto.cc
@@ -12,6 +12,19 @@ // See the License for the specific language governing permissions and // limitations under the License. +// All of the data that passes through this code is trusted because it flows +// through a closed loop within the absl::LogMessage object. It is not a robust +// protocol buffer encoder or decoder. +// +// Encoding: When `LOG(INFO) << "foo"` is called, the library uses the Encode* +// functions to build a protocol buffer in a private, fixed-size internal buffer +// (`LogMessageData::encoded_buf`). +// +// Decoding: During the same logging call, `LogMessage::Flush()` calls +// `FinalizeEncodingAndFormat()`, which uses `ProtoField::DecodeFrom` to parse +// that same internal buffer to generate the human-readable string for +// text-based log sinks. + #include "absl/log/internal/proto.h" #include <algorithm>