Documentation ¶
Overview ¶
Package inslogger contains context helpers for log
Examples:
// initialize base context with default logger with provided trace id ctx, inslog := inslogger.WithTraceField(context.Background(), "TraceID") inslog.Warn("warn") // get logger from context inslog := inslogger.FromContext(ctx) // initalize logger (SomeNewLogger() should return core.Logger) inslogger.SetLogger(ctx, SomeNewLogger())
Hints:
Use environment variables for log level setup: INSOLAR_LOG_LEVEL=debug go test ./yourpackage/...
Index ¶
- func ContextWithTrace(ctx context.Context, traceid string) context.Context
- func FromContext(ctx context.Context) core.Logger
- func SetLogger(ctx context.Context, l core.Logger) context.Context
- func TestContext(t *testing.T) context.Context
- func TraceID(ctx context.Context) string
- func WithField(ctx context.Context, key string, value string) (context.Context, core.Logger)
- func WithTraceField(ctx context.Context, traceid string) (context.Context, core.Logger)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithTrace ¶
ContextWithTrace returns only context with logger initialized with provided traceid.
func FromContext ¶
FromContext returns logger from context.
func TestContext ¶
TestContext returns context with initalized log field "testname" equal t.Name() value.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.