logx

package
v0.0.0-...-43a62c1 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddField

func AddField(k string, v interface{})

func AnyToString

func AnyToString(raw interface{}) string

func Bool

func Bool(e interface{}) bool

func Debug

func Debug(e interface{}, args ...interface{}) error

func Debugf

func Debugf(format string, args ...interface{}) error

func Error

func Error(e interface{}, args ...interface{}) error

func Errorf

func Errorf(format string, args ...interface{}) error

func Fatal

func Fatal(e interface{}, args ...interface{})

func Fatalf

func Fatalf(format string, args ...interface{})

func GetLevel

func GetLevel() string

func Info

func Info(e interface{}, args ...interface{}) error

func Infof

func Infof(format string, args ...interface{}) error

func InitDefaultLogger

func InitDefaultLogger(cfg *LogConfig)

InitDefaultLogger initial standard log, if you don't init, it will use default logger setting

func Panic

func Panic(e interface{}, args ...interface{})

func Panicf

func Panicf(format string, args ...interface{})

func SetLevel

func SetLevel(lvl string)

func Warn

func Warn(e interface{}, args ...interface{}) error

func Warnf

func Warnf(format string, args ...interface{}) error

Types

type Fields

type Fields map[string]interface{}

type LogConfig

type LogConfig struct {
	AppName         string `yaml:"app_name" json:"app_name" toml:"app_name"`
	Level           string `yaml:"level" json:"level" toml:"level"`
	StacktraceLevel string `yaml:"stacktrace_level" json:"stacktrace_level" toml:"stacktrace_level"`
	IsStdOut        bool   `yaml:"is_stdout" json:"is_stdout" toml:"is_stdout"`
	IsStdErr        bool   `yaml:"is_stderr" json:"is_stderr" toml:"is_stderr"`
	TimeFormat      string `yaml:"time_format" json:"time_format" toml:"time_format"` // second, milli, nano, standard, iso,
	Encoding        string `yaml:"encoding" json:"encoding" toml:"encoding"`          // console, json
	Skip            int    `yaml:"skip" json:"skip" toml:"skip"`

	IsFileOut     bool   `yaml:"is_file_out" json:"is_file_out" toml:"is_file_out"`
	FileDir       string `yaml:"file_dir" json:"file_dir" toml:"file_dir"`
	FileName      string `yaml:"file_name" json:"file_name" toml:"file_name"`
	FileMaxSize   int    `yaml:"file_max_size" json:"file_max_size" toml:"file_max_size"` // MB
	FileMaxAge    int    `yaml:"file_max_age" json:"file_max_age" toml:"file_max_age"`    // Days
	FileMaxBackup int    `yaml:"file_max_backup" json:"file_max_backup" toml:"file_max_backup"`
}

type LogX

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

func AddCallerSkip

func AddCallerSkip(skip int) *LogX

AddCallerSkip temporary add call skip

func AddDepth

func AddDepth(skip int) *LogX

AddDepth permanent add call skip

func AddFields

func AddFields(fields map[string]interface{}) *LogX

func AddOptions

func AddOptions(opts ...zap.Option) *LogX

AddOptions permanent add options

func NewLogger

func NewLogger(cfg *LogConfig) *LogX

NewLogger create a new logger

func (*LogX) DPanic

func (l *LogX) DPanic(s interface{}, args ...interface{})

func (*LogX) DPanicf

func (l *LogX) DPanicf(msg string, args ...interface{}) error

func (*LogX) Debug

func (l *LogX) Debug(s interface{}, args ...interface{}) error

func (*LogX) Debugf

func (l *LogX) Debugf(msg string, args ...interface{}) error

func (*LogX) Error

func (l *LogX) Error(s interface{}, args ...interface{}) error

func (*LogX) Errorf

func (l *LogX) Errorf(msg string, args ...interface{}) error

func (*LogX) Fatal

func (l *LogX) Fatal(s interface{}, args ...interface{})

func (*LogX) Fatalf

func (l *LogX) Fatalf(msg string, args ...interface{})

func (*LogX) Info

func (l *LogX) Info(s interface{}, args ...interface{}) error

func (*LogX) Infof

func (l *LogX) Infof(msg string, args ...interface{}) error

func (*LogX) LogError

func (l *LogX) LogError(err error) error

func (*LogX) Panic

func (l *LogX) Panic(s interface{}, args ...interface{})

func (*LogX) Panicf

func (l *LogX) Panicf(msg string, args ...interface{})

func (*LogX) Warn

func (l *LogX) Warn(s interface{}, args ...interface{}) error

func (*LogX) Warnf

func (l *LogX) Warnf(msg string, args ...interface{}) error

type Syncer

type Syncer struct {
	*lumberjack.Logger
	// contains filtered or unexported fields
}

func NewSyncer

func NewSyncer(l *lumberjack.Logger) *Syncer

func (*Syncer) Stop

func (s *Syncer) Stop()

func (*Syncer) Sync

func (s *Syncer) Sync() error

func (*Syncer) Write

func (s *Syncer) Write(bs []byte) (int, error)

type WriteSyncer

type WriteSyncer interface {
	io.Writer
	Sync() error
}

WriteSyncer output interface

func NewRollingFile

func NewRollingFile(dir, filename string, maxSize, maxAge, maxBackups int) WriteSyncer

NewRollingFile split writer

Jump to

Keyboard shortcuts

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