logs

package
v1.0.25 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: MIT Imports: 6 Imported by: 15

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// Error 错误.
	Error = doError
	// Warn 警告.
	Warn = doWarn
	// Info 提示.
	Info = doInfo
	// Debug 调试.
	Debug = doDebug
)

nolint: gochecknoglobals

View Source
var BaseLogger = &baseLogger{
	deb: log.New(os.Stderr, "DEBUG: ", flag),
	inf: log.New(os.Stderr, "INFO: ", flag),
	war: log.New(os.Stderr, "WARN: ", flag),
	err: log.New(os.Stderr, "ERROR: ", flag),
}

BaseLogger 基础日志. nolint: gochecknoglobals

Functions

func SetFlags

func SetFlags(f int)

SetFlags 标志.

func SetLevel

func SetLevel(logLevel LogLevel)

SetLevel 设置日志级别.

func SetLogger

func SetLogger(elems ...Logger)

SetLogger 设置日志.

Types

type LogLevel

type LogLevel = uint8

LogLevel 日志级别.

const (
	// LevelDebug 调试级别.
	LevelDebug LogLevel = iota
	// LevelInfo 提示级别.
	LevelInfo
	// LevelWarn 警告级别.
	LevelWarn
	// LevelError 错误级别.
	LevelError
)

type Logger

type Logger interface {
	// Error 错误.
	Error(...interface{})
	// Warn 警告.
	Warn(...interface{})
	// Info 提示.
	Info(...interface{})
	// Debug 调试.
	Debug(...interface{})
	// SetFlags 设置标记.
	SetFlags(int)
	// 关闭.
	Close()
}

Logger 日志器.

func FileLogger

func FileLogger(file string, files ...string) Logger

FileLogger 新建文件日志. file 默认日志, error 日志, warn 日志, info 日志.

func RollingLogger

func RollingLogger(maxSize int64, file string, files ...string) Logger

RollingLogger 滚动日志.

type WriteCloser

type WriteCloser interface {
	Write(p []byte) (n int, err error)
	Close() error
}

WriteCloser 写入关闭.

Jump to

Keyboard shortcuts

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