zctx

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 3 Imported by: 5

Documentation

Overview

Package zctx is a context-aware zap logger.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base

func Base(ctx context.Context, lg *zap.Logger) context.Context

Base initializes root logger for using as a base context. Should be done early.

The span and trace IDs must not be added to the base logger because zap can't update or replace fields.

func From

func From(ctx context.Context) *zap.Logger

From returns zap.Logger from context.

func Start added in v0.3.0

func Start(ctx context.Context) (context.Context, *zap.Logger)

Start allocates new span logger and returns new context with it. Use Start to reduce allocations during From, caching the span-scoped logger.

Should be same as ctx = With(ctx), but more effective.

func With

func With(ctx context.Context, fields ...zap.Field) context.Context

With returns new context with provided zap fields.

The span and trace IDs must not be added to the base logger because zap can't update or replace fields.

Types

This section is empty.

Jump to

Keyboard shortcuts

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