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") }