zctx

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: Apache-2.0 Imports: 3 Imported by: 18

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.

func WithOpenTelemetryZap added in v0.18.0

func WithOpenTelemetryZap(ctx context.Context) context.Context

WithOpenTelemetryZap enables otelzap mode, disabling writing span and trace IDs to logs and adding ctx as a log field instead.

Types

This section is empty.

Jump to

Keyboard shortcuts

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