AUTH-2596 added new logger package and replaced logrus

This commit is contained in:
Dalton
2020-04-29 15:51:32 -05:00
parent a908453aa4
commit 046be63253
158 changed files with 2027 additions and 5771 deletions

View File

@@ -5,7 +5,7 @@ import (
"bytes"
"context"
log "github.com/sirupsen/logrus"
"github.com/cloudflare/cloudflared/logger"
"zombiezen.com/go/capnproto2/encoding/text"
"zombiezen.com/go/capnproto2/rpc"
rpccapnp "zombiezen.com/go/capnproto2/std/capnp/rpc"
@@ -13,28 +13,28 @@ import (
type transport struct {
rpc.Transport
l *log.Entry
l logger.Service
}
// New creates a new logger that proxies messages to and from t and
// NewTransportLogger creates a new logger that proxies messages to and from t and
// logs them to l. If l is nil, then the log package's default
// logger is used.
func NewTransportLogger(l *log.Entry, t rpc.Transport) rpc.Transport {
func NewTransportLogger(l logger.Service, t rpc.Transport) rpc.Transport {
return &transport{Transport: t, l: l}
}
func (t *transport) SendMessage(ctx context.Context, msg rpccapnp.Message) error {
t.l.Debugf("tx %s", formatMsg(msg))
t.l.Debugf("rpcconnect: tx %s", formatMsg(msg))
return t.Transport.SendMessage(ctx, msg)
}
func (t *transport) RecvMessage(ctx context.Context) (rpccapnp.Message, error) {
msg, err := t.Transport.RecvMessage(ctx)
if err != nil {
t.l.WithError(err).Debug("rx error")
t.l.Debugf("rpcconnect: rx error: %s", err)
return msg, err
}
t.l.Debugf("rx %s", formatMsg(msg))
t.l.Debugf("rpcconnect: rx %s", formatMsg(msg))
return msg, nil
}