log

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package log implements some utilities for our logging. E.g. it provides an utility for parsing the specified log level and a context aware logging function, which can be used to extend the list of fields for a log line, with the fields from the passed in context.

Index

Constants

View Source
const LogKey ctxKeyLog = 0

LogKey is the key that holds the log fields in a context.

Variables

This section is empty.

Functions

func ContextWithValue

func ContextWithValue(ctx context.Context, fields ...zapcore.Field) context.Context

ContextWithValue takes an existing context and adds all the provided fields to the context so that they will then be logged for each line where the returned context is used. In the first step we have to check if the context already contains some log fields. If this is the case, we append the provided fields, so that the new context contains all fields.

func Debug

func Debug(ctx context.Context, msg string, fields ...zapcore.Field)

Debug is a wrapper around the zap.L().Debug() function, which adds all fields from the passed context to the log message.

func Error

func Error(ctx context.Context, msg string, fields ...zapcore.Field)

Error is a wrapper around the zap.L().Error() function, which adds all fields from the passed context to the log message.

func Fatal

func Fatal(ctx context.Context, msg string, fields ...zapcore.Field)

Fatal is a wrapper around the zap.L().Fatal() function, which adds all fields from the passed context to the log message.

func Info

func Info(ctx context.Context, msg string, fields ...zapcore.Field)

Info is a wrapper around the zap.L().Info() function, which adds all fields from the passed context to the log message.

func Panic

func Panic(ctx context.Context, msg string, fields ...zapcore.Field)

Panic is a wrapper around the zap.L().Panic() function, which adds all fields from the passed context to the log message.

func ParseLevel

func ParseLevel(level string) zap.AtomicLevel

ParseLevel parses the give string for the log level and returns the corresponding log level for zap.

func Warn

func Warn(ctx context.Context, msg string, fields ...zapcore.Field)

Warn is a wrapper around the zap.L().Warn() function, which adds all fields from the passed context to the log message.

Types

This section is empty.

Jump to

Keyboard shortcuts

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