grlogs/log_test.go
2020-05-05 17:04:08 +08:00

51 lines
1.2 KiB
Go

package grlogs
import (
_ "golib.gaore.com/GaoreGo/grlogs/logs/alils"
_ "golib.gaore.com/GaoreGo/grlogs/logs/es"
"testing"
"time"
)
func TestGetLogger(t *testing.T) {
// 新建 channel 大小为128 标识为nds 日志通道 , Get 的方法 默认带 console 和 file 输出
l := Get("nds", 128).SetAdapter(LevelAll, AdapterElasticSearch)
l.Debug("我正在调试")
l.Critical("出错了")
// 复用 nds 的日志通道
Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123))
Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123))
// 新建 channel 大小为默认 标识为wifi 日志通道 , GetEs 的方法 默认带 console 和 file 和 elatisearch 输出
GetEs("wifi")
for i := 0; i < 10; i++ {
Get("wifi").Warning("Warning")
Get("wifi").Warn("Warn")
Get("wifi").Debug("Debug")
Get("wifi").Error("Error")
Get("wifi").Notice("Notice")
Get("wifi").Info("Info")
Get("wifi").Alert("Alert")
}
Get("wifi").Critical("neoweiwoewe")
}
func TestGetAliLs(t *testing.T) {
l := Get("test_alils").SetAdapter(LevelAll, AdapterAliLs)
for i := 0; i < 1; i++ {
l.Info("endport")
l.Info("endport")
l.Info("endport")
l.Info("endport")
l.Error("Error")
l.Error("Error\n\n Error")
l.Warn("Warn")
}
Close("test_alils")
}