Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
06521ffa
Unverified
Commit
06521ffa
authored
Feb 22, 2019
by
Mark Sagi-Kazar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove the logrus logger wrapper
parent
aec2edb4
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
34 additions
and
95 deletions
+34
-95
serve.go
cmd/dex/serve.go
+2
-2
ldap_test.go
connector/ldap/ldap_test.go
+1
-2
saml_test.go
connector/saml/saml_test.go
+3
-4
logrus.go
pkg/log/logrus.go
+0
-40
logrus_test.go
pkg/log/logrus_test.go
+0
-10
api_test.go
server/api_test.go
+8
-8
rotation_test.go
server/rotation_test.go
+2
-3
server_test.go
server/server_test.go
+2
-3
etcd_test.go
storage/etcd/etcd_test.go
+2
-3
storage_test.go
storage/kubernetes/storage_test.go
+2
-3
memory_test.go
storage/memory/memory_test.go
+2
-3
static_test.go
storage/memory/static_test.go
+6
-7
config_test.go
storage/sql/config_test.go
+2
-3
migrate_test.go
storage/sql/migrate_test.go
+2
-4
No files found.
cmd/dex/serve.go
View file @
06521ffa
...
...
@@ -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
}
connector/ldap/ldap_test.go
View file @
06521ffa
...
...
@@ -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
{
...
...
connector/saml/saml_test.go
View file @
06521ffa
...
...
@@ -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
(
log
rus
.
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
:=
log
rus
.
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
:
log
rus
.
New
(
),
}
}
...
...
pkg/log/logrus.go
deleted
100644 → 0
View file @
aec2edb4
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
...
)
}
pkg/log/logrus_test.go
deleted
100644 → 0
View file @
aec2edb4
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
)
}
}
server/api_test.go
View file @
06521ffa
...
...
@@ -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
)
...
...
server/rotation_test.go
View file @
06521ffa
...
...
@@ -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
),
...
...
server/server_test.go
View file @
06521ffa
...
...
@@ -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
...
...
storage/etcd/etcd_test.go
View file @
06521ffa
...
...
@@ -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"
...
...
storage/kubernetes/storage_test.go
View file @
06521ffa
...
...
@@ -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
)
...
...
storage/memory/memory_test.go
View file @
06521ffa
...
...
@@ -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
)
...
...
storage/memory/static_test.go
View file @
06521ffa
...
...
@@ -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"}`
)
...
...
storage/sql/config_test.go
View file @
06521ffa
...
...
@@ -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
{
...
...
storage/sql/migrate_test.go
View file @
06521ffa
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment