From f35dc15fb2fd939faaad7cc6bf27c47e8f4635bb Mon Sep 17 00:00:00 2001 From: liangzy Date: Tue, 28 Apr 2020 15:49:04 +0800 Subject: [PATCH] =?UTF-8?q?v1.2.1=20=E5=A2=9E=E5=8A=A0es=E7=AE=A1=E9=81=93?= =?UTF-8?q?=E5=86=99=E5=85=A5=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- log.go | 17 +++++++++++++++-- log_test.go | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/log.go b/log.go index 1f12c07..1e490a6 100644 --- a/log.go +++ b/log.go @@ -48,7 +48,7 @@ func New(label string, channelLens ...int64) (l *Logger, loaded bool) { } func Get(label string, channelLens ...int64) (l *Logger) { - var filelevel Level = LevelWarning + var filelevel Level = LevelInfo var loaded bool if os.Getenv(envkey) == "dev" { filelevel = LevelAll @@ -57,6 +57,19 @@ func Get(label string, channelLens ...int64) (l *Logger) { if l, loaded = New(label, channelLens...); !loaded { l.SetAdapter(filelevel, AdapterFile).SetAdapter(LevelAll, AdapterConsole) } - return } + +func GetEs(label string, channelLens ...int64) (l *Logger) { + var filelevel Level = LevelInfo + var loaded bool + if os.Getenv(envkey) == "dev" { + filelevel = LevelAll + } + + if l, loaded = New(label, channelLens...); !loaded { + l.SetAdapter(filelevel, AdapterFile).SetAdapter(LevelAll, AdapterConsole).SetAdapter(filelevel, AdapterElasticSearch) + } + return + +} diff --git a/log_test.go b/log_test.go index 88c0391..b7b28a0 100644 --- a/log_test.go +++ b/log_test.go @@ -12,7 +12,7 @@ func TestGetLogger(t *testing.T) { l.Critical("出错了") Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123)) - Get("wifi").SetAdapter(LevelAll, AdapterElasticSearch) + GetEs("wifi") for i := 0; i < 10; i++ { Get("wifi").Error("neoweiwoewe") }