From 56ece724835d594aa66a620d656f36ad3c5ae705 Mon Sep 17 00:00:00 2001 From: Brian Downs Date: Thu, 15 Oct 2020 07:37:17 -0700 Subject: [PATCH] Change debug logging to trace level (#57) * update debug to trace Signed-off-by: Brian Downs --- main.go | 2 +- pkg/drivers/generic/generic.go | 6 +----- pkg/logstructured/logstructured.go | 16 ++++++++-------- pkg/logstructured/sqllog/sql.go | 8 ++++---- pkg/server/watch.go | 10 +++++----- 5 files changed, 19 insertions(+), 23 deletions(-) diff --git a/main.go b/main.go index bff1299e..4e14ec43 100644 --- a/main.go +++ b/main.go @@ -74,7 +74,7 @@ func main() { func run(c *cli.Context) error { if c.Bool("debug") { - logrus.SetLevel(logrus.DebugLevel) + logrus.SetLevel(logrus.TraceLevel) } ctx := signals.SetupSignalHandler(context.Background()) _, err := endpoint.Listen(ctx, config) diff --git a/pkg/drivers/generic/generic.go b/pkg/drivers/generic/generic.go index aadd41a1..bd9bf0cb 100644 --- a/pkg/drivers/generic/generic.go +++ b/pkg/drivers/generic/generic.go @@ -255,11 +255,7 @@ func (d *Generic) execute(ctx context.Context, sql string, args ...interface{}) wait := strategy.Backoff(backoff.Linear(100 + time.Millisecond)) for i := uint(0); i < 20; i++ { - if i > 2 { - logrus.Debugf("EXEC (try: %d) %v : %s", i, args, Stripped(sql)) - } else { - logrus.Tracef("EXEC (try: %d) %v : %s", i, args, Stripped(sql)) - } + logrus.Tracef("EXEC (try: %d) %v : %s", i, args, Stripped(sql)) result, err = d.DB.ExecContext(ctx, sql, args...) if err != nil && d.Retry != nil && d.Retry(err) { wait(i) diff --git a/pkg/logstructured/logstructured.go b/pkg/logstructured/logstructured.go index 11270a4f..211c7f47 100644 --- a/pkg/logstructured/logstructured.go +++ b/pkg/logstructured/logstructured.go @@ -41,7 +41,7 @@ func (l *LogStructured) Start(ctx context.Context) error { func (l *LogStructured) Get(ctx context.Context, key string, revision int64) (revRet int64, kvRet *server.KeyValue, errRet error) { defer func() { l.adjustRevision(ctx, &revRet) - logrus.Debugf("GET %s, rev=%d => rev=%d, kv=%v, err=%v", key, revision, revRet, kvRet != nil, errRet) + logrus.Tracef("GET %s, rev=%d => rev=%d, kv=%v, err=%v", key, revision, revRet, kvRet != nil, errRet) }() rev, event, err := l.get(ctx, key, revision, false) @@ -82,7 +82,7 @@ func (l *LogStructured) adjustRevision(ctx context.Context, rev *int64) { func (l *LogStructured) Create(ctx context.Context, key string, value []byte, lease int64) (revRet int64, errRet error) { defer func() { l.adjustRevision(ctx, &revRet) - logrus.Debugf("CREATE %s, size=%d, lease=%d => rev=%d, err=%v", key, len(value), lease, revRet, errRet) + logrus.Tracef("CREATE %s, size=%d, lease=%d => rev=%d, err=%v", key, len(value), lease, revRet, errRet) }() rev, prevEvent, err := l.get(ctx, key, 0, true) @@ -114,7 +114,7 @@ func (l *LogStructured) Create(ctx context.Context, key string, value []byte, le func (l *LogStructured) Delete(ctx context.Context, key string, revision int64) (revRet int64, kvRet *server.KeyValue, deletedRet bool, errRet error) { defer func() { l.adjustRevision(ctx, &revRet) - logrus.Debugf("DELETE %s, rev=%d => rev=%d, kv=%v, deleted=%v, err=%v", key, revision, revRet, kvRet != nil, deletedRet, errRet) + logrus.Tracef("DELETE %s, rev=%d => rev=%d, kv=%v, deleted=%v, err=%v", key, revision, revRet, kvRet != nil, deletedRet, errRet) }() rev, event, err := l.get(ctx, key, 0, true) @@ -155,7 +155,7 @@ func (l *LogStructured) Delete(ctx context.Context, key string, revision int64) func (l *LogStructured) List(ctx context.Context, prefix, startKey string, limit, revision int64) (revRet int64, kvRet []*server.KeyValue, errRet error) { defer func() { - logrus.Debugf("LIST %s, start=%s, limit=%d, rev=%d => rev=%d, kvs=%d, err=%v", prefix, startKey, limit, revision, revRet, len(kvRet), errRet) + logrus.Tracef("LIST %s, start=%s, limit=%d, rev=%d => rev=%d, kvs=%d, err=%v", prefix, startKey, limit, revision, revRet, len(kvRet), errRet) }() rev, events, err := l.log.List(ctx, prefix, startKey, limit, revision, false) @@ -185,7 +185,7 @@ func (l *LogStructured) List(ctx context.Context, prefix, startKey string, limit func (l *LogStructured) Count(ctx context.Context, prefix string) (revRet int64, count int64, err error) { defer func() { - logrus.Debugf("COUNT %s => rev=%d, count=%d, err=%v", prefix, revRet, count, err) + logrus.Tracef("COUNT %s => rev=%d, count=%d, err=%v", prefix, revRet, count, err) }() rev, count, err := l.log.Count(ctx, prefix) if err != nil { @@ -211,7 +211,7 @@ func (l *LogStructured) Update(ctx context.Context, key string, value []byte, re if kvRet != nil { kvRev = kvRet.ModRevision } - logrus.Debugf("UPDATE %s, value=%d, rev=%d, lease=%v => rev=%d, kvrev=%d, updated=%v, err=%v", key, len(value), revision, lease, revRet, kvRev, updateRet, errRet) + logrus.Tracef("UPDATE %s, value=%d, rev=%d, lease=%v => rev=%d, kvrev=%d, updated=%v, err=%v", key, len(value), revision, lease, revRet, kvRev, updateRet, errRet) }() rev, event, err := l.get(ctx, key, 0, false) @@ -311,7 +311,7 @@ func (l *LogStructured) ttl(ctx context.Context) { } func (l *LogStructured) Watch(ctx context.Context, prefix string, revision int64) <-chan []*server.Event { - logrus.Debugf("WATCH %s, revision=%d", prefix, revision) + logrus.Tracef("WATCH %s, revision=%d", prefix, revision) // starting watching right away so we don't miss anything ctx, cancel := context.WithCancel(ctx) @@ -330,7 +330,7 @@ func (l *LogStructured) Watch(ctx context.Context, prefix string, revision int64 cancel() } - logrus.Debugf("WATCH LIST key=%s rev=%d => rev=%d kvs=%d", prefix, revision, rev, len(kvs)) + logrus.Tracef("WATCH LIST key=%s rev=%d => rev=%d kvs=%d", prefix, revision, rev, len(kvs)) go func() { lastRevision := revision diff --git a/pkg/logstructured/sqllog/sql.go b/pkg/logstructured/sqllog/sql.go index 18235a75..80c5b378 100644 --- a/pkg/logstructured/sqllog/sql.go +++ b/pkg/logstructured/sqllog/sql.go @@ -411,13 +411,13 @@ func (s *SQLLog) poll(result chan interface{}, pollStart int64) { break } else { if err := s.d.Fill(s.ctx, next); err == nil { - logrus.Debugf("FILL, revision=%d, err=%v", next, err) + logrus.Tracef("FILL, revision=%d, err=%v", next, err) select { case s.notify <- next: default: } } else { - logrus.Debugf("FILL FAILED, revision=%d, err=%v", next, err) + logrus.Tracef("FILL FAILED, revision=%d, err=%v", next, err) } break } @@ -431,10 +431,10 @@ func (s *SQLLog) poll(result chan interface{}, pollStart int64) { saveLast = true rev = event.KV.ModRevision if s.d.IsFill(event.KV.Key) { - logrus.Debugf("NOT TRIGGER FILL %s, revision=%d, delete=%v", event.KV.Key, event.KV.ModRevision, event.Delete) + logrus.Tracef("NOT TRIGGER FILL %s, revision=%d, delete=%v", event.KV.Key, event.KV.ModRevision, event.Delete) } else { sequential = append(sequential, event) - logrus.Debugf("TRIGGERED %s, revision=%d, delete=%v", event.KV.Key, event.KV.ModRevision, event.Delete) + logrus.Tracef("TRIGGERED %s, revision=%d, delete=%v", event.KV.Key, event.KV.ModRevision, event.Delete) } } diff --git a/pkg/server/watch.go b/pkg/server/watch.go index b8b70de9..ff800763 100644 --- a/pkg/server/watch.go +++ b/pkg/server/watch.go @@ -31,7 +31,7 @@ func (s *KVServerBridge) Watch(ws etcdserverpb.Watch_WatchServer) error { if msg.GetCreateRequest() != nil { w.Start(ws.Context(), msg.GetCreateRequest()) } else if msg.GetCancelRequest() != nil { - logrus.Debugf("WATCH CANCEL REQ id=%d", msg.GetCancelRequest().GetWatchId()) + logrus.Tracef("WATCH CANCEL REQ id=%d", msg.GetCancelRequest().GetWatchId()) w.Cancel(msg.GetCancelRequest().WatchId, nil) } } @@ -58,7 +58,7 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest) key := string(r.Key) - logrus.Debugf("WATCH START id=%d, count=%d, key=%s, revision=%d", id, len(w.watches), key, r.StartRevision) + logrus.Tracef("WATCH START id=%d, count=%d, key=%s, revision=%d", id, len(w.watches), key, r.StartRevision) go func() { defer w.wg.Done() @@ -78,7 +78,7 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest) if logrus.IsLevelEnabled(logrus.DebugLevel) { for _, event := range events { - logrus.Debugf("WATCH READ id=%d, key=%s, revision=%d", id, event.KV.Key, event.KV.ModRevision) + logrus.Tracef("WATCH READ id=%d, key=%s, revision=%d", id, event.KV.Key, event.KV.ModRevision) } } @@ -92,7 +92,7 @@ func (w *watcher) Start(ctx context.Context, r *etcdserverpb.WatchCreateRequest) } } w.Cancel(id, nil) - logrus.Debugf("WATCH CLOSE id=%d, key=%s", id, key) + logrus.Tracef("WATCH CLOSE id=%d, key=%s", id, key) }() } @@ -130,7 +130,7 @@ func (w *watcher) Cancel(watchID int64, err error) { if err != nil { reason = err.Error() } - logrus.Debugf("WATCH CANCEL id=%d reason=%s", watchID, reason) + logrus.Tracef("WATCH CANCEL id=%d reason=%s", watchID, reason) serr := w.server.Send(&etcdserverpb.WatchResponse{ Header: &etcdserverpb.ResponseHeader{}, Canceled: true,