inslogger

package
v0.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithTrace

func ContextWithTrace(ctx context.Context, traceid string) context.Context

ContextWithTrace returns only context with logger initialized with provided traceid.

func FromContext

func FromContext(ctx context.Context) core.Logger

FromContext returns logger from context.

func SetLogger

func SetLogger(ctx context.Context, l core.Logger) context.Context

SetLogger returns context with provided core.Logger,

func TestContext

func TestContext(t *testing.T) context.Context

TestContext returns context with initalized log field "testname" equal t.Name() value.

func TraceID

func TraceID(ctx context.Context) string

func WithField

func WithField(ctx context.Context, key string, value string) (context.Context, core.Logger)

WithField returns context with logger initialized with provided field's key value and logger itself.

func WithTraceField

func WithTraceField(ctx context.Context, traceid string) (context.Context, core.Logger)

WithTraceField returns context with logger initialized with provided traceid value and logger itself.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL