logger

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package logger provides logging facilities with incremental prefixes stored in contexts.

Calls to Print and Println print log to the Target, with all the prefixes stored in the context by previous calls to Push. This provides a convenient facility for log in servers, for which different components may add information to be logged about the current request. The function Constructor is a so-called "middleware" initiating this facility for net/http compatible servers.

Index

Constants

This section is empty.

Variables

View Source
var NoLogInfo = errors.New("Log info not found in context")

NoLogInfo is returned when the given context has no log prefix stack.

Functions

func Constructor

func Constructor(next http.Handler) http.Handler

Constructor is a so-called net/http "middleware" that initialises a log prefix stack in the request's context and logs the time elapsed for the request.

func New

func New(ctx context.Context) context.Context

New creates returns a copy of ctx with a log prefix stack.

func Print

func Print(ctx context.Context, msg ...interface{}) error

Print send a log message with all the prefixes from the log stack of ctx.

func Printf

func Printf(ctx context.Context, format string, msg ...interface{}) error

Print send a log message with all the prefixes from the log stack of ctx.

func Push

func Push(ctx context.Context, info ...interface{}) error

Push add the given prefixes to the log prefix stack of the context.

Types

type Printer

type Printer interface {
	Println(a ...interface{})
}

Printer is the type of the Target variable.

var Target Printer

Target is underlying object used to print the logs. By default it is a log.Logger object with the same behaviour as log's standard logger.

Jump to

Keyboard shortcuts

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