I just want to parse an instance from a string when logging something, and don't care the result.

But when I update protobuf to 3.5.0, the annoying message is always printing to the terminal (stderr):

“Can't parse message of type because it is missing required fields”

Its fields must be required.

How can I stop printing the error message?

2

There are 2 best solutions below

0
On

As far as I know, the protobuf library itself doesn't directly print to stderr. Instead, error messages are returned through the API like message->InitializationErrorString().

So it seems it is your own code that is printing this message to stderr, or perhaps you have enabled some debug mode.

You can try to add a debugger hook to the print to see where it is coming from.

0
On

Options:

  • make it optional instead of required
  • provide the missing data
  • hook stderr and send it to nul