Documentation ¶
Index ¶
- func AttachTraceID(ctx context.Context, traceID string) context.Context
- func GetTraceID(ctx context.Context) string
- func GetTraceIDGin(c *gin.Context) string
- func Logger(l0 logrus.FieldLogger, filter bool) gin.HandlerFunc
- func NewLogger(traceID string, ancestor logrus.FieldLogger) logrus.FieldLogger
- func NewLoggerCtx(ctx context.Context, ancestor logrus.FieldLogger) logrus.FieldLogger
- func NewLoggerGin(c *gin.Context, ancestor logrus.FieldLogger) logrus.FieldLogger
- func TraceIDMiddleware(next http.Handler) http.Handler
- type ContextKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AttachTraceID ¶
AttachTraceID will attach a brand-new request ID to a http request
func GetTraceID ¶
GetTraceID will get reqID from a http request and return it as a string.
func GetTraceIDGin ¶
GetTraceIDGin will get reqID from a http request and return it as a string.
func Logger ¶
func Logger(l0 logrus.FieldLogger, filter bool) gin.HandlerFunc
Logger is the logrus logger handler Filter static when true
func NewLogger ¶
func NewLogger(traceID string, ancestor logrus.FieldLogger) logrus.FieldLogger
NewLogger creates a *logrus.Entry that has requestID as a field. A new LogField inst will be created if log is nil
func NewLoggerCtx ¶
func NewLoggerCtx(ctx context.Context, ancestor logrus.FieldLogger) logrus.FieldLogger
NewLoggerCtx creates a *logrus.Entry that has requestID as a field. A new LogField inst will be created if log is nil.
func NewLoggerGin ¶
func NewLoggerGin(c *gin.Context, ancestor logrus.FieldLogger) logrus.FieldLogger
Types ¶
type ContextKey ¶
type ContextKey string
ContextKey is context key type.
const ( // ContextKeyTraceID is the context key for TraceID. ContextKeyTraceID ContextKey = "TRACE_ID" // HTTPHeaderNamTraceID has the name of the header for trace ID. HTTPHeaderNamTraceID = "X-TRACE-ID" )
Click to show internal directories.
Click to hide internal directories.