logging

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const PreciseLayout = "2006-01-02T15:04:05.000000Z07:00"

PreciseLayout is a variant of time.RFC3339Nano but with microsecond precision and trailing zeroes.

Variables

View Source
var NullLogger = zap.NewNop().Sugar()

NullLogger represents a singleton logger that discards all output.

Functions

func Attach

func Attach(rootCmd *cobra.Command)

Attach attaches logging flags to the provided application.

func Clock

func Clock() zapcore.Clock

Clock is an implementation of zapcore.Clock that uses clock.Now().

func Module

func Module(module string) func(ctx context.Context) Logger

Module returns an function that returns a logger for a given module when provided with a context.

func NewStdConsoleEncoder

func NewStdConsoleEncoder(ec StdConsoleEncoderConfig) zapcore.Encoder

NewStdConsoleEncoder returns standardized console encoder which is optimized for performance.

func PreciseTimeEncoder

func PreciseTimeEncoder() zapcore.TimeEncoder

PreciseTimeEncoder encodes the time as RFC3389 with 6 digits of sub-second precision.

func TimezoneAdjust

func TimezoneAdjust(inner zapcore.TimeEncoder, isLocal bool) zapcore.TimeEncoder

TimezoneAdjust returns zapcore.TimeEncoder that adjusts the time to either UTC or local time before logging.

func WithAdditionalLogger

func WithAdditionalLogger(ctx context.Context, fact LoggerFactory) context.Context

WithAdditionalLogger returns a context where all logging is emitted the original output plus the provided logger factory.

func WithLogger

func WithLogger(ctx context.Context, l LoggerFactory) context.Context

WithLogger returns a derived context with associated logger.

Types

type Logger

type Logger = *zap.SugaredLogger

Logger emits various logs.

func Broadcast

func Broadcast(logger ...Logger) Logger

Broadcast is a logger that broadcasts each log message to multiple loggers.

type LoggerFactory

type LoggerFactory func(module string) Logger

LoggerFactory retrieves a named logger for a given module.

var (
	DefaultLoggerFactory LoggerFactory
)

func ToWriter

func ToWriter(w io.Writer) LoggerFactory

ToWriter returns LoggerFactory that uses given writer for log output (unadorned).

type StdConsoleEncoderConfig

type StdConsoleEncoderConfig struct {
	TimeLayout         string
	LocalTime          bool
	EmitLoggerName     bool
	EmitLogLevel       bool
	DoNotEmitInfoLevel bool
	ColoredLogLevel    bool
}

StdConsoleEncoderConfig provides configurationfor NewStdConsoleEncoder.

Jump to

Keyboard shortcuts

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