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 insolar.Logger) inslogger.SetLogger(ctx, SomeNewLogger())
Hints:
Use environment variables for log level setup: INSOLAR_LOG_LEVEL=debug INSOLAR_LOG_FORMATTER=text go test ./yourpackage/...
Index ¶
- func ContextWithTrace(ctx context.Context, traceid string) context.Context
- func FromContext(ctx context.Context) insolar.Logger
- func GetLoggerLevel(ctx context.Context) insolar.LogLevel
- func InitNodeLogger(ctx context.Context, cfg configuration.Log, traceID, nodeRef, nodeRole string) (context.Context, insolar.Logger)
- func SetLogger(ctx context.Context, l insolar.Logger) context.Context
- func TestContext(t *testing.T) context.Context
- func TraceID(ctx context.Context) string
- func UpdateLogger(ctx context.Context, fn func(insolar.Logger) (insolar.Logger, error)) context.Context
- func WithField(ctx context.Context, key string, value string) (context.Context, insolar.Logger)
- func WithFields(ctx context.Context, fields map[string]interface{}) (context.Context, insolar.Logger)
- func WithLoggerLevel(ctx context.Context, logLevel insolar.LogLevel) context.Context
- func WithTraceField(ctx context.Context, traceid string) (context.Context, insolar.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 InitNodeLogger ¶ added in v0.9.0
func TestContext ¶
TestContext returns context with initalized log field "testname" equal t.Name() value.
func UpdateLogger ¶ added in v0.9.8
func WithField ¶
WithField returns context with logger initialized with provided field's key value and logger itself.
func WithFields ¶ added in v0.9.0
func WithFields(ctx context.Context, fields map[string]interface{}) (context.Context, insolar.Logger)
WithFields returns context with logger initialized with provided fields map.
func WithLoggerLevel ¶ added in v0.9.0
SetLoggerLevel returns context with provided insolar.LogLevel and set logLevel on logger,
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.