基于zap封装的日志库
Go to file
2022-09-07 18:04:24 +08:00
log 🎨 修改部分依赖 2022-09-07 18:04:24 +08:00
.gitignore init project 2022-05-25 01:56:38 +08:00
caller.go 🎨 修改部分依赖 2022-09-07 18:04:24 +08:00
config.go init project 2022-05-25 01:56:38 +08:00
console.go init project 2022-05-25 01:56:38 +08:00
file.go init project 2022-05-25 01:56:38 +08:00
go.mod 🎨 修改部分依赖 2022-09-07 18:04:24 +08:00
gorm.go init project 2022-05-25 01:56:38 +08:00
LICENSE Initial commit 2022-05-25 01:45:17 +08:00
logger.go init project 2022-05-25 01:56:38 +08:00
loki.go 🎨 修改部分依赖 2022-09-07 18:04:24 +08:00
readme.md 更新 'readme.md' 2022-05-25 01:58:15 +08:00

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 名称