Documentation
¶
Overview ¶
Logging and Tracing
Index ¶
- Constants
- Variables
- func AddPropagationKey(key string)
- func AddPropagationKeys(keys ...string)
- func BuildRollingLogFileWriter(p NewRollingLogFileParam) *lumberjack.Logger
- func BuildTraceHeadersAny(rail Rail) map[string]any
- func BuildTraceHeadersStr(rail Rail) map[string]string
- func ConfigDebugLogToInfo(loggerName string, doRewrite bool)
- func CustomFormatter() logrus.Formatter
- func GetCtxInt(ctx context.Context, key string) (int, bool)
- func GetCtxStr(ctx context.Context, key string) (string, bool)
- func GetLogrusLogger() *logrus.Logger
- func GetPropagationKeys() []string
- func IsDebugLevel() bool
- func IsLogLevel(logLevel string) bool
- func IsTraceLevel() bool
- func NewSpanId() string
- func NewTraceId() string
- func ParseLogLevel(logLevel string) (logrus.Level, bool)
- func PreConfiguredFormatter() logrus.Formatter
- func SetLogLevel(level string)
- func SetLogOutput(out io.Writer)
- func TraceLogger(ctx context.Context) *logrus.Entry
- func UsePropagationKeys(forEach func(key string))
- type CTFormatter
- type NewRollingLogFileParam
- type PlainStrFormatter
- type PropagationKeys
- type Rail
- func (r Rail) Context() context.Context
- func (r Rail) CtxValInt(key string) int
- func (r Rail) CtxValStr(key string) string
- func (r Rail) CtxValue(key string) any
- func (r Rail) Deadline() (deadline time.Time, ok bool)
- func (r Rail) Debug(args ...interface{})
- func (r Rail) DebugTimeOp(start time.Time, pat string, args ...any)
- func (r Rail) Debugf(format string, args ...interface{})
- func (r Rail) Debugln(args ...interface{})
- func (r Rail) Done() <-chan struct{}
- func (r Rail) Err() error
- func (r Rail) Error(args ...interface{})
- func (r Rail) ErrorIf(err error, op string, args ...any)
- func (r Rail) Errorf(format string, args ...interface{})
- func (r Rail) Errorln(args ...interface{})
- func (r Rail) Fatal(args ...interface{})
- func (r Rail) Fatalf(format string, args ...interface{})
- func (r Rail) Fatalln(args ...interface{})
- func (r Rail) Info(args ...interface{})
- func (r Rail) Infof(format string, args ...interface{})
- func (r Rail) Infoln(args ...interface{})
- func (r Rail) IsDone() bool
- func (r Rail) NewCtx() Rail
- func (r Rail) NewTrace() Rail
- func (r Rail) NextSpan() Rail
- func (r Rail) Panic(args ...interface{})
- func (r Rail) Panicf(format string, args ...interface{})
- func (r Rail) Panicln(args ...interface{})
- func (r Rail) Print(args ...interface{})
- func (r Rail) Printf(format string, args ...interface{})
- func (r Rail) Println(args ...interface{})
- func (r Rail) RoleNo() string
- func (r Rail) SetGetCallFnUpN(upN int) Rail
- func (r Rail) SpanId() string
- func (r Rail) TimeOp(start time.Time, pat string, args ...any)
- func (r Rail) TraceId() string
- func (r Rail) Tracef(format string, args ...interface{})
- func (r Rail) User() User
- func (r Rail) Username() string
- func (r Rail) Value(key any) any
- func (r Rail) Warn(args ...interface{})
- func (r Rail) WarnIf(err error, op string, args ...any)
- func (r Rail) Warnf(format string, args ...interface{})
- func (r Rail) Warnln(args ...interface{})
- func (r Rail) WithCancel() (Rail, context.CancelFunc)
- func (r Rail) WithCtxVal(key any, val any) Rail
- func (r Rail) WithGetCallFnUpN(upN int) Rail
- func (r Rail) WithName(name string) Rail
- func (r Rail) WithRoleNo(v string) Rail
- func (r Rail) WithSpanId(id string) Rail
- func (r Rail) WithTimeout(timeout time.Duration) (Rail, context.CancelFunc)
- func (r Rail) WithTraceId(id string) Rail
- func (r Rail) WithUsername(v string) Rail
- func (r Rail) ZeroTrace() Rail
- type User
Constants ¶
View Source
const ( XTraceId = "X-B3-TraceId" XSpanId = "X-B3-SpanId" XUsername = "x-username" XUserNo = "x-userno" XRoleNo = "x-roleno" )
Variables ¶
View Source
var ( GetCallerFn = src.GetCallerFn GetCallerFnUpN = src.GetCallerFnUpN )
View Source
var ( Infof = zRail.Infof Tracef = zRail.Tracef Debugf = zRail.Debugf Warnf = zRail.Warnf Errorf = zRail.Errorf Fatalf = zRail.Fatalf Debug = zRail.Debug Info = zRail.Info Warn = zRail.Warn Error = zRail.Error Fatal = zRail.Fatal )
Functions ¶
func BuildRollingLogFileWriter ¶
func BuildRollingLogFileWriter(p NewRollingLogFileParam) *lumberjack.Logger
Create rolling file based logger
func BuildTraceHeadersAny ¶
func BuildTraceHeadersStr ¶
func ConfigDebugLogToInfo ¶
func GetCtxStr ¶
Get value from context as a string
int*, unit*, float* types are formatted as string, other types are returned as empty string
func GetLogrusLogger ¶
func IsLogLevel ¶
func IsTraceLevel ¶
func IsTraceLevel() bool
func PreConfiguredFormatter ¶
Get pre-configured TextFormatter for logrus
func SetLogLevel ¶
func SetLogLevel(level string)
func SetLogOutput ¶
func TraceLogger ¶
Return logger with tracing infomation
func UsePropagationKeys ¶
func UsePropagationKeys(forEach func(key string))
Types ¶
type CTFormatter ¶
type CTFormatter struct {
}
type NewRollingLogFileParam ¶
type PlainStrFormatter ¶
type PlainStrFormatter struct {
}
type PropagationKeys ¶
type PropagationKeys struct {
// contains filtered or unexported fields
}
type Rail ¶
type Rail struct {
// contains filtered or unexported fields
}
Rail, an object that carries trace infromation along with the execution.
It's essentially a thin wrapper of context.Context.
func (Rail) DebugTimeOp ¶ added in v0.4.8
func (Rail) SetGetCallFnUpN ¶
func (Rail) WithCancel ¶
func (r Rail) WithCancel() (Rail, context.CancelFunc)
Create new Rail with context's CancelFunc
func (Rail) WithGetCallFnUpN ¶
func (Rail) WithRoleNo ¶ added in v0.4.11
func (Rail) WithSpanId ¶
func (Rail) WithTimeout ¶
Create new Rail with timeout and context's CancelFunc
func (Rail) WithTraceId ¶
func (Rail) WithUsername ¶
Click to show internal directories.
Click to hide internal directories.