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"
|
2020-04-27 21:26:13 +08:00
|
|
|
"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)
|
2020-04-24 17:34:39 +08:00
|
|
|
l.Debug("我正在调试")
|
|
|
|
l.Critical("出错了")
|
2020-04-29 11:28:18 +08:00
|
|
|
|
|
|
|
// 复用 nds 的日志通道
|
|
|
|
Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123))
|
2020-04-27 21:26:13 +08:00
|
|
|
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) {
|
2020-05-05 17:04:08 +08:00
|
|
|
|
|
|
|
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")
|
2020-04-28 17:17:21 +08:00
|
|
|
}
|