Documentation
¶
Index ¶
- func Ctx(ctx context.Context) *zerolog.Logger
- func Debug() *zerolog.Event
- func Err(err error) *zerolog.Event
- func Error() *zerolog.Event
- func Fatal() *zerolog.Event
- func Hook(h zerolog.Hook) zerolog.Logger
- func Info() *zerolog.Event
- func Level(level zerolog.Level) zerolog.Logger
- func Log() *zerolog.Event
- func NewCustomFileLogger(opts ...CustomLoggerOption) (*zerolog.Logger, error)
- func Output(w io.Writer) zerolog.Logger
- func Panic() *zerolog.Event
- func Print(v ...interface{})
- func Printf(format string, v ...interface{})
- func Sample(s zerolog.Sampler) zerolog.Logger
- func Trace() *zerolog.Event
- func Warn() *zerolog.Event
- func With() zerolog.Context
- func WithLevel(level zerolog.Level) *zerolog.Event
- type CustomLogger
- type CustomLoggerOption
- type CustomLoggerOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ctx ¶
Ctx returns the Logger associated with the ctx. If no logger is associated, a disabled logger is returned.
func Debug ¶
Debug starts a new message with debug level.
You must call Msg on the returned event in order to send the event.
func Err ¶
Err starts a new message with error level with err as a field if not nil or with info level if err is nil.
You must call Msg on the returned event in order to send the event.
func Error ¶
Error starts a new message with error level.
You must call Msg on the returned event in order to send the event.
func Fatal ¶
Fatal starts a new message with fatal level. The os.Exit(1) function is called by the Msg method.
You must call Msg on the returned event in order to send the event.
func Info ¶
Info starts a new message with info level.
You must call Msg on the returned event in order to send the event.
func Log ¶
Log starts a new message with no level. Setting zerolog.GlobalLevel to zerolog.Disabled will still disable events produced by this method.
You must call Msg on the returned event in order to send the event.
func NewCustomFileLogger ¶ added in v1.0.4
func NewCustomFileLogger(opts ...CustomLoggerOption) (*zerolog.Logger, error)
NewCustomFileLogger 创建自定义文件日志记录器 返回一个 *zerolog.Logger 对象, 系统会自动处理关闭操作 将日志写入指定文件并享受全局的日志切割和格式化配置
func Panic ¶
Panic starts a new message with panic level. The message is also sent to the panic function.
You must call Msg on the returned event in order to send the event.
func Print ¶
func Print(v ...interface{})
Print sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Print.
func Printf ¶
func Printf(format string, v ...interface{})
Printf sends a log event using debug level and no extra field. Arguments are handled in the manner of fmt.Printf.
func Trace ¶
Trace starts a new message with trace level.
You must call Msg on the returned event in order to send the event.
func Warn ¶
Warn starts a new message with warn level.
You must call Msg on the returned event in order to send the event.
Types ¶
type CustomLogger ¶ added in v1.0.4
CustomLogger 自定义日志记录器(内部使用)
type CustomLoggerOption ¶ added in v1.0.4
type CustomLoggerOption func(*CustomLoggerOptions)
CustomLoggerOption 自定义日志记录器选项函数类型
func WithLogFile ¶ added in v1.0.4
func WithLogFile(logFile string) CustomLoggerOption
WithLogFile 设置日志文件路径
func WithLogLevel ¶ added in v1.0.4
func WithLogLevel(level zerolog.Level) CustomLoggerOption
WithLogLevel 设置日志级别
func WithMaxAge ¶ added in v1.0.4
func WithMaxAge(maxAge int) CustomLoggerOption
WithMaxAge 设置日志文件最大保留时间 (天)
func WithMaxBackups ¶ added in v1.0.4
func WithMaxBackups(maxBackups int) CustomLoggerOption
WithMaxBackups 设置日志文件最大备份数
func WithMaxSize ¶ added in v1.0.4
func WithMaxSize(maxSize int64) CustomLoggerOption
WithMaxSize 设置日志文件最大大小 (MB)
type CustomLoggerOptions ¶ added in v1.0.4
type CustomLoggerOptions struct {
// contains filtered or unexported fields
}
CustomLoggerOptions 自定义日志记录器选项