rlog

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//日志打印登记常量
	LogDebug    = iota //调试
	LogInfo            //信息
	LogWarn            //警告
	LogError           //错误
	LogPanic           //恐慌
	LogNotPrint        //不打印
)
View Source
const NOPATH noPath = 1

Variables

This section is empty.

Functions

func Debug

func Debug(a ...interface{})

func Error

func Error(a ...interface{})

func Finish

func Finish()

Finish 为了保证所有日志打印完毕,建议在程序结束前,运行这个。

func Info

func Info(a ...interface{})

func InitConfig

func InitConfig(c Config)

InitConfig 初始化日志打印配置,为了保证所有日志输出完毕,请在程序终止前,执行 rlog.Finish() 函数。 初始化的目的,是为了打印日志到文件,如果不打印到文件。则不需要执行本函数的初始化。

func Panic

func Panic(a ...interface{})

func SetLogFilePath

func SetLogFilePath(debugFile, infoFile, warnFile, errorFile, panicFile string, maxByte uint64)

SetLogFilePath 设置日志文件地址,不设置地址,不打印到文件。

func SetLogRank

func SetLogRank(prevLength, consoleRank, fileRank uint)

SetLogRank 设置日志打印等级 prevLength:项目地址前面省去多少字符

func SetPrevTime

func SetPrevTime(format string)

SetPrevTime 设置行首日期格式。默认 "2006/01/02·15:04:05"

func Warn

func Warn(a ...interface{})

Types

type Config

type Config struct {
	//PrevLength 可以通过以下代码,计算出你的项目地址,前缀长度。
	//	getwd, _ := os.Getwd()
	//	fmt.Println(len(getwd) + 1)
	//但,需要注意的是, PrevLength 必须是固定值,而不能使用动态计算前缀长度的方式。
	PrevLength  uint   `json:"prev_length"`   //日志打印地址前面省略多少个字符,0则打印完整地址。默认0。
	ConsoloRank uint   `json:"consolo_rank"`  //控制台日志打印等级
	FileRank    uint   `json:"file_rank"`     //文件日志打印等级
	MaxFileSize uint64 `json:"max_file_size"` //日志文件最大大小,1024 * 1024 * 1  为 1MB,如果该值为0,那么执行默认 1MB 。
	DebugFile   string `json:"debug_file"`    //Debug日志文件路径
	InfoFile    string `json:"info_file"`     //Info日志文件路径
	WarnFile    string `json:"warn_file"`     //Warn日志文件路径
	ErrorFile   string `json:"error_file"`    //Error日志文件路径
	PanicFile   string `json:"panic_file"`    //Panic日志文件路径
}

Jump to

Keyboard shortcuts

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