clog15

package module
v0.0.0-...-e3e2472 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2020 License: BSD-3-Clause Imports: 2 Imported by: 3

README

Build Status codecov Go Report Card GoDoc

Clog15

Package clog15 provides utilities to embed and extract a log15.Logger to a context. This might be helpfull to preserve logger context while being restricted by funtction signatures. For instance in http.HanderFunc, middleware or gRPC interceptors. It allows you to define logging context and attach the configured logger to a context passed down the executions chain.

License

Copyright (c) 2020, Mohlmann Solutions SRL. All rights reserved. Use of this source code is governed by a BSD 3 Clause License that can be found in the LICENSE file.

Documentation

Overview

Package clog15 provides utilities to embed and extract a log15.Logger to a context. This might be helpful to preserve logger context while being restricted by function signatures. For instance in http.HanderFunc, middleware or gRPC interceptors. It allows you to define logging context and attach the configured logger to a context passed down the executions chain.

Index

Constants

View Source
const CtxLogger logKey = 1

CtxLogger is the context Value key which must be used.

Variables

This section is empty.

Functions

func AddArgs

func AddArgs(ctx context.Context, args ...interface{}) context.Context

AddArgs to the logger in the returned context. If there is no logger set to context, a new root logger is returned with args.

func Crit

func Crit(ctx context.Context, msg string, args ...interface{})

Crit is a wrapper for GetLogger().Crit()

func Debug

func Debug(ctx context.Context, msg string, args ...interface{})

Debug is a wrapper for GetLogger().Debug()

func Error

func Error(ctx context.Context, msg string, args ...interface{})

Error is a wrapper for GetLogger().Error()

func GetLogger

func GetLogger(ctx context.Context) log.Logger

GetLogger retrieves a logger from the context. If there is no logger set to context, a new root logger is returned.

func Info

func Info(ctx context.Context, msg string, args ...interface{})

Info is a wrapper for GetLogger().Info()

func NewLogger

func NewLogger(ctx context.Context, args ...interface{}) context.Context

NewLogger creates a new logger from the Root logger. It embeds the logger into the returned context. args are added to the logger's context.

func SetLogger

func SetLogger(ctx context.Context, l log.Logger, args ...interface{}) context.Context

SetLogger embeds the logger into the returned context. args are added to the logger's context.

func Warn

func Warn(ctx context.Context, msg string, args ...interface{})

Warn is a wrapper for GetLogger().Warn()

Types

This section is empty.

Jump to

Keyboard shortcuts

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