接入阿里sls

This commit is contained in:
liangzy 2020-05-06 10:19:07 +08:00
parent c014aca84b
commit b3a1b78006
2 changed files with 14 additions and 1 deletions

13
log.go
View File

@ -73,6 +73,19 @@ func GetEs(label string, channelLens ...int64) (l *Logger) {
return
}
func GetAli(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(LevelAll, AdapterConsole).SetAdapter(filelevel, AdapterAliLs)
}
return
}
func Close(lable string) {
if v, ok := loggers.Load(lable); ok {
if tmp, ok := v.(*Logger); ok {

View File

@ -34,7 +34,7 @@ func TestGetLogger(t *testing.T) {
func TestGetAliLs(t *testing.T) {
l := Get("test_alils").SetAdapter(LevelAll, AdapterAliLs)
l := GetAli("test_alils")
for i := 0; i < 1; i++ {
l.Info("endport")