[go: nahoru, domu]

Skip to content

Commit

Permalink
pkg: fix validation in if statement in the loglevel file
Browse files Browse the repository at this point in the history
  • Loading branch information
gessecarneiro authored and gustavosbarreto committed Oct 25, 2022
1 parent 73aec0b commit 974022b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
1 change: 1 addition & 0 deletions agent/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ github.com/streadway/amqp v0.0.0-20190827072141-edfb9018d271/go.mod h1:AZpEONHx3
github.com/streadway/handy v0.0.0-20190108123426-d5acb3125c2a/go.mod h1:qNTQ5P5JnDBl6z3cMAg/SywNDC5ABu5ApDIw6lUbRmI=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
Expand Down
9 changes: 4 additions & 5 deletions pkg/loglevel/loglevel.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
package loglevel

import (
"os"

"github.com/shellhub-io/shellhub/pkg/envs"
"github.com/sirupsen/logrus"
)

func SetLogLevel() {
level := logrus.InfoLevel

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

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

0 comments on commit 974022b

Please sign in to comment.