基于Zap整合的日志框架,可自由组合输出到Console、File、Loki
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.
李寻欢 40a3dc9339 🎨 优化gorm日志 1 week ago
log 🎨 优化日志用法 1 week ago
.gitignore 🎨 优化日志用法 1 week ago
config.go 🎨 配置优化 1 week ago
console.go 🎉 创建项目 5 months ago
file.go 🎉 创建项目 5 months ago
go.mod ⬆️ 更新依赖版本到最新版 1 week ago
go.sum ⬆️ 更新依赖版本到最新版 1 week ago
gorm.go 🎨 优化gorm日志 1 week ago
gorm_test.go 🎨 优化gorm日志 1 week ago
logger.go 🐛 Fix a bug. 1 week ago
logger_test.go 🐛 Fix a bug. 1 week ago
loki.go 🐛 修复多余的控制台打印 5 months ago
readme.md 📝 完善readme 1 week ago

readme.md

Logger

基于Zap整合的日志框架,可自由组合输出到Console、File、Loki

Demo

package main

import (
	"gitee.ltd/lxh/logger"
	"gitee.ltd/lxh/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 名称