contextx

package
v0.0.0-...-c583576 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// KeyCtx ctx key string
	KeyCtx = Key("ctx")
)

Functions

This section is empty.

Types

type Contextx

type Contextx struct {
	context.Context
	// contains filtered or unexported fields
}

Contextx extends google's context to support logging methods

func Background

func Background() Contextx

Background returns a non-nil, empty Context. It is never canceled, has no values, and has no deadline. It is typically used by the main function, initialization, and tests, and as the top-level Context for incoming requests

func BackgroundWithLogger

func BackgroundWithLogger(logger *zap.Logger) Contextx

BackgroundWithLogger returns a non-nil, empty Context. It is never canceled, has no values, and has no deadline. It is typically used by the main function, initialization, and tests, and as the top-level Context for incoming requests

func WithCancel

func WithCancel(parent Contextx) (Contextx, context.CancelFunc)

WithCancel returns a copy of parent with added cancel function

func WithTimeout

func WithTimeout(parent Contextx, d time.Duration) (Contextx, context.CancelFunc)

WithTimeout returns a copy of parent with timeout condition and cancel function

func WithValue

func WithValue(parent Contextx, key interface{}, val interface{}) Contextx

WithValue returns a copy of parent in which the value associated with key is val.

func (*Contextx) Debug

func (c *Contextx) Debug(msg string, fields ...zapcore.Field)

Debug logs a message at DebugLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Contextx) Elapsed

func (c *Contextx) Elapsed(msg string) func()

Elapsed calculate method execution time

func (*Contextx) Error

func (c *Contextx) Error(msg string, fields ...zapcore.Field)

Error logs a message at ErrorLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Contextx) Info

func (c *Contextx) Info(msg string, fields ...zapcore.Field)

Info logs a message at InfoLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

func (*Contextx) Warn

func (c *Contextx) Warn(msg string, fields ...zapcore.Field)

Warn logs a message at WarnLevel. The message includes any fields passed at the log site, as well as any fields accumulated on the logger.

type Key

type Key string

Key declare key string

Jump to

Keyboard shortcuts

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