Documentation ¶
Index ¶
- func Config(cfg Cfg)
- func DEBUG(args ...any)
- func DEBUGSkip(skip int, args ...any)
- func DUMP(args ...any)
- func DUMPSkip(skip int, args ...any)
- func PRETTY(args ...any)
- func PRETTYSkip(skip int, args ...any)
- func SPEW(args ...any)
- func SPEWSkip(skip int, args ...any)
- type Cfg
- type DebugLogger
- type PrintFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DEBUG ¶
func DEBUG(args ...any)
DEBUG is debug message logger which do nothing if debug level is not enabled (the default). It gives best performance for production deployment by eliminating unnecessary parameter evaluation and control flows.
DEBUG accepts very flexible arguments to help development, see the following examples:
// func() DEBUG(func() { logrus.Debug(something) for _, item := range someSlice { logrus.Debug(item) } }) // logger from context with or without format DEBUG(ctx, 1, 2, 3) DEBUG(ctx, "a=%v b=%v c=%v", 1, 2, 3) // log variables with or without format DEBUG(1, 2, 3) DEBUG("a=%v b=%v c=%v", 1, 2, 3) // optionally a DebugLogger can be provided as the first parameter logger := logrus.WithField("key", "dummy") DEBUG(logger, "aa", 2, 3) DEBUG(logger, "a=%v b=%v c=%v", "aa", 2, 3) // or a function which returns a logger implements DebugLogger logger := func() *logrus.Entry { ... } DEBUG(logger, "aa", 2, 3) DEBUG(logger, "a=%v b=%v c=%v", "aa", 2, 3) // or a print function to print the log message logger := logrus.Debugf DEBUG(logger, "aa", 2, 3) DEBUG(logger, "a=%v b=%v c=%v", "aa", 2, 3) // non-basic-type values will be formatted using json obj := &SomeStructType{Field1: "blah", Field2: 1234567, Field3: true} DEBUG(logger, "obj=%v", obj)
func DEBUGSkip ¶
DEBUGSkip is similar to DEBUG, but it has an extra skip param to skip stacktrace to get correct caller information. When you wrap functions in this package, you always want to use the functions which end with "Skip".
func DUMP ¶
func DUMP(args ...any)
DUMP is similar to DEBUG, but it calls spew.Sdump to format non-basic-type data.
func DUMPSkip ¶
DUMPSkip is similar to DUMP, but it has an extra skip param to skip stacktrace to get correct caller information. When you wrap functions in this package, you always want to use the functions which end with "Skip".
func PRETTY ¶
func PRETTY(args ...any)
PRETTY is similar to DEBUG, but it calls Pretty to format non-basic-type data.
func PRETTYSkip ¶
PRETTYSkip is similar to PRETTY, but it has an extra skip param to skip stacktrace to get correct caller information. When you wrap functions in this package, you always want to use the functions which end with "Skip".
Types ¶
type DebugLogger ¶
DebugLogger is an interface which log an message at DEBUG level. It's implemented by *logrus.Logger, *logrus.Entry, *zap.SugaredLogger, and many other logging packages.