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

README.md 709 B

4 years ago
4 years ago
123456789101112131415161718192021222324252627282930
  1. # grlogs
  2. 本库为争游内部日志公共库
  3. ## 代码示例
  4. 1. 引入
  5. ```go
  6. import "golib.gaore.com/GaoreGo/grlogs"
  7. ```
  8. 2. 简单用法
  9. ```go
  10. grlogs.Get("test", 128).Info("hello word")
  11. grlogs.Get("test").Warning("hello word")
  12. ```
  13. lable 为通
  14. 3. 进阶用法
  15. ```go
  16. logger := grlogs.GetEs("wifi")
  17. logger.SetAdapter(LevelAll, AdapterElasticSearch)
  18. logger.SetAdapter(LevelInfo, AdapterFile)
  19. logger.Critical("出错了")
  20. logger.Info("出错了")
  21. ```
  22. 4. 如果需要写入es, 必须设置环境变量 `GRLOG_APP_NAME`, 不能有反斜杠, 如
  23. ```shell script
  24. export GRLOG_APP_NAME=mkt.gaore.com;
  25. ```
  26. 5. 文件日志会写入到 `./runtime/logs/` 文件夹 请务必在项目构建阶段创建该目录