log15

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2020 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Overview

Package log15 provides a Log15 binding for Scribe.

Example
binding := Bind(WithContext(log15.Root()))
s := scribe.New(binding.Factories())

// Do some logging
s.I()("Important application message")

// Eventually, when the logger is no longer required...
err := binding.Close()
if err != nil {
	panic(err)
}
Output:

Index

Examples

Constants

View Source
const KeyErr = "Err"

KeyErr is used to key Scene.Err into the custom context.

Variables

This section is empty.

Functions

This section is empty.

Types

type Binding

type Binding interface {
	Factories() scribe.LoggerFactories
	Close() error
}

Binding captures the state of the binding, including the underlying logger instance. The binding must be closed when the logger is no longer required.

func Bind

func Bind(ctor Constructor, dtor ...Destructor) Binding

Bind makes a new Log15 binding using the given constructor to create the underlying Log15 logger. The returned binding must be closed after the logger is no longer required. The closing of the logger is delegated to an optional destructor. The destructor will typically close any handlers that require explit disposal.

This implementation uses shimming to realise the binding, having compensated for the call stack depth with the underlying logger.

type Constructor

type Constructor func() log15.Logger

Constructor is a way of creating a Log15 logger.

func WithContext

func WithContext(parent log15.Logger, ctx ...interface{}) Constructor

WithContext returns a constructor for creating a Log15 logger from the given parent logger and additional context.

func WithHandler

func WithHandler(ctor Constructor, handler log15.Handler) Constructor

WithHandler wraps a given constructor to inject the given handler to a newly created Log15 logger before returning it to the caller.

type Destructor

type Destructor func(logger log15.Logger) error

Destructor provides a way of cleaning up

func NoDestructor

func NoDestructor() Destructor

NoDestructor is a no-op destructor.

type FullFormat

type FullFormat struct{}

FullFormat prints all fields in a log record. Useful for debugging.

func (FullFormat) Format

func (FullFormat) Format(r *log15.Record) []byte

Format obtains a formatted representation of the given log record.

Jump to

Keyboard shortcuts

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