logrus

package
v0.0.0-...-e0d6b9e Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilLogger = errors.New("Logger is nil,please check the whether logger is init correct! ")
View Source
var (
	LLogger *logruslog.Logger
)

Functions

func Debug

func Debug(message ...interface{})

func Debugf

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

func Error

func Error(err error, message ...interface{})

func Errorf

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

func Fatal

func Fatal(err error, message ...interface{})

Fatal日志基本打印时Logger会自动退出

func Fatalf

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

Fatalf日志基本打印时Logger会自动退出

func GetLogger

func GetLogger() *logruslog.Logger

func Info

func Info(message ...interface{})

func Infof

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

func InitLogger

func InitLogger(c *LogConf) error

初始化全局的Logrus日志框架

func SetWriter

func SetWriter(c *LogConf)

func Warn

func Warn(err error, message ...interface{})

func Warnf

func Warnf(err error, format string, message ...interface{})

Types

type LogConf

type LogConf struct {
	// FileName 日志文件路径
	FileName string `json:"fileName" yaml:"fileName"`
	// MaxSize 每个日志文件保存的最大尺寸 单位:M
	MaxSize int `json:"maxSize" yaml:"maxSize"`
	// MaxBackups 日志文件最多保存多少个备份
	MaxBackups int `json:"maxBackups" yaml:"maxBackups"`
	// MaxAge 文件最多保存多少天
	MaxAge int `json:"maxAge"  yaml:"maxAge"`
	// Compress 是否压缩
	Compress bool `json:"compress" yaml:"compress"`
	// Console 是否打印到控制台
	Console bool `json:"console" yaml:"console"`
}

type MyFormatter

type MyFormatter struct {
	PrettyPrint bool
}

MyFormatter 自定义 formatter

func (*MyFormatter) Format

func (mf *MyFormatter) Format(entry *logruslog.Entry) ([]byte, error)

Format implement the Formatter interface

Jump to

Keyboard shortcuts

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