()
| 336 | } |
| 337 | |
| 338 | func (c *ServerTrailer) toProto() *binlogpb.GrpcLogEntry { |
| 339 | st, ok := status.FromError(c.Err) |
| 340 | if !ok { |
| 341 | grpclogLogger.Info("binarylogging: error in trailer is not a status error") |
| 342 | } |
| 343 | var ( |
| 344 | detailsBytes []byte |
| 345 | err error |
| 346 | ) |
| 347 | stProto := st.Proto() |
| 348 | if stProto != nil && len(stProto.Details) != 0 { |
| 349 | detailsBytes, err = proto.Marshal(stProto) |
| 350 | if err != nil { |
| 351 | grpclogLogger.Infof("binarylogging: failed to marshal status proto: %v", err) |
| 352 | } |
| 353 | } |
| 354 | ret := &binlogpb.GrpcLogEntry{ |
| 355 | Type: binlogpb.GrpcLogEntry_EVENT_TYPE_SERVER_TRAILER, |
| 356 | Payload: &binlogpb.GrpcLogEntry_Trailer{ |
| 357 | Trailer: &binlogpb.Trailer{ |
| 358 | Metadata: mdToMetadataProto(c.Trailer), |
| 359 | StatusCode: uint32(st.Code()), |
| 360 | StatusMessage: st.Message(), |
| 361 | StatusDetails: detailsBytes, |
| 362 | }, |
| 363 | }, |
| 364 | } |
| 365 | if c.OnClientSide { |
| 366 | ret.Logger = binlogpb.GrpcLogEntry_LOGGER_CLIENT |
| 367 | } else { |
| 368 | ret.Logger = binlogpb.GrpcLogEntry_LOGGER_SERVER |
| 369 | } |
| 370 | if c.PeerAddr != nil { |
| 371 | ret.Peer = addrToProto(c.PeerAddr) |
| 372 | } |
| 373 | return ret |
| 374 | } |
| 375 | |
| 376 | // Cancel configs the binary log entry to be a Cancel entry. |
| 377 | type Cancel struct { |
nothing calls this directly
no test coverage detected