Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLoggerZap ¶
InitLoggerZap 初始化zap日志服务
会加入默认的一个模块空间,当不传参调用GetLogger()时, 就是使用默认的模块空间
当启用elk时,logger使用redis队列作为媒介,需要在logstash侧配置对应的pipeline 队列的key取决于日志文件名和appName的组合,如: 日志文件名=logs/app.log,appName=app 则,队列名称为=> app:logs/app.log
func InitLoggerZapV2 ¶
InitLoggerZapV2 初始化zap日志服务v2
会加入默认的一个模块空间,当不传参调用GetLogger()时, 就是使用默认的模块空间
当启用elk时,logger根据provider配置使用redis队列或nats publish等作为媒介,需要在logstash侧配置对应的pipeline 队列的key取决于日志文件名和appName的组合,如: 日志文件名=logs/app.log,appName=app 则,队列名称为=> app:logs/app.log
func MarshalInterfaceValue ¶
func MarshalInterfaceValue(obj interface{}) string
MarshalInterfaceValue 将interface序列化成字符串
主要用于日志记录
Types ¶
type Conf ¶
type Conf struct { Env string `yaml:"env" toml:"env" json:"env" default:"prod"` //日志环境,prod:生产环境,dev:开发环境 Level string `yaml:"level" toml:"level" json:"level" default:"info"` //日志级别,debug,info,warn,error Filename string `yaml:"filename" toml:"filename" json:"filename" default:"logs/running.log"` //日志文件名称 MaxSize int `yaml:"max_size" toml:"max_size" json:"max_size" default:"100"` //日志大小限制,单位MB MaxBackups int `yaml:"max_backups" toml:"max_backups" json:"max_backups" default:"10"` //最大历史文件保留数量 Compress bool `yaml:"compress" toml:"compress" json:"compress" default:"true"` //是否压缩历史日志文件 EnableELKWithRedisList bool `yaml:"enable_elk_with_redis_list" toml:"enable_elk_with_redis_list" json:"enable_elk_with_redis_list" default:"false"` //是否启用基于redis list的elk日志写入 RedisListKey string `yaml:"redis_list_key" toml:"redis_list_key" json:"redis_list_key"` //redis list的elk日志写入的key }
Conf 日志配置
type ConfV2 ¶
type ConfV2 struct { Env string `yaml:"env" toml:"env" json:"env" default:"prod"` //日志环境,prod:生产环境,dev:开发环境 Level string `yaml:"level" toml:"level" json:"level" default:"info"` //日志级别,debug,info,warn,error Filename string `yaml:"filename" toml:"filename" json:"filename" default:"logs/running.log"` //日志文件名称 MaxSize int `yaml:"max_size" toml:"max_size" json:"max_size" default:"100"` //日志大小限制,单位MB MaxBackups int `yaml:"max_backups" toml:"max_backups" json:"max_backups" default:"10"` //最大历史文件保留数量 Compress bool `yaml:"compress" toml:"compress" json:"compress" default:"true"` //是否压缩历史日志文件 Exporter struct { Provider string `yaml:"provider" toml:"provider" json:"provider" default:""` //导出器,目前支持redis、redis-cluster和nats Redis struct { ConnConf redis.Conf `yaml:"conn_conf" toml:"conn_conf" json:"conn_conf"` //redis连接配置(单机) ConnClusterConf redis.ClusterConf `yaml:"cluster_conn_conf" toml:"cluster_conn_conf" json:"cluster_conn_conf"` //redis连接配置(集群) ListKey string `yaml:"list_key" toml:"list_key" json:"list_key"` //redis list的elk日志写入的key } `json:"redis"` Nats struct { ConnConf nats.Conf `yaml:"conn_conf" toml:"conn_conf" json:"conn_conf"` //nats连接配置 Subject string `yaml:"subject" toml:"subject" json:"subject"` //nats的发布主题 } `yaml:"nats"` } `yaml:"exporter" toml:"exporter" json:"exporter"` //导出器 }
ConfV2 日志配置v2
Click to show internal directories.
Click to hide internal directories.