grlogs/log_test.go

46 lines
1.2 KiB
Go
Raw Normal View History

2020-04-01 11:38:28 +08:00
package grlogs
import (
2020-05-04 21:10:20 +08:00
_ "golib.gaore.com/GaoreGo/grlogs/logs/alils"
2020-04-28 14:32:56 +08:00
_ "golib.gaore.com/GaoreGo/grlogs/logs/es"
2020-04-01 11:38:28 +08:00
"testing"
"time"
2020-04-01 11:38:28 +08:00
)
func TestGetLogger(t *testing.T) {
2020-04-29 11:28:18 +08:00
// 新建 channel 大小为128 标识为nds 日志通道 , Get 的方法 默认带 console 和 file 输出
2020-04-28 14:32:56 +08:00
l := Get("nds", 128).SetAdapter(LevelAll, AdapterElasticSearch)
l.Debug("我正在调试")
l.Critical("出错了")
2020-04-29 11:28:18 +08:00
// 复用 nds 的日志通道
Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123))
Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123))
2020-04-28 15:27:39 +08:00
2020-04-29 11:28:18 +08:00
// 新建 channel 大小为默认 标识为wifi 日志通道 , GetEs 的方法 默认带 console 和 file 和 elatisearch 输出
2020-04-28 15:49:04 +08:00
GetEs("wifi")
2020-04-28 15:27:39 +08:00
for i := 0; i < 10; i++ {
2020-04-29 11:28:18 +08:00
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")
2020-04-28 15:27:39 +08:00
}
2020-04-29 11:28:18 +08:00
Get("wifi").Critical("neoweiwoewe")
2020-04-01 11:38:28 +08:00
}
2020-04-28 17:17:21 +08:00
2020-05-04 21:10:20 +08:00
func TestGetAliLs(t *testing.T) {
l := Get("es").SetAdapter(LevelAll, AdapterAliLs)
l.Info("endport")
l.Info("endport")
l.Info("endport")
l.Info("endport")
2020-05-05 16:10:42 +08:00
l.Error("Error")
l.Error("Error")
l.Warn("Warn")
2020-05-04 21:10:20 +08:00
time.Sleep(time.Millisecond * 500)
2020-04-28 17:17:21 +08:00
}