logger: fix reading env var (#1414)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-03-26 01:00:43 +03:00 committed by GitHub
parent 6efc5556e5
commit beaa434610
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -11,6 +11,15 @@ import (
dlog "github.com/micro/go-micro/v2/debug/log" dlog "github.com/micro/go-micro/v2/debug/log"
) )
func init() {
lvl, err := GetLevel(os.Getenv("MICRO_LOG_LEVEL"))
if err != nil {
lvl = InfoLevel
}
DefaultLogger = NewHelper(NewLogger(WithLevel(lvl)))
}
type defaultLogger struct { type defaultLogger struct {
sync.RWMutex sync.RWMutex
opts Options opts Options

View File

@ -1,6 +1,8 @@
package logger package logger
import "testing" import (
"testing"
)
func TestLogger(t *testing.T) { func TestLogger(t *testing.T) {
l := NewLogger(WithLevel(TraceLevel)) l := NewLogger(WithLevel(TraceLevel))