Documentation ¶
Index ¶
- func Debug(msg string)
- func DebugCtx(ctx context.Context, msg string)
- func Error(msg string)
- func ErrorCtx(ctx context.Context, msg string)
- func Fatal(msg string)
- func FatalCtx(ctx context.Context, msg string)
- func Info(msg string)
- func InfoCtx(ctx context.Context, msg string)
- func New(cfg *Config)
- func NewContext(ctx context.Context, fields ...zapcore.Field) context.Context
- func NewLogger(exporters ...IExporter)
- func OnlyConsole()
- func Warn(msg string)
- func WarnCtx(ctx context.Context, msg string)
- func WithContext(ctx context.Context) *zap.Logger
- type Config
- type FileExporter
- type IExporter
- type Level
- type StdExporter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Debug ¶
func Debug(msg string)
Debug *
- @Description:
- @param msg
Example ¶
Debug("example")
Output:
func DebugCtx ¶
DebugCtx *
- @Description:
- @param ctx
- @param msg
Example ¶
DebugCtx(context.TODO(), "example")
Output:
func OnlyConsole ¶
func OnlyConsole()
Types ¶
type Config ¶
type Config struct { StdLevel string `toml:"std_level" json:"std_level"` // Std Log level. StdFormat string `toml:"std_format" json:"std_format"` // Std Log format. one of json, text, or console. Level string `toml:"level" json:"level"` // Log level. Format string `toml:"format" json:"format"` // Log format. one of json, text, or console. FileDirectory string `toml:"file_dir" json:"file_dir"` // File directory FileName string `toml:"file_name" json:"file_name"` // Log filename, leave empty to disable file log. MaxSize int `toml:"max_size" json:"max_size"` // Max size for a single file, in MB. MaxDays int `toml:"max_days" json:"max_days"` // Max log keep days, default is never deleting. MaxBackups int `toml:"max_backups" json:"max_backups"` // Maximum number of old log files to retain. Compress bool `toml:"compress" json:"compress"` // Compress }
Config cfg logger
type FileExporter ¶
type FileExporter struct{}
func (*FileExporter) Encoder ¶
func (e *FileExporter) Encoder() zapcore.Encoder
Encoder *
- @Description:
- @receiver e
- @return zapcore.Encoder
func (*FileExporter) Level ¶
func (e *FileExporter) Level() zapcore.Level
Level *
- @Description:
- @receiver e
- @return zapcore.Level
func (*FileExporter) Writer ¶
func (e *FileExporter) Writer() zapcore.WriteSyncer
Writer *
- @Description:
- @receiver e
- @return zapcore.WriteSyncer
type IExporter ¶
type IExporter interface { Encoder() zapcore.Encoder Writer() zapcore.WriteSyncer Level() zapcore.Level }
func NewExporters ¶
func NewExporters() []IExporter
type Level ¶
type Level int8
Level is a logging priority. Higher levels are more important.
const ( DebugLevel Level = iota - 1 InfoLevel WarnLevel ErrorLevel FatalLevel // Critical exists only for config backward compatibility. )
Logging levels.
type StdExporter ¶
type StdExporter struct{}
func (*StdExporter) Encoder ¶
func (e *StdExporter) Encoder() zapcore.Encoder
Encoder *
- @Description:
- @receiver e
- @return zapcore.Encoder
func (*StdExporter) Level ¶
func (e *StdExporter) Level() zapcore.Level
Level *
- @Description:
- @receiver e
- @return zapcore.Level
func (*StdExporter) Writer ¶
func (e *StdExporter) Writer() zapcore.WriteSyncer
Writer *
- @Description:
- @receiver e
- @return zapcore.WriteSyncer
Click to show internal directories.
Click to hide internal directories.