log

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StdoutSyncer = zapcore.Lock(os.Stdout)
	StderrSyncer = zapcore.Lock(os.Stderr)
)

Functions

func CopyFile

func CopyFile(srcFile, destFile string) error

func Debug

func Debug(msg string)

func DebugOrWarnf

func DebugOrWarnf(start time.Time, format string, args ...interface{})

func Debugf

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

func Error

func Error(msg string, err error)

func Errorf

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

func EscapPath

func EscapPath(msg string) string

func Fatal

func Fatal(msg string, err error)

func Fatalf

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

func FilterFileList

func FilterFileList(path, pat string, permits os.FileMode) ([]string, error)

path : where the file will be filtered pat : regexp pattern to filter the matched file permit : check the file whether match any of the permits or not

func Info

func Info(msg string)

func InfoOrWarnf

func InfoOrWarnf(start time.Time, format string, args ...interface{})

func Infof

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

func NilOrWarnf

func NilOrWarnf(start time.Time, format string, args ...interface{})

func Panic

func Panic(r interface{})

Panic is a function can only be called in defer function.

func Recover

func Recover()

Recover is a function call recover() and print the stack in log Please call this function like 'defer log.Recover()' in your code

func Rotate

func Rotate(path string, MaxFileSize int, MaxBackupCount int)

path: where log files need rollover MaxFileSize: MaxSize of a file before rotate. By M Bytes. MaxBackupCount: Max counts to keep of a log's backup files.

func RotateFile

func RotateFile(file string, MaxFileSize int, MaxBackupCount int)

func SetGlobal

func SetGlobal(cfg Config)

func Sync

func Sync()

func Warn

func Warn(msg string)

func Warnf

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

Types

type Config

type Config struct {
	LoggerLevel string
	LoggerFile  string
	// if false, log print with JSON format
	LogFormatText bool
	// M Bytes
	LogRotateSize  int
	LogBackupCount int
	// days
	LogBackupAge int
	CallerSkip   int
	NoTime       bool // if true, not record time
	NoLevel      bool // if true, not record level
	NoCaller     bool // if true, not record caller
}

Config struct for lager and rotate parameters

func Configure

func Configure() Config

func (Config) WithCallerSkip

func (cfg Config) WithCallerSkip(s int) Config

func (Config) WithFile

func (cfg Config) WithFile(path string) Config

func (Config) WithNoCaller

func (cfg Config) WithNoCaller(b bool) Config

func (Config) WithNoLevel

func (cfg Config) WithNoLevel(b bool) Config

func (Config) WithNoTime

func (cfg Config) WithNoTime(b bool) Config

type Logger

type Logger struct {
	Config Config
	// contains filtered or unexported fields
}

func Default

func Default() *Logger

func NewLogger

func NewLogger(cfg Config) *Logger

func (*Logger) Debug

func (l *Logger) Debug(msg string)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(msg string, err error)

func (*Logger) Errorf

func (l *Logger) Errorf(err error, format string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(msg string, err error)

func (*Logger) Fatalf

func (l *Logger) Fatalf(err error, format string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(msg string)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) Recover

func (l *Logger) Recover(r interface{}, callerSkip int)

callSkip equals to 0 identify the caller of Recover()

func (*Logger) Sync

func (l *Logger) Sync()

func (*Logger) Warn

func (l *Logger) Warn(msg string)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

Jump to

Keyboard shortcuts

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