logs-fix-4

This commit is contained in:
Untone 2024-03-02 12:51:26 +03:00
parent f9e1316145
commit d6fec9121c

View File

@ -13,6 +13,7 @@ import (
"github.com/authorizerdev/authorizer/server/oauth" "github.com/authorizerdev/authorizer/server/oauth"
"github.com/authorizerdev/authorizer/server/refs" "github.com/authorizerdev/authorizer/server/refs"
"github.com/authorizerdev/authorizer/server/routes" "github.com/authorizerdev/authorizer/server/routes"
"github.com/sirupsen/logrus"
) )
// VERSION is used to define the version of authorizer from build tags // VERSION is used to define the version of authorizer from build tags
@ -26,24 +27,24 @@ func main() {
cli.ARG_REDIS_URL = flag.String("redis_url", "", "Redis connection string") cli.ARG_REDIS_URL = flag.String("redis_url", "", "Redis connection string")
flag.Parse() flag.Parse()
// global log level
logrus.SetFormatter(&logs.LogTextFormatter{})
constants.VERSION = VERSION constants.VERSION = VERSION
// initialize logrus
log := logs.InitLog(refs.StringValue(cli.ARG_LOG_LEVEL))
// set logrus formatter
log.SetFormatter(&logs.LogTextFormatter{})
// initialize required envs (mainly db, env file path and redis) // initialize required envs (mainly db, env file path and redis)
err := memorystore.InitRequiredEnv() err := memorystore.InitRequiredEnv()
if err != nil { if err != nil {
log.Fatal("Error while initializing required envs: ", err) logrus.Fatal("Error while initializing required envs: ", err)
} }
// initialize required envs (mainly db, env file path and redis) log := logs.InitLog(refs.StringValue(cli.ARG_LOG_LEVEL))
err = memorystore.InitRequiredEnv() log.SetFormatter(&logs.LogTextFormatter{})
// initialize memory store
err = memorystore.InitMemStore()
if err != nil { if err != nil {
log.Fatal("Error while initializing required envs: ", err) log.Fatal("Error while initializing memory store: ", err)
} }
// initialize db provider // initialize db provider