log

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorDebugf added in v0.5.0

func ColorDebugf(formatter string, args ...any)

func ColorErrorf added in v0.5.0

func ColorErrorf(formatter string, args ...any)

func ColorFatalf added in v0.5.0

func ColorFatalf(formatter string, args ...any)

func ColorInfof added in v0.5.0

func ColorInfof(formatter string, args ...any)

func ColorWarnf added in v0.5.0

func ColorWarnf(formatter string, args ...any)

func Debug

func Debug(args ...any)

func DebugFields added in v0.5.0

func DebugFields(msg string, fields ...zap.Field)

func Debugf added in v0.3.0

func Debugf(formatter string, args ...any)

func Error

func Error(args ...any)

func ErrorFields added in v0.5.0

func ErrorFields(msg string, fields ...zap.Field)

func Errorf added in v0.3.0

func Errorf(formatter string, args ...any)

func Fatal

func Fatal(args ...any)

func FatalFields added in v0.5.0

func FatalFields(msg string, fields ...zap.Field)

func Fatalf added in v0.3.0

func Fatalf(formatter string, args ...any)

func Info

func Info(args ...any)

func InfoFields added in v0.5.0

func InfoFields(msg string, fields ...zap.Field)

func Infof added in v0.3.0

func Infof(formatter string, args ...any)

func Sync added in v0.5.0

func Sync() error

func Warn

func Warn(args ...any)

func WarnFields added in v0.5.0

func WarnFields(msg string, fields ...zap.Field)

func Warnf added in v0.3.0

func Warnf(formatter string, args ...any)

Types

type Config added in v0.6.3

type Config struct {
	// CallerSkip controls the nesting depth of log function.
	CallerSkip int           `yaml:"caller_skip"`
	CoreConfig []*CoreConfig `yaml:"core_config"`
}

Config is the output config, includes console, file and remote.

type CoreConfig

type CoreConfig struct {
	// Level controls the log level, like debug, info or error.
	Level string

	// Formatter is the format of log, such as console or json.
	Formatter    string
	FormatConfig *FormatConfig `yaml:"formatter_config"`

	// Writer is the output of log, such as console or file.
	Writer      string
	WriteConfig *WriteConfig `yaml:"writer_config"`
}

CoreConfig is console, file output config.

type FormatConfig

type FormatConfig struct {
	// TimeKey is the time key of log output, default as "time".
	TimeKey string `yaml:"time_key"`
	// LevelKey is the level key of log output, default as "level".
	LevelKey string `yaml:"level_key"`
	// NameKey is the name key of log output, default as "name".
	NameKey string `yaml:"name_key"`
	// CallerKey is the caller key of log output, default as "caller".
	CallerKey string `yaml:"caller_key"`
	// FunctionKey is the function key of log output, default as "", which means not to print function name.
	FunctionKey string `yaml:"function_key"`
	// MessageKey is the message key of log output, default as "msg".
	MessageKey string `yaml:"message_key"`
	// StackTraceKey is the stack trace key of log output, default as "", which means not to print stacktrace name.
	StacktraceKey string `yaml:"stacktrace_key"`
}

FormatConfig is the log format config.

type Logger

type Logger interface {
	With(fields ...zap.Field) Logger
	Debug(args ...any)
	Debugf(formatter string, args ...any)
	DebugFields(msg string, fields ...zap.Field)
	Info(args ...any)
	Infof(formatter string, args ...any)
	InfoFields(msg string, fields ...zap.Field)
	Warn(args ...any)
	Warnf(formatter string, args ...any)
	WarnFields(msg string, fields ...zap.Field)
	Error(args ...any)
	Errorf(formatter string, args ...any)
	ErrorFields(msg string, fields ...zap.Field)
	Fatal(args ...any)
	Fatalf(formatter string, args ...any)
	FatalFields(msg string, fields ...zap.Field)
	Sync() error
}

func New added in v0.0.9

func New(c *Config) (Logger, error)

func With added in v0.5.0

func With(fields ...zap.Field) Logger

type WriteConfig

type WriteConfig struct {
	// FileName is the file name like /var/run/log/server.log.
	FileName string `yaml:"file_name"`
	// TimeFormat is the time format to split log file by time.
	TimeFormat string `yaml:"time_format"`
	// MaxSize is the max size of log file(MB).
	MaxSize int `yaml:"max_size"`
	// MaxBackups is the max backup files.
	MaxBackups int `yaml:"max_backups"`
	// MaxAge is the max expire times(day).
	MaxAge int `yaml:"max_age"`
	// Compress defines whether log should be compressed.
	Compress bool `yaml:"compress"`
}

WriteConfig is the local file config.

type ZapLogger added in v0.0.4

type ZapLogger struct {
	// contains filtered or unexported fields
}

func (*ZapLogger) Debug added in v0.0.4

func (z *ZapLogger) Debug(args ...any)

func (*ZapLogger) DebugFields added in v0.0.4

func (z *ZapLogger) DebugFields(msg string, fields ...zap.Field)

func (*ZapLogger) Debugf added in v0.0.4

func (z *ZapLogger) Debugf(formatter string, args ...any)

func (*ZapLogger) Error added in v0.0.4

func (z *ZapLogger) Error(args ...any)

func (*ZapLogger) ErrorFields added in v0.0.4

func (z *ZapLogger) ErrorFields(msg string, fields ...zap.Field)

func (*ZapLogger) Errorf added in v0.0.4

func (z *ZapLogger) Errorf(formatter string, args ...any)

func (*ZapLogger) Fatal added in v0.0.4

func (z *ZapLogger) Fatal(args ...any)

func (*ZapLogger) FatalFields added in v0.0.4

func (z *ZapLogger) FatalFields(msg string, fields ...zap.Field)

func (*ZapLogger) Fatalf added in v0.0.4

func (z *ZapLogger) Fatalf(formatter string, args ...any)

func (*ZapLogger) Info added in v0.0.4

func (z *ZapLogger) Info(args ...any)

func (*ZapLogger) InfoFields added in v0.0.4

func (z *ZapLogger) InfoFields(msg string, fields ...zap.Field)

func (*ZapLogger) Infof added in v0.0.4

func (z *ZapLogger) Infof(formatter string, args ...any)

func (*ZapLogger) Sync added in v0.0.4

func (z *ZapLogger) Sync() error

func (*ZapLogger) Warn added in v0.0.4

func (z *ZapLogger) Warn(args ...any)

func (*ZapLogger) WarnFields added in v0.0.4

func (z *ZapLogger) WarnFields(msg string, fields ...zap.Field)

func (*ZapLogger) Warnf added in v0.0.4

func (z *ZapLogger) Warnf(formatter string, args ...any)

func (*ZapLogger) With added in v0.0.4

func (z *ZapLogger) With(fields ...zap.Field) Logger

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL