log

package
v0.0.0-...-e1e9d1d Latest Latest
Warning

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

Go to latest
Published: May 20, 2021 License: BSD-3-Clause Imports: 1 Imported by: 1

Documentation

Overview

Package log defines the standard log interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields map[string]interface{}

Fields is a map of string keys to empty interface values. It is used for structured logging.

type Logger

type Logger interface {
	// Error logs an error message, printing each value passed as argument
	// in the message. This is not a printf-style function, the values
	// are all printed as in a call to fmt.Print. This is to encourage setting
	// dynamic values as fields via WithFields.
	Error(...interface{})

	// Info logs an information message, printing each value passed as argument
	// in the message. This is not a printf-style function, the values
	// are all printed as in a call to fmt.Print. This is to encourage setting
	// dynamic values as fields via WithFields.
	Info(...interface{})

	// WithError returns a Logger that will log all messages with an error
	// field set to the error value.
	WithError(error) Logger

	// WithFields returns a Logger that will log all messages with the provided
	// fields set.
	WithFields(Fields) Logger
}

Logger is the interface for the logger. It encourages structured logging by setting relevant contextual values as fields and then calling either Error or Info with the message. Those are the only supported levels, and neither takes any additional action such as raising a panic or exiting the process.

type MockLogger

type MockLogger struct {
	ErrorFunc      func(...interface{})
	InfoFunc       func(...interface{})
	WithErrorFunc  func(error) Logger
	WithFieldsFunc func(Fields) Logger
}

MockLogger is a test mock for the Logger interface.

func (*MockLogger) Error

func (m *MockLogger) Error(vs ...interface{})

func (*MockLogger) Info

func (m *MockLogger) Info(vs ...interface{})

func (*MockLogger) WithError

func (m *MockLogger) WithError(e error) Logger

func (*MockLogger) WithFields

func (m *MockLogger) WithFields(fields Fields) Logger

Jump to

Keyboard shortcuts

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