[go: nahoru, domu]

Skip to content

Commit

Permalink
pkg: create loglevel package
Browse files Browse the repository at this point in the history
  • Loading branch information
gessecarneiro authored and otavio committed Sep 19, 2022
1 parent f20e991 commit 067fc04
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pkg/loglevel/loglevel.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package loglevel

import (
"os"

"github.com/sirupsen/logrus"
)

func SetLogLevel() {
level := logrus.InfoLevel

if env, ok := os.LookupEnv("SHELLHUB_ENV"); ok && env == "development" {
level = logrus.TraceLevel
}

if env, ok := os.LookupEnv("SHELLHUB_LOG_LEVEL"); ok {
if v, err := logrus.ParseLevel(env); err != nil {
level = v
}
}

logrus.WithField("log_level", level.String()).Info("Setting log level")
logrus.SetLevel(level)
}

0 comments on commit 067fc04

Please sign in to comment.