Documentation ¶
Index ¶
- func Debug(msg string, fields ...zapcore.Field)
- func DebugCtx(ctx context.Context, msg string, fields ...zapcore.Field)
- func DefaultPrint(msg string, fields ...zapcore.Field)
- func Error(msg string, fields ...zapcore.Field)
- func ErrorCtx(ctx context.Context, msg string, fields ...zapcore.Field)
- func Fatal(msg string, fields ...zapcore.Field)
- func FatalCtx(ctx context.Context, msg string, fields ...zapcore.Field)
- func Info(msg string, fields ...zapcore.Field)
- func InfoCtx(ctx context.Context, msg string, fields ...zapcore.Field)
- func LogFrmCtx(ctx context.Context, level Level, msg string, fields ...zapcore.Field)
- func New(cfg *Config)
- func NewContext(ctx context.Context, fields ...zapcore.Field) context.Context
- func NewLogger(exporters ...IExporter)
- func NewOne(cfg *Config)
- func OnlyConsole()
- func Print(msg string, err error, fields ...zapcore.Field)
- func PrintCtx(ctx context.Context, msg string, err error, fields ...zapcore.Field)
- func Warn(msg string, fields ...zapcore.Field)
- func WarnCtx(ctx context.Context, msg string, fields ...zapcore.Field)
- func WithContext(ctx context.Context) *zap.Logger
- type Config
- type Fields
- type FileExporter
- type IExporter
- type Key
- type Level
- func (l Level) CtxPrintf(ctx context.Context, format string, a ...interface{})
- func (l Level) CtxPrintln(ctx context.Context, a ...interface{})
- func (l Level) Print(msg string)
- func (l Level) PrintCtx(ctx context.Context, msg string)
- func (l Level) Printf(format string, a ...interface{})
- func (l Level) Println(a ...interface{})
- func (l Level) String() string
- func (l Level) Unabled(level Level) bool
- func (l *Level) Unpack(str string) error
- type LevelFileExporter
- type Logger
- func (logger *Logger) Debug(args ...interface{})
- func (logger *Logger) DebugCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Debugf(format string, args ...interface{})
- func (logger *Logger) Debugln(args ...interface{})
- func (logger *Logger) Error(args ...interface{})
- func (logger *Logger) ErrorCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Errorf(format string, args ...interface{})
- func (logger *Logger) Errorln(args ...interface{})
- func (logger *Logger) Fatal(args ...interface{})
- func (logger *Logger) FatalCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Fatalf(format string, args ...interface{})
- func (logger *Logger) Fatalln(args ...interface{})
- func (logger *Logger) Info(args ...interface{})
- func (logger *Logger) InfoCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Infof(format string, args ...interface{})
- func (logger *Logger) Infoln(args ...interface{})
- func (logger *Logger) Log(level Level, args ...interface{})
- func (logger *Logger) LogCtxf(ctx context.Context, level Level, format string, args ...interface{})
- func (logger *Logger) Logf(level Level, format string, args ...interface{})
- func (logger *Logger) Logln(level Level, args ...interface{})
- func (logger *Logger) Panic(args ...interface{})
- func (logger *Logger) PanicCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Panicf(format string, args ...interface{})
- func (logger *Logger) Panicln(args ...interface{})
- func (logger *Logger) Print(args ...interface{})
- func (logger *Logger) PrintCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Printf(format string, args ...interface{})
- func (logger *Logger) Println(args ...interface{})
- func (logger *Logger) Trace(args ...interface{})
- func (logger *Logger) TraceCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Tracef(format string, args ...interface{})
- func (logger *Logger) Traceln(args ...interface{})
- func (logger *Logger) Warn(args ...interface{})
- func (logger *Logger) WarnCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Warnf(format string, args ...interface{})
- func (logger *Logger) Warning(args ...interface{})
- func (logger *Logger) WarningCtxf(ctx context.Context, format string, args ...interface{})
- func (logger *Logger) Warningf(format string, args ...interface{})
- func (logger *Logger) Warningln(args ...interface{})
- func (logger *Logger) Warnln(args ...interface{})
- func (logger *Logger) WithField(key string, value interface{}) *Logger
- func (logger *Logger) WithFields(fields Fields) *Logger
- type StdExporter
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugCtx ¶
DebugCtx *
- @Description:
- @param ctx
- @param msg
Example ¶
DebugCtx(context.TODO(), "example")
Output:
func DefaultPrint ¶ added in v1.2.0
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 EncodeTime func(time.Time, zapcore.PrimitiveArrayEncoder) }
Config cfg logger
type FileExporter ¶
type FileExporter struct {
zapcore.EncoderConfig
}
FileExporter std console exporter
func (*FileExporter) Encoder ¶
func (e *FileExporter) Encoder() zapcore.Encoder
Encoder *
- @Description:
- @receiver e
- @return zapcore.Encoder
func (*FileExporter) Level ¶
func (e *FileExporter) Level() zapcore.LevelEnabler
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.LevelEnabler }
func NewExporters ¶
func NewLevelExporters ¶ added in v1.3.0
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 LevelFileExporter ¶ added in v1.3.0
type LevelFileExporter struct { zapcore.EncoderConfig // contains filtered or unexported fields }
LevelFileExporter file console exporter
func NewLevelFileExporter ¶ added in v1.3.0
func NewLevelFileExporter(level zapcore.Level, cfg *Config) *LevelFileExporter
func (*LevelFileExporter) Enabled ¶ added in v1.3.0
func (e *LevelFileExporter) Enabled(lvl zapcore.Level) bool
Enabled level enable
func (*LevelFileExporter) Encoder ¶ added in v1.3.0
func (e *LevelFileExporter) Encoder() zapcore.Encoder
Encoder *
- @Description:
- @receiver e
- @return zapcore.Encoder
func (*LevelFileExporter) Level ¶ added in v1.3.0
func (e *LevelFileExporter) Level() zapcore.LevelEnabler
Level *
- @Description:
- @receiver e
- @return zapcore.Level
func (*LevelFileExporter) Writer ¶ added in v1.3.0
func (e *LevelFileExporter) Writer() zapcore.WriteSyncer
Writer *
- @Description:
- @receiver e
- @return zapcore.WriteSyncer
type Logger ¶
type Logger struct {
FieldMap Fields
}
Logger this wrap instead of "logrus"
func (*Logger) WarningCtxf ¶
func (*Logger) WithFields ¶
type StdExporter ¶
type StdExporter struct {
zapcore.EncoderConfig
}
StdExporter std console exporter
func (*StdExporter) Encoder ¶
func (e *StdExporter) Encoder() zapcore.Encoder
Encoder *
- @Description:
- @receiver e
- @return zapcore.Encoder
func (*StdExporter) Level ¶
func (e *StdExporter) Level() zapcore.LevelEnabler
Level *
- @Description:
- @receiver e
- @return zapcore.Level
func (*StdExporter) Writer ¶
func (e *StdExporter) Writer() zapcore.WriteSyncer
Writer *
- @Description:
- @receiver e
- @return zapcore.WriteSyncer
Source Files ¶
Click to show internal directories.
Click to hide internal directories.