xlogger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	F_ASYNC      = 1 << iota // Print logging content asynchronously。
	F_FILE_LONG              // Print full file name and line number: /a/b/c/d.go:23.
	F_FILE_SHORT             // Print final file name element and line number: d.go:23. overrides F_FILE_LONG.
	F_TIME_DATE              // Print the date in the local time zone: 2009-01-23.
	F_TIME_TIME              // Print the time in the local time zone: 01:23:23.
	F_TIME_MILLI             // Print the time with milliseconds in the local time zone: 01:23:23.675.
	F_CALLER_FN              // Print Caller function name and package: main.main
	F_TIME_STD   = F_TIME_DATE | F_TIME_MILLI | F_FILE_LONG
)
View Source
const (
	LEVEL_ALL       = LEVEL_DEBU | LEVEL_INFO | LEVEL_NOTI | LEVEL_WARN | LEVEL_ERRO | LEVEL_CRIT | LEVEL_ERRO_SEND
	LEVEL_DEV       = LEVEL_ALL                                              //开发环境
	LEVEL_PROD      = LEVEL_WARN | LEVEL_ERRO | LEVEL_CRIT | LEVEL_ERRO_SEND //生成环境
	LEVEL_DEBU      = 1 << iota                                              // 8
	LEVEL_INFO                                                               // 16
	LEVEL_NOTI                                                               // 32
	LEVEL_WARN                                                               // 64
	LEVEL_ERRO                                                               // 128
	LEVEL_ERRO_SEND                                                          // 128
	LEVEL_CRIT                                                               // 256
	LEVEL_PANI                                                               // 512
	LEVEL_FATA                                                               // 1024
)

Variables

This section is empty.

Functions

func Black

func Black(buffer *bytes.Buffer)

func Blue

func Blue(buffer *bytes.Buffer)

func Cyan

func Cyan(buffer *bytes.Buffer)

func Green

func Green(buffer *bytes.Buffer)

func Purple

func Purple(buffer *bytes.Buffer)

func Red

func Red(buffer *bytes.Buffer)

func White

func White(buffer *bytes.Buffer)

func Yellow

func Yellow(buffer *bytes.Buffer)

Types

type Config

type Config struct {
	Level         int            //日志等级
	Flags         int            // Extra flags for logging output features.
	Path          string         // Logging directory path.
	Prefix        string         // Prefix string for every logging content.
	StSkip        int            // Skip count for stack.
	StStatus      int            // Stack status(1: enabled - default; 0: disabled)
	HeaderPrint   bool           `c:"header"` // Print header or not(true in default).
	StdoutPrint   bool           `c:"stdout"` // Output to stdout or not(true in default).
	LevelPrefixes map[int]string // Logging level to its prefix string mapping.
	RotateSize    int64          // Rotate the logging file if its size > 0 in bytes.
}

func DefaultConfig

func DefaultConfig() Config

type ErrorInfo

type ErrorInfo struct {
	Error string      //报错接口
	Code  interface{} //错误码
	Msg   interface{} //错误消息
}

type HandlerFunc

type HandlerFunc func(ErrorInfo)

type Logger

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

func New

func New() *Logger

func (*Logger) Debug

func (l *Logger) Debug(v ...interface{})

func (*Logger) Debugf

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

func (*Logger) Error

func (l *Logger) Error(v ...interface{})

func (*Logger) ErrorSend

func (l *Logger) ErrorSend(s ErrorInfo)

错误日志 并发送消息

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(v ...interface{})

func (*Logger) Fatalf

func (l *Logger) Fatalf(f string, v ...interface{})

func (*Logger) GetLevel

func (l *Logger) GetLevel() int

func (*Logger) Info

func (l *Logger) Info(v ...interface{})

func (*Logger) Infof

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

func (*Logger) Panic

func (l *Logger) Panic(v ...interface{})

func (*Logger) Panicf

func (l *Logger) Panicf(format string, v ...interface{})

Panicf prints the logging content with [PANI] header, custom format and newline, then panics.

func (*Logger) SetConfig

func (l *Logger) SetConfig(config Config) error

SetConfig set configurations for the logger.

func (*Logger) SetErrorSend

func (l *Logger) SetErrorSend(h HandlerFunc)

设置回调状态

func (*Logger) SetLevel

func (l *Logger) SetLevel(level int)

SetLevel sets the logging level.

func (*Logger) Warning

func (l *Logger) Warning(v ...interface{})

func (*Logger) Warningf

func (l *Logger) Warningf(format string, v ...interface{})

Jump to

Keyboard shortcuts

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