2
0
mirror of https://gitee.ltd/lxh/logger.git synced 2026-09-03 00:14:29 +08:00

支持初始化的时候从环境变量读取配置信息

This commit is contained in:
李寻欢
2021-12-29 14:33:48 +08:00
parent 3f6003edd7
commit 6253de5599
6 changed files with 31 additions and 12 deletions

View File

@@ -11,12 +11,13 @@ var (
// LogConfig 日志配置
type LogConfig struct {
Mode mode // dev, prod
LokiEnable bool
FileEnable bool
LokiHost string
LokiPort int
LokiName string // Loki的job和source名称
Mode mode `env:"LOG_MODE"` // dev, prod
LokiEnable bool `env:"LOG_LOKI_ENABLE"` // 是否启用Loki
FileEnable bool `env:"LOG_FILE_ENABLE"` // 是否输出到文件
LokiHost string `env:"LOG_LOKI_HOST"` // Loki地址
LokiPort int `env:"LOG_LOKI_PORT"` // Loki端口
LokiSource string `env:"LOG_LOKI_SOURCE_NAME"` // Loki的source名称
LokiJob string `env:"LOG_LOKI_JOB_NAME"` // Loki的job名称
}
func (c LogConfig) getLokiPushURL() string {