如何更改protobuf日志记录行为(分隔符)
How can I change protobuf logging behavior (separator)?
我在protobuf消息上使用ShortDebugString()来获取字符串并将其记录到文件中。这个函数返回以':'作为分隔符的简洁版本。从protobuf代码中,它看起来像是发生在TextFormat::Printer::PrintField中。
generator.Print(": ");
// Write the field value.
PrintFieldValue(message, reflection, field, field_index, generator);
我想改变':'到'='从ShortDebugString返回的字符串。如何在不更改protobuf库代码本身的情况下实现这一点?我可以替换':'与'='后,我得到字符串从ShortDebugString返回,但我希望避免这种情况,以及。谢谢。
最好的办法是复制整个TextFormat
类并对其进行修改。TextFormat
代码不使用任何私有的protobuf api,因此将其移出核心库应该没有问题。事实上,TextFormat
的设计部分是为了作为一个例子,说明你如何为其他文本格式编写自己的编码器,这听起来正是你想要的。:)
相关文章:
- 将两个数组中的差异记录在第三个数组中
- 当用户键入分隔符时,停止getline()输入
- 为什么在逗号分隔符上下文中将预增量的结果强制转换为void
- 如何在 c++ 中使用 ',' 作为 getline 分隔符
- 带有多个字符分隔符的正则表达式
- 使用 char 分隔符解析C++中的字符串,但将可重复的字符保留为每个解析的子字符串 (C++ STL) 中的分隔符
- 字符串开头的分隔符
- 禁止在控制台上记录谷神星
- 创建 Spdlog 异步文件记录器时遇到困难
- fastrtps:如何在发布/订阅级别使用 DDS 历史记录?
- 尝试将 c 字符串数组与分隔符连接起来
- 如何将自定义记录器与websocketpp一起使用?
- 正则表达式以匹配数字的重复模式,后跟任何类型的分隔符?
- C++结构到德尔福记录dll调用
- 根据新的行分隔符从字符串中删除子字符串
- 如何判断SSL_read是否已经接收并处理了来自单个消息的所有记录
- 同一分隔符之间的多个子字符串
- 通过分隔符分隔包含 UTF-16 BE 文本的uint8_t数组
- 检测 CSV 文件中的记录/行分隔符
- 如何更改protobuf日志记录行为(分隔符)