You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
loser cecfed7212 | 2 years ago | |
---|---|---|
log | 2 years ago | |
.gitignore | 2 years ago | |
LICENSE | 2 years ago | |
caller.go | 2 years ago | |
config.go | 2 years ago | |
console.go | 2 years ago | |
file.go | 2 years ago | |
go.mod | 2 years ago | |
gorm.go | 2 years ago | |
logger.go | 2 years ago | |
loki.go | 2 years ago | |
readme.md | 2 years ago |
readme.md
Logger
基于Zap整合的日志框架,可自由组合输出到Console、File、Loki
Demo
package main
import (
"git.echol.cn/loser/logger"
"git.echol.cn/loser/logger/log"
)
func main() {
logger.InitLogger(logger.LogConfig{Mode: logger.Dev, LokiEnable: false, FileEnable: true})
log.Debug("芜湖")
}
环境变量
export LOG_MODE=0 # development | production
export LOG_LOKI_ENABLE=1 # 是否启用Loki 0: disable, 1: enable
export LOG_FILE_ENABLE=0 # 是否启用输出到文件 0: disable, 1: enable
export LOG_LOKI_HOST=10.0.0.31 # Loki地址
export LOG_LOKI_PORT=3100 # Loki端口
export LOG_LOKI_SOURCE_NAME=tests # Loki Source 名称
export LOG_LOKI_JOB_NAME=testj # Loki Job 名称