logger

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PanicLevel = logrus.PanicLevel // 打印后抛出异常
	FatalLevel = logrus.FatalLevel
	ErrorLevel = logrus.ErrorLevel
	WarnLevel  = logrus.WarnLevel
	InfoLevel  = logrus.InfoLevel
	DebugLevel = logrus.DebugLevel
	TraceLevel = logrus.TraceLevel
)

Variables

View Source
var (
	Black     = "\033[30;1m"
	Red       = "\033[31;1m"
	Green     = "\033[32;1m"
	Yellow    = "\033[33;1m"
	Blue      = "\033[34;1m"
	Purple    = "\033[35;1m"
	DarkGreen = "\033[36;1m"
	White     = "\033[37;1m"
	Reset     = "\033[0m"
)

使用后要用Reset重置

Functions

func ExitLogger

func ExitLogger()

func InitLogger

func InitLogger(appName, fileName string)

初始化日志系统

func PrinfInterface

func PrinfInterface(v interface{})

打印各种类型数据

func PrintDebug

func PrintDebug(format string, v ...interface{})

打印 Debug 日志

func PrintDebugCalldepth

func PrintDebugCalldepth(calldepth int, format string, v ...interface{})

func PrintError

func PrintError(format string, v ...interface{})

打印 Error 日志

func PrintErrorCalldepth

func PrintErrorCalldepth(calldepth int, format string, v ...interface{})

func PrintInfo

func PrintInfo(format string, v ...interface{})

打印 Info 日志

func PrintInfoCalldepth

func PrintInfoCalldepth(calldepth int, format string, v ...interface{})

func PrintLog

func PrintLog(level logrus.Level, format string, v ...interface{})

打印日志,自定义日志等级

func PrintPanic

func PrintPanic(format string, v ...interface{})

打印 Panic 日志,并抛出 Panic

func PrintReport

func PrintReport(callerName, calleeName, calleeNode, methods string, errCode int, timeConsume float64)

打印 Report 日志

func PrintReportByTime

func PrintReportByTime(callerName, calleeName, calleeNode, methods string, errCode int, startTimeNano int64)

打印 Report 日志

func PrintZipkin

func PrintZipkin(s string)

打印 Zipkin 日志

Types

type LogrusConfig

type LogrusConfig struct {
	ProgramName string       // 应用名,用于日志目录
	LogFileName string       // 日志文件名
	LogFilePath string       // 日志文件路径
	Suffix      string       // 日志后缀
	LogLevel    logrus.Level // 日志打印级别
	IsFormat    bool         // 是否格式化输出
	PrLogMaxLen int          // 打印日志最大长度
	MaxSize     int64        // 日志文件最大长度
	MaxDays     int          // 日志文件保存天数
	// contains filtered or unexported fields
}

func (*LogrusConfig) Format

func (f *LogrusConfig) Format(entry *logrus.Entry) ([]byte, error)

type MyLogger

type MyLogger struct {
	*logrus.Logger
	// contains filtered or unexported fields
}
var (
	AppLogger       *MyLogger
	AppReportLogger *MyLogger
	AppZipkinLogger *MyLogger
)

func NewLogrus

func NewLogrus(logConf LogrusConfig) *MyLogger

func (*MyLogger) Close

func (l *MyLogger) Close()

func (*MyLogger) GetContextInfo

func (l *MyLogger) GetContextInfo(calldepth int) (string, string, int)

获取日志打印内容的文件信息

func (*MyLogger) InitColor

func (l *MyLogger) InitColor()

Jump to

Keyboard shortcuts

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