From b01357058a8e232c9d36a9e95746963054da3790 Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Wed, 27 Nov 2019 18:38:26 +0000 Subject: [PATCH] Regenerate proto cruft --- debug/handler/debug.go | 31 ++++++++++++++++++++++- debug/proto/debug.pb.go | 56 ++++++++++++++++++++--------------------- debug/proto/debug.proto | 4 +-- 3 files changed, 60 insertions(+), 31 deletions(-) diff --git a/debug/handler/debug.go b/debug/handler/debug.go index 8b8eedfd..e532de79 100644 --- a/debug/handler/debug.go +++ b/debug/handler/debug.go @@ -43,6 +43,35 @@ func (d *Debug) Stats(ctx context.Context, req *proto.StatsRequest, rsp *proto.S return nil } -func (d *Debug) Logs(ctx context.Context, req *proto.LogRequest, rsp proto.Debug_LogsStream) error { +func (d *Debug) Logs(ctx context.Context, req *proto.LogRequest, stream proto.Debug_LogsStream) error { + var records []log.Record + since := time.Unix(0, req.Since) + if !since.IsZero() { + records = d.Log.Read(log.Since(since)) + } else { + records = d.Log.Read(log.Count(int(req.Count))) + } + + defer stream.Close() + + // TODO: figure out the stream later on + // stream the logs + for _, record := range records { + metadata := make(map[string]string) + for k, v := range record.Metadata { + metadata[k] = v + } + + recLog := &proto.Log{ + Timestamp: record.Timestamp.UnixNano(), + Value: record.Value.(string), + Metadata: metadata, + } + + if err := stream.Send(recLog); err != nil { + return err + } + } + return nil } diff --git a/debug/proto/debug.pb.go b/debug/proto/debug.pb.go index b8236261..423e98cc 100644 --- a/debug/proto/debug.pb.go +++ b/debug/proto/debug.pb.go @@ -201,11 +201,11 @@ func (m *StatsResponse) GetGc() uint64 { // LogRequest queries service for logs type LogRequest struct { // count is the count of events - Count uint64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` + Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` // relative time in seconds // before the current time // from which to show logs - Since uint64 `protobuf:"varint,2,opt,name=since,proto3" json:"since,omitempty"` + Since int64 `protobuf:"varint,2,opt,name=since,proto3" json:"since,omitempty"` // stream logs continuously Stream bool `protobuf:"varint,3,opt,name=stream,proto3" json:"stream,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` @@ -238,14 +238,14 @@ func (m *LogRequest) XXX_DiscardUnknown() { var xxx_messageInfo_LogRequest proto.InternalMessageInfo -func (m *LogRequest) GetCount() uint64 { +func (m *LogRequest) GetCount() int64 { if m != nil { return m.Count } return 0 } -func (m *LogRequest) GetSince() uint64 { +func (m *LogRequest) GetSince() int64 { if m != nil { return m.Since } @@ -331,28 +331,28 @@ func init() { func init() { proto.RegisterFile("debug.proto", fileDescriptor_8d9d361be58531fb) } var fileDescriptor_8d9d361be58531fb = []byte{ - // 359 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0xcd, 0x6a, 0xe3, 0x30, - 0x14, 0x85, 0xe3, 0xbf, 0x4c, 0x72, 0x33, 0x76, 0x06, 0x31, 0x0c, 0xc6, 0xcc, 0x40, 0xd0, 0xca, - 0x30, 0x20, 0x86, 0xcc, 0xa6, 0xb4, 0xdb, 0x16, 0xba, 0x70, 0xa1, 0xb8, 0x4f, 0xa0, 0xd8, 0xc2, - 0x09, 0x8d, 0x2d, 0xd7, 0xba, 0x2e, 0x64, 0xd1, 0x55, 0xdf, 0xa5, 0xcf, 0x59, 0x64, 0xc9, 0x4d, - 0x0d, 0xdd, 0xf9, 0x3b, 0xf2, 0x3d, 0x47, 0xbe, 0xc7, 0xb0, 0x2a, 0xc5, 0xae, 0xaf, 0x58, 0xdb, - 0x49, 0x94, 0x74, 0x0d, 0xe1, 0xad, 0xe0, 0x47, 0xdc, 0xe7, 0xe2, 0xa9, 0x17, 0x0a, 0x69, 0x0a, - 0xd1, 0x28, 0xa8, 0x56, 0x36, 0x4a, 0x90, 0x5f, 0x30, 0x57, 0xc8, 0xb1, 0x57, 0xb1, 0xb3, 0x71, - 0xd2, 0x65, 0x6e, 0x89, 0x46, 0x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b1, 0x49, 0xbb, 0xc9, - 0x9a, 0x4d, 0xcb, 0xa5, 0x33, 0x92, 0x42, 0x30, 0xb4, 0x46, 0x42, 0xf6, 0xb9, 0xce, 0x24, 0x62, - 0x93, 0x32, 0xe9, 0x8c, 0xfc, 0x01, 0x3f, 0x93, 0x95, 0x22, 0x2b, 0x76, 0xde, 0x70, 0xe2, 0x6b, - 0xa0, 0xb3, 0x7f, 0xce, 0x6e, 0x3e, 0xfc, 0x51, 0xff, 0xdf, 0x03, 0x00, 0x00, 0xff, 0xff, 0xbe, - 0xa2, 0x1f, 0x47, 0x60, 0x02, 0x00, 0x00, + // 360 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x92, 0x5f, 0x6b, 0xdb, 0x30, + 0x14, 0xc5, 0xe3, 0x7f, 0x59, 0x72, 0x33, 0x3b, 0x43, 0x8c, 0x61, 0xcc, 0x06, 0x41, 0x4f, 0x86, + 0x81, 0x18, 0xd9, 0xcb, 0xd8, 0x5e, 0x57, 0xe8, 0x83, 0x0b, 0x45, 0xfd, 0x04, 0x8a, 0x2d, 0x9c, + 0xd0, 0xd8, 0x72, 0xad, 0xeb, 0x42, 0x1e, 0xfa, 0xd4, 0xef, 0xd2, 0xcf, 0x59, 0x64, 0x29, 0x4d, + 0x0d, 0x7d, 0xf3, 0xef, 0xc8, 0xf7, 0x1c, 0xf9, 0x1e, 0xc3, 0xaa, 0x92, 0xbb, 0xa1, 0x66, 0x5d, + 0xaf, 0x50, 0xd1, 0x35, 0xc4, 0xd7, 0x52, 0x1c, 0x71, 0xcf, 0xe5, 0xc3, 0x20, 0x35, 0xd2, 0x1c, + 0x92, 0xb3, 0xa0, 0x3b, 0xd5, 0x6a, 0x49, 0xbe, 0xc1, 0x5c, 0xa3, 0xc0, 0x41, 0xa7, 0xde, 0xc6, + 0xcb, 0x97, 0xdc, 0x11, 0x4d, 0xe0, 0xf3, 0x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 0x3b, 0x24, 0x09, 0x9b, 0xb4, + 0x9b, 0xad, 0xd9, 0xb4, 0x5c, 0x3a, 0x23, 0x39, 0x44, 0x63, 0x6b, 0x24, 0x66, 0xef, 0xeb, 0xcc, + 0x12, 0x36, 0x29, 0x93, 0xce, 0xc8, 0x0f, 0x08, 0x0b, 0x55, 0x6b, 0xb2, 0x62, 0x97, 0x0d, 0x67, + 0xa1, 0x01, 0x3a, 0xfb, 0xe5, 0xed, 0xe6, 0xe3, 0x1f, 0xf5, 0xfb, 0x35, 0x00, 0x00, 0xff, 0xff, + 0x95, 0x24, 0xad, 0xbc, 0x60, 0x02, 0x00, 0x00, } diff --git a/debug/proto/debug.proto b/debug/proto/debug.proto index 25030153..830423b3 100644 --- a/debug/proto/debug.proto +++ b/debug/proto/debug.proto @@ -31,11 +31,11 @@ message StatsResponse { // LogRequest queries service for logs message LogRequest { // count is the count of events - uint64 count = 1; + int64 count = 1; // relative time in seconds // before the current time // from which to show logs - uint64 since = 2; + int64 since = 2; // stream logs continuously bool stream = 3; }