(err error)
| 30 | ) |
| 31 | |
| 32 | func logFieldsForError(err error) *log.F { |
| 33 | fields := log.Fields() |
| 34 | if ttnErr, ok := errors.From(err); ok { |
| 35 | fields = fields.WithField("grpc_code", codes.Code(ttnErr.Code())) |
| 36 | if ns := ttnErr.Namespace(); ns != "" { |
| 37 | fields = fields.WithField("error_namespace", ns) |
| 38 | } |
| 39 | if name := ttnErr.Name(); name != "" { |
| 40 | fields = fields.WithField("error_name", name) |
| 41 | } |
| 42 | if cid := ttnErr.CorrelationID(); cid != "" { |
| 43 | fields = fields.WithField("error_correlation_id", cid) |
| 44 | } |
| 45 | } else if status, ok := status.FromError(err); ok { |
| 46 | fields = fields.WithField("grpc_code", status.Code()) |
| 47 | } |
| 48 | return fields |
| 49 | } |
| 50 | |
| 51 | func logFieldsForCall(ctx context.Context, fullMethodString string) (once, propagated *log.F) { |
| 52 | service := path.Dir(fullMethodString)[1:] |
no test coverage detected