log

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UnwrapContext = func(ctx context.Context) context.Context {
	return ctx
}

ContextFunc is to get the actual log context from a custom context (gin-kit context) Override this function at the startup to avoid race condition

Functions

func Debug

func Debug(ctx context.Context, v ...interface{})

Debug logs with debug level

func Error

func Error(ctx context.Context, v ...interface{})

Error logs with error level

func GetID

func GetID(ctx context.Context) string

GetID returns the context id from context

func Info

func Info(ctx context.Context, v ...interface{})

Info logs with info level

func SaveID

func SaveID(ctx context.Context, contextID string) context.Context

SaveID saves the context id to context variable and custom context store Return a copy of parent in which the value associated with key is

func Setup

func Setup(module string, writer io.Writer)

Setup setups logger

func Warn

func Warn(ctx context.Context, v ...interface{})

Warn logs with warn level

func WithContextualValues

func WithContextualValues(ctx context.Context, keysAndValues ...interface{}) context.Context

WithContextualValues sets contextual keys and values which will be shared with downstream functions Pass keys and values in log functions if you want to write keys/values for a single log keysAndValues must be string keys and arbitrary values, and extraneous ones are ignored

Types

type Logger

type Logger interface {
	Info(ctx context.Context, v ...interface{})
	Warn(ctx context.Context, v ...interface{})
	Debug(ctx context.Context, v ...interface{})
	Error(ctx context.Context, v ...interface{})
	Fields(ctx context.Context, kvList ...interface{}) Logger
	AddCallDepth(i int) Logger
	WithContextualValues(ctx context.Context, kvList ...interface{}) context.Context
}

Logger defines interface for logger

func Fields

func Fields(ctx context.Context, keysAndValues ...interface{}) Logger

Fields sets log fields for a single log line Info, Warn, Debug, Error must be called. Otherwise, log will be ignored

func NewLogger

func NewLogger() Logger

NewLogger returns new instance

Jump to

Keyboard shortcuts

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