Documentation
¶
Index ¶
- func Debug(ctx context.Context, msg string, kv ...interface{})
- func Error(ctx context.Context, msg string, kv ...interface{})
- func Fatal(ctx context.Context, msg string, kv ...interface{})
- func Info(ctx context.Context, msg string, kv ...interface{})
- func InitDevLogger(projectName string)
- func InitPrdLogger(projectName string, config ...*PrdLoggerConfig)
- func Warn(ctx context.Context, msg string, kv ...interface{})
- type LogBasicInfo
- type PrdLoggerConfig
- type Pure
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitDevLogger ¶ added in v0.0.2
func InitDevLogger(projectName string)
InitDevLogger 初始化开发环境日志配置 入参:projectName 项目名称,如 user_srv 特点: 1. 输出带颜色的日志级别 2. 使用人性化的时间格式 3. 输出调用位置信息 4. 开发环境默认记录 Debug 及以上级别的日志
func InitPrdLogger ¶ added in v0.0.2
func InitPrdLogger(projectName string, config ...*PrdLoggerConfig)
InitPrdLogger 初始化生产环境日志配置 入参:projectName 项目名称,如 user_srv 特点: 1. 使用 JSON 格式输出,便于日志收集和解析 2. 日志文件自动轮转,避免单个文件过大 3. 错误日志单独收集 4. Info 及以上级别会记录到 app.log 5. Error 及以上级别会记录到 error.log 6. 同时在控制台输出 Info 及以上级别的日志
Types ¶
type LogBasicInfo ¶
type PrdLoggerConfig ¶ added in v0.0.7
type Pure ¶ added in v0.0.3
type Pure struct{}
用于打印不含上下文信息的,纯日志 因为统一跳过1层调用堆栈信息,所以也必须都包装一层
Click to show internal directories.
Click to hide internal directories.