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
- func ContextWithValue(ctx context.Context, fields ...zapcore.Field) context.Context
- func Debug(ctx context.Context, msg string, fields ...zapcore.Field)
- func Error(ctx context.Context, msg string, fields ...zapcore.Field)
- func Fatal(ctx context.Context, msg string, fields ...zapcore.Field)
- func Info(ctx context.Context, msg string, fields ...zapcore.Field)
- func Panic(ctx context.Context, msg string, fields ...zapcore.Field)
- func ParseLevel(level string) zap.AtomicLevel
- func Warn(ctx context.Context, msg string, fields ...zapcore.Field)
Constants ¶
const LogKey ctxKeyLog = 0
LogKey is the key that holds the log fields in a context.
Variables ¶
This section is empty.
Functions ¶
func ContextWithValue ¶
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 ¶
Debug is a wrapper around the zap.L().Debug() function, which adds all fields from the passed context to the log message.
func Error ¶
Error is a wrapper around the zap.L().Error() function, which adds all fields from the passed context to the log message.
func Fatal ¶
Fatal is a wrapper around the zap.L().Fatal() function, which adds all fields from the passed context to the log message.
func Info ¶
Info is a wrapper around the zap.L().Info() function, which adds all fields from the passed context to the log message.
func Panic ¶
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.
Types ¶
This section is empty.