Skip to content

Commit 16c4b8a

Browse files
committed
fix(server): global logging
1 parent 0788c5f commit 16c4b8a

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

server/logs/logs.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ func (u LogUTCFormatter) Format(e *log.Entry) ([]byte, error) {
1919
}
2020

2121
func InitLog(cliLogLevel string) *log.Logger {
22-
// global log level
23-
logrus.SetFormatter(LogUTCFormatter{&logrus.JSONFormatter{}})
2422

2523
// log instance for gin server
2624
log := logrus.New()

server/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/authorizerdev/authorizer/server/oauth"
1313
"github.com/authorizerdev/authorizer/server/refs"
1414
"github.com/authorizerdev/authorizer/server/routes"
15+
"github.com/sirupsen/logrus"
1516
)
1617

1718
// VERSION is used to define the version of authorizer from build tags
@@ -25,16 +26,19 @@ func main() {
2526
cli.ARG_REDIS_URL = flag.String("redis_url", "", "Redis connection string")
2627
flag.Parse()
2728

28-
log := logs.InitLog(refs.StringValue(cli.ARG_LOG_LEVEL))
29+
// global log level
30+
logrus.SetFormatter(logs.LogUTCFormatter{&logrus.JSONFormatter{}})
2931

3032
constants.VERSION = VERSION
3133

3234
// initialize required envs (mainly db, env file path and redis)
3335
err := memorystore.InitRequiredEnv()
3436
if err != nil {
35-
log.Fatal("Error while initializing required envs: ", err)
37+
logrus.Fatal("Error while initializing required envs: ", err)
3638
}
3739

40+
log := logs.InitLog(refs.StringValue(cli.ARG_LOG_LEVEL))
41+
3842
// initialize memory store
3943
err = memorystore.InitMemStore()
4044
if err != nil {

0 commit comments

Comments
 (0)