logs

package
v1.0.57 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2021 License: MIT Imports: 7 Imported by: 15

Documentation

Overview

Package logs 日志类库.

包括 Debug, Info, Warn, Error. 支持控制台输出,文件输入,文件滚动输出.

Index

Constants

This section is empty.

Variables

View Source
var (

	// Error 错误.
	Error = doError
	// ErrorStack 错误及堆栈.
	ErrorStack = doErrorStack
	// 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 Panic added in v1.0.37

func Panic(err error)

Panic 恐慌.

func PanicBool added in v1.0.38

func PanicBool(b bool, err error) bool

PanicBool 布尔值返回.

func PanicBytes added in v1.0.38

func PanicBytes(bs []byte, err error) []byte

PanicBytes 字节码返回.

func PanicInt added in v1.0.39

func PanicInt(i int, err error) int

PanicInt 返回int.

func PanicInt32 added in v1.0.49

func PanicInt32(i int32, err error) int32

PanicInt32 返回int32.

func PanicInt64 added in v1.0.39

func PanicInt64(i int64, err error) int64

PanicInt64 返回int64.

func PanicString added in v1.0.38

func PanicString(str string, err error) string

PanicString 字符串返回.

func PanicU32 added in v1.0.49

func PanicU32(i uint32, err error) uint32

PanicU32 返回uint32.

func PanicU64 added in v1.0.49

func PanicU64(i uint64, err error) uint64

PanicU64 返回uint64.

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{})
	// ErrorStack 错误及堆栈.
	ErrorStack(...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