loghelper

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README



用于收集日志,查询日志,删除历史过期日志
例:
后台配置日志
用户操作日志
错误日志
软件性能日志
事件日志
连接池监控日志
线程监控日志
定时任务执行日志
服务器性能峰值日志
......

在JAVA中一般采用ELK方式,在GO中貌似有更轻量级的日志系统,也能达到同等效果

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginimeRecord

func BeginimeRecord() time.Time

程序开始执行前调用本方法,会返回开始时间,程序执行完后再调用 execEnd ,execEnd方法会自动判定是否超时

func ByConfig

func ByConfig(title string, logMsg string, uid string)

ByConfig 所有后台配置操作一律要记录日志

func ByDataCenterInfo

func ByDataCenterInfo(title string, logMsg string, uid string)

ByDataCenterInfo 数据平台日志

func ByError

func ByError(title string, logMsg string, uid string)

ByError用于记录所有错误日志(业务错误)

func ByHighError

func ByHighError(title string, logMsg string, uid string)

ByHighError用于记录所有严重错误日志(例:系统异常)

func ByInfo

func ByInfo(title string, logMsg string, uid string)

ByInfo 普通日志记录

func ByRestCatchErr

func ByRestCatchErr(title string, logMsg string, uid string)

ByConfig 所有后台配置操作一律要记录日志

func ByTimeOut

func ByTimeOut(title string, logMsg string, uid string, sqlScriptOrFnName string)

ByTimeOut 记录所有超时的日志 例:ajax请求,事件执行效率,保存超时时间,提交超时时间 以超过5s做为记录依据

func EndTimeRecord

func EndTimeRecord(userID string, countType string, beginExecTime time.Time, execScript ...interface{})

记录结束时间 userID 用户ID countType 统计类型 例:SQL执行,rest请求,事件执行 beginExecTime 开始执行的时间 execScript 执行的SQL或其它语句

func GetIP

func GetIP() string

获取MAC

func SendLog

func SendLog(title, logMsg, ip, uid, logType, filePath string, line int) error

Types

type LogBaseInfo

type LogBaseInfo struct {
	Id        int64
	Title     string `xorm:"Title" json:"title"`
	LogMsg    string `xorm:"LogMsg" json:"logMsg"`
	Uid       string `xorm:"Uid" json:"uid"`
	IP        string `xorm:"Ip" json:"ip"`
	FileName  string `xorm:"Filename" json:"fileName"`
	FileLine  int    `xorm:"fileline" json:"fileline"`
	Extend1   string `xorm:"Extend1" json:"extend1"`
	Extend2   string `xorm:"Extend2" json:"extend2"`
	CreatedAt int64  `xorm:"CreatedAt" json:"createdAt"`
	LogTime   string `xorm:"logtime" json:"logtime"`
	LogType   string `xorm:"LogType" json:"logType"`
}

type LogModel

type LogModel struct {
	// contains filtered or unexported fields
}

func NewLogModel

func NewLogModel(path string) (*LogModel, error)

func (*LogModel) Err

func (l *LogModel) Err(i interface{})

func (*LogModel) Info

func (l *LogModel) Info(i interface{})

Jump to

Keyboard shortcuts

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