mirror of
https://github.com/lightninglabs/pool.git
synced 2026-08-13 12:33:04 +02:00
26 lines
541 B
Go
26 lines
541 B
Go
package poolrpc
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/lightninglabs/protobuf-hex-display/jsonpb"
|
|
"github.com/lightninglabs/protobuf-hex-display/proto"
|
|
)
|
|
|
|
var (
|
|
jsonMarshaler = &jsonpb.Marshaler{
|
|
EmitDefaults: true,
|
|
OrigName: true,
|
|
}
|
|
)
|
|
|
|
// PrintMsg prints a protobuf message as JSON, suitable for logging (without any
|
|
// indentation).
|
|
func PrintMsg(message proto.Message) string {
|
|
jsonStr, err := jsonMarshaler.MarshalToString(message)
|
|
if err != nil {
|
|
return fmt.Sprintf("<unable to decode proto msg: %v>", err)
|
|
}
|
|
|
|
return jsonStr
|
|
}
|