Logs to Log

This commit is contained in:
Asim Aslam 2019-12-04 23:58:29 +00:00
parent 78647c7027
commit fe46e7a9e9
5 changed files with 48 additions and 48 deletions

View File

@ -47,7 +47,7 @@ func (d *Debug) Stats(ctx context.Context, req *proto.StatsRequest, rsp *proto.S
return nil
}
func (d *Debug) Logs(ctx context.Context, stream server.Stream) error {
func (d *Debug) Log(ctx context.Context, stream server.Stream) error {
req := new(proto.LogRequest)
if err := stream.Recv(req); err != nil {
return err

View File

@ -371,28 +371,28 @@ func init() {
var fileDescriptor_dea322649cde1ef2 = []byte{
// 399 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xc1, 0x6e, 0xd4, 0x30,
0x10, 0xdd, 0x6c, 0x36, 0x69, 0x77, 0xca, 0x2e, 0xc8, 0x2a, 0xc8, 0x8a, 0x38, 0xac, 0x7c, 0x0a,
0x42, 0x78, 0xa1, 0x5c, 0x10, 0x5c, 0x41, 0xe2, 0x50, 0x2e, 0xe6, 0x0b, 0xdc, 0x64, 0x94, 0x06,
0x9a, 0x38, 0xd8, 0x93, 0x4a, 0x7b, 0xe3, 0x57, 0xb8, 0xf3, 0x91, 0x28, 0xb6, 0x97, 0x36, 0x02,
0xa9, 0xb7, 0x79, 0x6f, 0x9e, 0x9e, 0x67, 0xc6, 0x0f, 0x64, 0xd7, 0x56, 0xd6, 0xec, 0x1b, 0xf3,
0x2a, 0x14, 0x35, 0x5e, 0x8d, 0xcd, 0xde, 0xa1, 0xbd, 0x6d, 0x2b, 0xdc, 0x0f, 0xd6, 0x50, 0xe4,
0xa4, 0xaf, 0xc5, 0x0b, 0xd8, 0x7c, 0x46, 0x7d, 0x43, 0xd7, 0x0a, 0x7f, 0x8c, 0xe8, 0x88, 0x71,
0x38, 0x89, 0x6a, 0x9e, 0xec, 0x92, 0x72, 0xad, 0x8e, 0x50, 0x94, 0xb0, 0x3d, 0x4a, 0xdd, 0x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 0xe2, 0x3f, 0x77, 0xe4, 0x76, 0xfa, 0x9f,
0x6c, 0xfd, 0x11, 0x96, 0x93, 0x16, 0x7f, 0x02, 0xec, 0x07, 0xee, 0xd2, 0x72, 0x63, 0xf9, 0xf0,
0x5b, 0x1f, 0xe6, 0xef, 0xb3, 0x8b, 0x5f, 0x90, 0x7f, 0x1a, 0xc3, 0xc4, 0x5f, 0x41, 0x11, 0xb3,
0xc1, 0x57, 0x6a, 0x92, 0xa7, 0xf5, 0x63, 0x35, 0x0d, 0x8d, 0x9c, 0xf1, 0x12, 0xf2, 0xf0, 0xe7,
0x7c, 0xa9, 0xee, 0xc7, 0x64, 0xbd, 0x52, 0x93, 0x28, 0xc8, 0x19, 0x7f, 0x01, 0xec, 0xd2, 0x36,
0xfc, 0x54, 0xdd, 0x7d, 0xc0, 0xfa, 0x38, 0x6d, 0x24, 0x67, 0x6f, 0xb2, 0xab, 0x22, 0xa4, 0xf8,
0xdd, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xea, 0xdf, 0xa5, 0x1d, 0xf7, 0x02, 0x00, 0x00,
}

View File

@ -36,7 +36,7 @@ var _ server.Option
type DebugService interface {
Health(ctx context.Context, in *HealthRequest, opts ...client.CallOption) (*HealthResponse, error)
Stats(ctx context.Context, in *StatsRequest, opts ...client.CallOption) (*StatsResponse, error)
Logs(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogsService, error)
Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error)
}
type debugService struct {
@ -77,8 +77,8 @@ func (c *debugService) Stats(ctx context.Context, in *StatsRequest, opts ...clie
return out, nil
}
func (c *debugService) Logs(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogsService, error) {
req := c.c.NewRequest(c.name, "Debug.Logs", &LogRequest{})
func (c *debugService) Log(ctx context.Context, in *LogRequest, opts ...client.CallOption) (Debug_LogService, error) {
req := c.c.NewRequest(c.name, "Debug.Log", &LogRequest{})
stream, err := c.c.Stream(ctx, req, opts...)
if err != nil {
return nil, err
@ -86,33 +86,33 @@ func (c *debugService) Logs(ctx context.Context, in *LogRequest, opts ...client.
if err := stream.Send(in); err != nil {
return nil, err
}
return &debugServiceLogs{stream}, nil
return &debugServiceLog{stream}, nil
}
type Debug_LogsService interface {
type Debug_LogService interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Recv() (*Record, error)
}
type debugServiceLogs struct {
type debugServiceLog struct {
stream client.Stream
}
func (x *debugServiceLogs) Close() error {
func (x *debugServiceLog) Close() error {
return x.stream.Close()
}
func (x *debugServiceLogs) SendMsg(m interface{}) error {
func (x *debugServiceLog) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *debugServiceLogs) RecvMsg(m interface{}) error {
func (x *debugServiceLog) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *debugServiceLogs) Recv() (*Record, error) {
func (x *debugServiceLog) Recv() (*Record, error) {
m := new(Record)
err := x.stream.Recv(m)
if err != nil {
@ -126,14 +126,14 @@ func (x *debugServiceLogs) Recv() (*Record, error) {
type DebugHandler interface {
Health(context.Context, *HealthRequest, *HealthResponse) error
Stats(context.Context, *StatsRequest, *StatsResponse) error
Logs(context.Context, *LogRequest, Debug_LogsStream) error
Log(context.Context, *LogRequest, Debug_LogStream) error
}
func RegisterDebugHandler(s server.Server, hdlr DebugHandler, opts ...server.HandlerOption) error {
type debug interface {
Health(ctx context.Context, in *HealthRequest, out *HealthResponse) error
Stats(ctx context.Context, in *StatsRequest, out *StatsResponse) error
Logs(ctx context.Context, stream server.Stream) error
Log(ctx context.Context, stream server.Stream) error
}
type Debug struct {
debug
@ -154,37 +154,37 @@ func (h *debugHandler) Stats(ctx context.Context, in *StatsRequest, out *StatsRe
return h.DebugHandler.Stats(ctx, in, out)
}
func (h *debugHandler) Logs(ctx context.Context, stream server.Stream) error {
func (h *debugHandler) Log(ctx context.Context, stream server.Stream) error {
m := new(LogRequest)
if err := stream.Recv(m); err != nil {
return err
}
return h.DebugHandler.Logs(ctx, m, &debugLogsStream{stream})
return h.DebugHandler.Log(ctx, m, &debugLogStream{stream})
}
type Debug_LogsStream interface {
type Debug_LogStream interface {
SendMsg(interface{}) error
RecvMsg(interface{}) error
Close() error
Send(*Record) error
}
type debugLogsStream struct {
type debugLogStream struct {
stream server.Stream
}
func (x *debugLogsStream) Close() error {
func (x *debugLogStream) Close() error {
return x.stream.Close()
}
func (x *debugLogsStream) SendMsg(m interface{}) error {
func (x *debugLogStream) SendMsg(m interface{}) error {
return x.stream.Send(m)
}
func (x *debugLogsStream) RecvMsg(m interface{}) error {
func (x *debugLogStream) RecvMsg(m interface{}) error {
return x.stream.Recv(m)
}
func (x *debugLogsStream) Send(m *Record) error {
func (x *debugLogStream) Send(m *Record) error {
return x.stream.Send(m)
}

View File

@ -3,7 +3,7 @@ syntax = "proto3";
service Debug {
rpc Health(HealthRequest) returns (HealthResponse) {};
rpc Stats(StatsRequest) returns (StatsResponse) {};
rpc Logs(LogRequest) returns (stream Record) {};
rpc Log(LogRequest) returns (stream Record) {};
}
message HealthRequest {

View File

@ -46,7 +46,7 @@ func (d *Debug) Logs(opts ...log.ReadOption) (<-chan log.Record, error) {
req.Stream = options.Stream
// get the log stream
stream, err := d.dbg.Logs(context.Background(), req)
stream, err := d.dbg.Log(context.Background(), req)
if err != nil {
return nil, fmt.Errorf("failed getting log stream: %s", err)
}
@ -59,7 +59,7 @@ func (d *Debug) Logs(opts ...log.ReadOption) (<-chan log.Record, error) {
return logChan, nil
}
func (d *Debug) streamLogs(logChan chan log.Record, stream pb.Debug_LogsService) {
func (d *Debug) streamLogs(logChan chan log.Record, stream pb.Debug_LogService) {
defer stream.Close()
for {