Remove the logrus logger wrapper

parent aec2edb4
......@@ -348,9 +348,9 @@ func newLogger(level string, format string) (log.Logger, error) {
return nil, fmt.Errorf("log format is not one of the supported values (%s): %s", strings.Join(logFormats, ", "), format)
}
return log.NewLogrusLogger(&logrus.Logger{
return &logrus.Logger{
Out: os.Stderr,
Formatter: &formatter,
Level: logLevel,
}), nil
}, nil
}
......@@ -17,7 +17,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/dexidp/dex/connector"
"github.com/dexidp/dex/pkg/log"
)
const envVar = "DEX_LDAP_TESTS"
......@@ -876,7 +875,7 @@ func runTests(t *testing.T, schema string, connMethod connectionMethod, config *
c.BindDN = "cn=admin,dc=example,dc=org"
c.BindPW = "admin"
l := log.NewLogrusLogger(&logrus.Logger{Out: ioutil.Discard, Formatter: &logrus.TextFormatter{}})
l := &logrus.Logger{Out: ioutil.Discard, Formatter: &logrus.TextFormatter{}}
conn, err := c.openConnector(l)
if err != nil {
......
......@@ -5,7 +5,6 @@ import (
"encoding/base64"
"encoding/pem"
"errors"
"github.com/dexidp/dex/pkg/log"
"io/ioutil"
"sort"
"testing"
......@@ -305,7 +304,7 @@ func (r responseTest) run(t *testing.T) {
t.Fatalf("parse test time: %v", err)
}
conn, err := c.openConnector(log.NewLogrusLogger(logrus.New()))
conn, err := c.openConnector(logrus.New())
if err != nil {
t.Fatal(err)
}
......@@ -339,7 +338,7 @@ func (r responseTest) run(t *testing.T) {
}
func TestConfigCAData(t *testing.T) {
logger := log.NewLogrusLogger(logrus.New())
logger := logrus.New()
validPEM, err := ioutil.ReadFile("testdata/ca.crt")
if err != nil {
t.Fatal(err)
......@@ -476,7 +475,7 @@ func newProvider(ssoIssuer string, redirectURI string) *provider {
usernameAttr: "user",
emailAttr: "email",
redirectURI: redirectURI,
logger: log.NewLogrusLogger(logrus.New()),
logger: logrus.New(),
}
}
......
package log
import "github.com/sirupsen/logrus"
// LogrusLogger is an adapter for Logrus implementing the Logger interface.
type LogrusLogger struct {
logger logrus.FieldLogger
}
// NewLogrusLogger returns a new Logger wrapping Logrus.
func NewLogrusLogger(logger logrus.FieldLogger) *LogrusLogger {
return &LogrusLogger{
logger: logger,
}
}
// Info logs an Info level event.
func (l *LogrusLogger) Info(args ...interface{}) {
l.logger.Info(args...)
}
// Warn logs a Warn level event.
func (l *LogrusLogger) Warn(args ...interface{}) {
l.logger.Warn(args...)
}
// Debugf formats and logs a Debug level event.
func (l *LogrusLogger) Debugf(format string, args ...interface{}) {
l.logger.Debugf(format, args...)
}
// Infof formats and logs an Info level event.
func (l *LogrusLogger) Infof(format string, args ...interface{}) {
l.logger.Infof(format, args...)
}
// Errorf formats and logs n Error level event.
func (l *LogrusLogger) Errorf(format string, args ...interface{}) {
l.logger.Errorf(format, args...)
}
package log
import "testing"
func TestLogrusLoggerImplementsLoggerInterface(t *testing.T) {
var i interface{} = new(LogrusLogger)
if _, ok := i.(Logger); !ok {
t.Errorf("expected %T to implement Logger interface", i)
}
}
......@@ -58,11 +58,11 @@ func newAPI(s storage.Storage, logger log.Logger, t *testing.T) *apiClient {
// Attempts to create, update and delete a test Password
func TestPassword(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
s := memory.New(logger)
client := newAPI(s, logger, t)
......@@ -123,11 +123,11 @@ func TestPassword(t *testing.T) {
// Ensures checkCost returns expected values
func TestCheckCost(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
s := memory.New(logger)
client := newAPI(s, logger, t)
......@@ -180,11 +180,11 @@ func TestCheckCost(t *testing.T) {
// Attempts to list and revoke an exisiting refresh token.
func TestRefreshToken(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
s := memory.New(logger)
client := newAPI(s, logger, t)
......@@ -293,11 +293,11 @@ func TestRefreshToken(t *testing.T) {
}
func TestUpdateClient(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
s := memory.New(logger)
client := newAPI(s, logger, t)
......
......@@ -8,7 +8,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/memory"
)
......@@ -68,11 +67,11 @@ func TestKeyRotater(t *testing.T) {
// Only the last 5 verification keys are expected to be kept around.
maxVerificationKeys := 5
l := log.NewLogrusLogger(&logrus.Logger{
l := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
r := &keyRotater{
Storage: memory.New(l),
......
......@@ -30,7 +30,6 @@ import (
"github.com/dexidp/dex/connector"
"github.com/dexidp/dex/connector/mock"
"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/memory"
)
......@@ -75,11 +74,11 @@ FDWV28nTP9sqbtsmU8Tem2jzMvZ7C/Q0AuDoKELFUpux8shm8wfIhyaPnXUGZoAZ
Np4vUwMSYV5mopESLWOg3loBxKyLGFtgGKVCjGiQvy6zISQ4fQo=
-----END RSA PRIVATE KEY-----`)
var logger = log.NewLogrusLogger(&logrus.Logger{
var logger = &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
func newTestServer(ctx context.Context, t *testing.T, updateConfig func(c *Config)) (*httptest.Server, *Server) {
var server *Server
......
......@@ -3,7 +3,6 @@ package etcd
import (
"context"
"fmt"
"github.com/dexidp/dex/pkg/log"
"os"
"runtime"
"strings"
......@@ -54,11 +53,11 @@ func cleanDB(c *conn) error {
return nil
}
var logger = log.NewLogrusLogger(&logrus.Logger{
var logger = &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
func TestEtcd(t *testing.T) {
testEtcdEnv := "DEX_ETCD_ENDPOINTS"
......
......@@ -7,7 +7,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/conformance"
)
......@@ -25,11 +24,11 @@ func loadClient(t *testing.T) *client {
if config.KubeConfigFile == "" {
t.Skipf("test environment variable %q not set, skipping", testKubeConfigEnv)
}
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
s, err := config.open(logger, true)
if err != nil {
t.Fatal(err)
......
......@@ -6,17 +6,16 @@ import (
"github.com/sirupsen/logrus"
"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/conformance"
)
func TestStorage(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
newStorage := func() storage.Storage {
return New(logger)
......
......@@ -8,16 +8,15 @@ import (
"github.com/sirupsen/logrus"
"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
)
func TestStaticClients(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
backing := New(logger)
c1 := storage.Client{ID: "foo", Secret: "foo_secret"}
......@@ -100,11 +99,11 @@ func TestStaticClients(t *testing.T) {
}
func TestStaticPasswords(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
backing := New(logger)
p1 := storage.Password{Email: "foo@example.com", Username: "foo_secret"}
......@@ -212,11 +211,11 @@ func TestStaticPasswords(t *testing.T) {
}
func TestStaticConnectors(t *testing.T) {
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
backing := New(logger)
config1 := []byte(`{"issuer": "https://accounts.google.com"}`)
......
......@@ -9,7 +9,6 @@ import (
"github.com/sirupsen/logrus"
"github.com/dexidp/dex/pkg/log"
"github.com/dexidp/dex/storage"
"github.com/dexidp/dex/storage/conformance"
)
......@@ -44,11 +43,11 @@ func cleanDB(c *conn) error {
return err
}
var logger = log.NewLogrusLogger(&logrus.Logger{
var logger = &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
func TestSQLite3(t *testing.T) {
newStorage := func() storage.Storage {
......
......@@ -7,8 +7,6 @@ import (
sqlite3 "github.com/mattn/go-sqlite3"
"github.com/sirupsen/logrus"
"github.com/dexidp/dex/pkg/log"
)
func TestMigrate(t *testing.T) {
......@@ -18,11 +16,11 @@ func TestMigrate(t *testing.T) {
}
defer db.Close()
logger := log.NewLogrusLogger(&logrus.Logger{
logger := &logrus.Logger{
Out: os.Stderr,
Formatter: &logrus.TextFormatter{DisableColors: true},
Level: logrus.DebugLevel,
})
}
errCheck := func(err error) bool {
sqlErr, ok := err.(sqlite3.Error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment