logger

package
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug added in v1.0.2

func Debug(v ...interface{})

Debug 以Debug级别打印日志

func DefaultFormatter

func DefaultFormatter(l *logger, t time.Time, level LogLevel, v ...interface{})

DefaultFormatter 是默认的日志格式器,输出格式为

[I] [PREFIX] 2022-03-02 21:35:43 | xxxxx
[E] [PREFIX] 2022-03-02 21:35:43 | xxxxx

func Error added in v1.0.2

func Error(v ...interface{})

Error 以Error级别打印日志

func Fatal added in v1.0.2

func Fatal(v ...interface{})

Fatal 以Fatal级别打印日志

func GetCaller added in v1.0.5

func GetCaller(callLevel int) string

func Info added in v1.0.2

func Info(v ...interface{})

Info 以Info级别打印日志

func New

func New(out io.Writer, prefix string, level LogLevel, formatter Formatter) *logger

New 初始化一个日志实例

func SetFormatter added in v1.0.2

func SetFormatter(formatter Formatter)

SetFormatter 设置日志格式器

func SetOut added in v1.0.2

func SetOut(out io.Writer)

SetOut 设置日志输入

func SetPrefix added in v1.0.2

func SetPrefix(prefix string)

SetPrefix 设置日志前缀

func SimpleFormatter added in v1.0.5

func SimpleFormatter(l *logger, t time.Time, level LogLevel, v ...interface{})

SimpleFormatter 是简化的日志格式器,输出格式为

[I] [PREFIX] 2022-03-02 21:35:43 | xxxxx
[E] [PREFIX] 2022-03-02 21:35:43 | xxxxx

func Warn added in v1.0.2

func Warn(v ...interface{})

Warn 以Warn级别打印日志

Types

type Formatter

type Formatter func(l *logger, t time.Time, level LogLevel, v ...interface{})

type LogLevel

type LogLevel int
const (
	LevelDebug LogLevel = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
)

func ParseLevel

func ParseLevel(levelName string) LogLevel

Jump to

Keyboard shortcuts

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