haiwai-grlogs/README.md
2020-04-28 17:38:45 +08:00

31 lines
818 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# grlogs
本库为争游内部日志公共库
## 代码示例
1. 引入
```go
import "golib.gaore.com/GaoreGo/grlogs"
```
2. 简单用法
```go
grlogs.Get("test", 128).Info("hello word")
grlogs.Get("test").Warning("hello word")
```
`Get` 方法中 `lable` 参数为标签为识别分类所用在Grlogs里一个分类使用一个管道进行日志
3. 进阶用法
```go
logger := grlogs.GetEs("wifi")
logger.SetAdapter(LevelAll, AdapterElasticSearch)
logger.SetAdapter(LevelInfo, AdapterFile)
logger.Critical("出错了")
logger.Info("出错了")
```
4. 如果需要写入es 必须设置环境变量 `GRLOG_APP_NAME`, 不能有反斜杠, 如
```shell script
export GRLOG_APP_NAME=mkt.gaore.com;
```
5. 文件日志会写入到 `./runtime/logs/` 文件夹 请务必在项目构建阶段创建该目录