高热共公日志库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.2 KiB

  1. package grlogs
  2. import (
  3. _ "golib.gaore.com/GaoreGo/grlogs/logs/alils"
  4. _ "golib.gaore.com/GaoreGo/grlogs/logs/es"
  5. "testing"
  6. "time"
  7. )
  8. func TestGetLogger(t *testing.T) {
  9. // 新建 channel 大小为128 标识为nds 日志通道 , Get 的方法 默认带 console 和 file 输出
  10. l := Get("nds", 128).SetAdapter(LevelAll, AdapterElasticSearch)
  11. l.Debug("我正在调试")
  12. l.Critical("出错了")
  13. // 复用 nds 的日志通道
  14. Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123))
  15. Get("nds").Warning("hadoee %s", time.Now().Format(time.RFC1123))
  16. // 新建 channel 大小为默认 标识为wifi 日志通道 , GetEs 的方法 默认带 console 和 file 和 elatisearch 输出
  17. GetEs("wifi")
  18. for i := 0; i < 10; i++ {
  19. Get("wifi").Warning("Warning")
  20. Get("wifi").Warn("Warn")
  21. Get("wifi").Debug("Debug")
  22. Get("wifi").Error("Error")
  23. Get("wifi").Notice("Notice")
  24. Get("wifi").Info("Info")
  25. Get("wifi").Alert("Alert")
  26. }
  27. Get("wifi").Critical("neoweiwoewe")
  28. }
  29. func TestGetAliLs(t *testing.T) {
  30. l := Get("es").SetAdapter(LevelAll, AdapterAliLs)
  31. l.Info("endport")
  32. l.Info("endport")
  33. l.Info("endport")
  34. l.Info("endport")
  35. time.Sleep(time.Millisecond * 500)
  36. }