logger

package
v1.9.8 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

model.go

Index

Constants

This section is empty.

Variables

View Source
var LogDb *gorm.DB

Functions

func Error

func Error(code, message string)

func HandlePanic

func HandlePanic()

捕捉并处理异常的函数

func Info

func Info(code, message string)

func InfoWithCtx

func InfoWithCtx(c *gin.Context, code, message string)

Types

type LogCtxEntity

type LogCtxEntity struct {
	SnowflakeIDModel
	TimeStampsModel
	Code       string `gorm:"column:code" json:"Code" form:"Code" comment:"Code"`
	Level      string `gorm:"column:level" json:"Level" form:"Level" comment:"Level"`
	Message    string `gorm:"column:message" json:"Message" form:"Message" comment:"Message"`
	Ip         string `gorm:"column:ip" json:"Ip" form:"Ip" comment:"Ip"`
	Path       string `gorm:"column:path" json:"Path" form:"Path" comment:"Path"`
	Method     string `gorm:"column:method" json:"Method" form:"Method" comment:"Method"`
	StatusCode int    `gorm:"column:status_code" json:"StatusCode" form:"StatusCode" comment:"StatusCode"`
	Headers    string `gorm:"column:headers" json:"Headers" form:"Headers" comment:"Headers"`
	Body       string `gorm:"column:body" json:"Body" form:"Body" comment:"Body"`
	Latency    int64  `gorm:"column:latency" json:"Latency,string"  form:"Latency" comment:"Latency"`
	FileName   string `gorm:"column:file_name" json:"FileName" form:"FileName" comment:"FileName"`
	FuncName   string `gorm:"column:func_name" json:"FuncName" form:"FuncName" comment:"FuncName"`
	Data       string `gorm:"column:data" json:"Data" form:"Data" comment:"Data"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func (LogCtxEntity) TableName

func (c LogCtxEntity) TableName() string

type LogErrorEntity

type LogErrorEntity struct {
	SnowflakeIDModel
	TimeStampsModel
	Code       string `gorm:"column:code" json:"Code" form:"Code" comment:"Code"`
	Level      string `gorm:"column:level" json:"Level" form:"Level" comment:"Level"`
	Message    string `gorm:"column:message" json:"Message" form:"Message" comment:"Message"`
	Ip         string `gorm:"column:ip" json:"Ip" form:"Ip" comment:"Ip"`
	Path       string `gorm:"column:path" json:"Path" form:"Path" comment:"Path"`
	Method     string `gorm:"column:method" json:"Method" form:"Method" comment:"Method"`
	StatusCode int    `gorm:"column:status_code" json:"StatusCode" form:"StatusCode" comment:"StatusCode"`
	Headers    string `gorm:"column:headers" json:"Headers" form:"Headers" comment:"Headers"`
	Body       string `gorm:"column:body" json:"Body" form:"Body" comment:"Body"`
	Latency    int64  `gorm:"column:latency" json:"Latency,string"  form:"Latency" comment:"Latency"`
	FileName   string `gorm:"column:file_name" json:"FileName" form:"FileName" comment:"FileName"`
	FuncName   string `gorm:"column:func_name" json:"FuncName" form:"FuncName" comment:"FuncName"`
	Data       string `gorm:"column:data" json:"Data" form:"Data" comment:"Data"`
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

func (LogErrorEntity) TableName

func (c LogErrorEntity) TableName() string

type LogInfoEntity

type LogInfoEntity struct {
	SnowflakeIDModel
	TimeStampsModel
	Code      string `gorm:"column:code" json:"Code" form:"Code" comment:"Code"`
	Level     string `gorm:"column:level" json:"Level" form:"Level" comment:"Level"`
	Message   string `gorm:"column:message" json:"Message" form:"Message" comment:"Message"`
	Ip        string `gorm:"column:ip" json:"Ip" form:"Ip" comment:"Ip"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

func (LogInfoEntity) TableName

func (c LogInfoEntity) TableName() string

type SnowflakeIDModel

type SnowflakeIDModel struct {
	Id int64 `gorm:"primaryKey;autoIncrement:false" json:"Id,string"`
}

func (*SnowflakeIDModel) BeforeCreate

func (m *SnowflakeIDModel) BeforeCreate(tx *gorm.DB) error

BeforeCreate 在创建记录前为模型生成雪花算法ID

type TimeStampsModel

type TimeStampsModel struct {
	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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