logging

package
v0.0.0-...-e2602fe Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2024 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GrpcClientLoggerUnary

func GrpcClientLoggerUnary(ctx context.Context, method string, req, reply any, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error

GrpcClientLoggerUnary grpc客户端日志拦截器

func GrpcServerLoggerUnary

func GrpcServerLoggerUnary(
	ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler,
) (interface{}, error)

GrpcServerLoggerUnary grpc服务端日志拦截器

func HandlerJson

func HandlerJson(ctx context.Context, in *glog.HandlerInput)

func HttpAccessLogMiddleware

func HttpAccessLogMiddleware(r *ghttp.Request)

func HttpClientLogMiddleware

func HttpClientLogMiddleware(c *gclient.Client, r *http.Request) (response *gclient.Response, err error)

func HttpErrorLogMiddleware

func HttpErrorLogMiddleware(r *ghttp.Request)

func HttpLogFormatJsonMiddleware

func HttpLogFormatJsonMiddleware(r *ghttp.Request)

Types

type ErrorLog

type ErrorLog struct {
	Method  string      `json:"method"`  //异常的方法
	Req     interface{} `json:"req"`     //异常方法的入参
	Code    int         `json:"code"`    //异常错误码
	Message string      `json:"message"` //异常信息
	Detail  interface{} `json:"detail"`  //异常详情
}

func (ErrorLog) Log

func (l ErrorLog) Log(ctx context.Context, err ...error)

type GrpcAccessLog

type GrpcAccessLog struct {
	Path  string      `json:"path"`
	Cost  string      `json:"cost"`
	Req   interface{} `json:"req"`
	Res   interface{} `json:"res"`
	Error errorI      `json:"error"`
	Meta  interface{} `json:"meta"`
}

func (GrpcAccessLog) Log

func (l GrpcAccessLog) Log(ctx context.Context, err ...error)

type GrpcClientLog

type GrpcClientLog struct {
	Path  string      `json:"path"`
	Cost  string      `json:"cost"`
	Req   interface{} `json:"req"`
	Res   interface{} `json:"res"`
	Error errorI      `json:"error"`
	Meta  interface{} `json:"meta"`
}

func (GrpcClientLog) Log

func (l GrpcClientLog) Log(ctx context.Context, err ...error)

type HandlerOutputJson

type HandlerOutputJson struct {
	Time       string `json:"time"`               // Formatted time string, like "2016-01-09 12:00:00".
	TraceId    string `json:"trace_id,omitempty"` // Trace id, only available if tracing is enabled.
	Category   string `json:"category"`
	CtxStr     string `json:"ctx_str,omitempty"`     // The retrieved context value string from context, only available if Config.CtxKeys configured.
	Level      string `json:"level"`                 // Formatted level string, like "DEBU", "ERRO", etc. Eg: ERRO
	CallerFunc string `json:"caller_func,omitempty"` // The source function name that calls logging, only available if F_CALLER_FN set.
	CallerPath string `json:"caller_path,omitempty"` // The source file path and its line number that calls logging, only available if F_FILE_SHORT or F_FILE_LONG set.
	Prefix     string `json:"prefix,omitempty"`      // Custom prefix string for logging content.
	Content    any    `json:"content"`               // Content is the main logging content, containing error stack string produced by logger.
	Stack      string `json:"stack,omitempty"`       // Stack string produced by logger, only available if Config.StStatus configured.
}

type HttpAccessLog

type HttpAccessLog struct {
	HttpCode int                    `json:"http_code"`
	Scheme   string                 `json:"scheme"`
	Method   string                 `json:"method"`
	Host     string                 `json:"host"`
	Path     string                 `json:"path"`
	Cost     float64                `json:"cost"`
	Req      map[string]interface{} `json:"req"`
	Res      interface{}            `json:"res"`
	Ip       string                 `json:"ip"`
	Header   http.Header            `json:"header"`
}

func (HttpAccessLog) Log

func (l HttpAccessLog) Log(ctx context.Context)

type HttpClientLog

type HttpClientLog struct {
	HttpCode int                    `json:"http_code"`
	Scheme   string                 `json:"scheme"`
	Method   string                 `json:"method"`
	Host     string                 `json:"host"`
	Path     string                 `json:"path"`
	Cost     string                 `json:"cost"`
	Req      map[string]interface{} `json:"req"`
	Res      interface{}            `json:"res"`
	Header   http.Header            `json:"header"`
}

func (HttpClientLog) Log

func (l HttpClientLog) Log(ctx context.Context)

Jump to

Keyboard shortcuts

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