xlog

package
v1.0.20 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractParam added in v1.0.17

func ExtractParam(r *http.Request) string

ExtractParam 从 http.Request 中提取参数

func NewLoggingResponseWriter added in v1.0.18

func NewLoggingResponseWriter(w http.ResponseWriter) *xLogResponseWriter

Types

type LogWriter

type LogWriter struct {
	http.ResponseWriter
	Body *bytes.Buffer
}

type OptLog

type OptLog struct {
	User       string `json:"user,omitempty"`
	OpTime     string `json:"op_time,omitempty"`
	OpType     string `json:"op_type,omitempty"`
	IP         string `json:"ip,omitempty"`
	Company    string `json:"company,omitempty"`
	Permission string `json:"permission,omitempty"`
	Method     string `json:"method,omitempty"`
	URL        string `json:"url,omitempty"`
	Module     string `json:"module,omitempty"`
	Param      string `json:"param,omitempty"`
	Trace      string `json:"trace,omitempty"`
	CreatedAt  string `json:"created_at,omitempty"`
	Result     Result `json:"result,omitempty"`
}

OptLog 定义了操作日志的结构

func NewOptLog

func NewOptLog(module, trace string) *OptLog

NewOptLog 创建一个新的 OptLog 实例,并应用默认值

func (*OptLog) WithCompany

func (opt *OptLog) WithCompany(company string) *OptLog

func (*OptLog) WithIp

func (opt *OptLog) WithIp(ip string) *OptLog

func (*OptLog) WithMethod

func (opt *OptLog) WithMethod(method string) *OptLog

func (*OptLog) WithOpTime

func (opt *OptLog) WithOpTime(time string) *OptLog

WithOpTime 为 OptLog 设置操作时间

func (*OptLog) WithOpType

func (opt *OptLog) WithOpType(ty string) *OptLog

func (*OptLog) WithParam

func (opt *OptLog) WithParam(param string) *OptLog

func (*OptLog) WithPermission

func (opt *OptLog) WithPermission(permission string) *OptLog

func (*OptLog) WithRsp

func (opt *OptLog) WithRsp(ret Result) *OptLog

func (*OptLog) WithUrl

func (opt *OptLog) WithUrl(url string) *OptLog

func (*OptLog) WithUser

func (opt *OptLog) WithUser(user string) *OptLog

type Result

type Result struct {
	Code int32       `json:"code,omitempty"`
	Data interface{} `json:"data,omitempty"`
	Msg  string      `json:"msg,omitempty"`
}

Jump to

Keyboard shortcuts

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