logger

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package logger defines a common logger interface used by the library various components.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(l Logger, msg string, fields ...Field)

Debug delegates the debug log call to the provided logger, if not nil.

func Error

func Error(l Logger, msg string, fields ...Field)

Error delegates the error log call to the provided logger, if not nil.

func Info

func Info(l Logger, msg string, fields ...Field)

Info delegates the info log call to the provided logger, if not nil.

Types

type Field

type Field struct {
	Key   string
	Value interface{}
}

Field represents a structured field to be added to a Log entry.

func With

func With(key string, value interface{}) Field

With is an helper function to add a field in a functional way.

type Logger

type Logger interface {
	Debug(msg string, fields ...Field)
	Info(msg string, fields ...Field)
	Error(msg string, fields ...Field)
}

Logger is a structured logger capable of printing information about the execution of a component at various levels.

type Nop

type Nop struct{}

Nop is a nop logger implementation.

func (Nop) Debug

func (Nop) Debug(msg string, fields ...Field)

Debug prints literally nothing.

func (Nop) Error

func (Nop) Error(msg string, fields ...Field)

Error prints literally nothing.

func (Nop) Info

func (Nop) Info(msg string, fields ...Field)

Info prints literally nothing.

type Test

type Test struct {
	// contains filtered or unexported fields
}

Test is a logger.Logger implementation using testing.T instance.

func NewTest

func NewTest(t *testing.T) Test

NewTest returns a new logger using the provided testing.T instance.

func (Test) Debug

func (t Test) Debug(msg string, fields ...Field)

Debug uses t.Logf to print a debug message.

func (Test) Error

func (t Test) Error(msg string, fields ...Field)

Error uses t.Logf to print an error message.

func (Test) Info

func (t Test) Info(msg string, fields ...Field)

Info uses t.Logf to print an info message.

Jump to

Keyboard shortcuts

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