高热共公日志库
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.

52 lines
1.3 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. lable := "test_alils"
  31. l := GetAli(lable).Async(128)
  32. for i := 0; i < 2; i++ {
  33. l.Info("Info")
  34. l.Debug("Debug")
  35. l.Warn("Warn")
  36. l.Warning("Warning")
  37. l.Error("Error")
  38. l.Error("Error\n\n 测试换行")
  39. l.Warn("Warn")
  40. }
  41. Close(lable, lable, lable)
  42. }