接入阿里sls
This commit is contained in:
parent
c014aca84b
commit
b3a1b78006
13
log.go
13
log.go
@ -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 {
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user