loggee

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package loggee is logging wrapper interface that allows share packages to call logging services without the calling application being tide to a specific implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Activity

func Activity(ctx context.Context, fn ActivityFunc) error

Activity log within th context of the activity.

func BindMultiErrorFormatting added in v0.2.1

func BindMultiErrorFormatting(err error) error

BindMultiErrorFormatting is a helper function to attach a standard formatter to opt in hashicorp/go-multierror errors.

func Debug

func Debug(msg string)

Debug writes a debug message.

func Debugf

func Debugf(fmt string, args ...interface{})

Debugf writes a formated debug message.

func Error

func Error(msg string)

Error writes an error message.

func Errorf

func Errorf(fmt string, args ...interface{})

Errorf writes a formated error message.

func Fatal

func Fatal(msg string)

Fatal writes a fatal error message and exits.

func Fatalf

func Fatalf(fmt string, args ...interface{})

Fatalf writes a formated fatal message and exits.

func Info

func Info(msg string)

Info writes a info message.

func Infof

func Infof(fmt string, args ...interface{})

Infof writes a formated info message.

func SetLogger

func SetLogger(logger Logger)

SetLogger sets the logger.

func SetMultiErrorFormatting added in v0.2.1

func SetMultiErrorFormatting(f func([]error) string)

SetMultiErrorFormatting allows the multiple error formatting to be globally set.

func Warn

func Warn(msg string)

Warn writes a warning message.

func Warnf

func Warnf(fmt string, args ...interface{})

Warnf writes a formated warn message.

Types

type ActivityFunc

type ActivityFunc func(context.Context) error

ActivityFunc is the call back function signature for an activity Activities allow logging context to be added to output.

type Entry

type Entry interface {
	WithFields(Fielder) Entry
	WithField(string, interface{}) Entry
	WithDuration(time.Duration) Entry
	WithError(error) Entry
	Debug(string)
	Info(string)
	Warn(string)
	Error(string)
	Fatal(string)
	Debugf(string, ...interface{})
	Infof(string, ...interface{})
	Warnf(string, ...interface{})
	Errorf(string, ...interface{})
	Fatalf(string, ...interface{})
}

Entry is a wrapper interface for a slog entry.

func WithDuration

func WithDuration(d time.Duration) Entry

WithDuration adds a time t an Entry.

func WithError

func WithError(e error) Entry

WithError adds an error to the Entry.

func WithField

func WithField(key string, value interface{}) Entry

WithField adds a field to an Entry.

func WithFields

func WithFields(f Fielder) Entry

WithFields adds fields to a log Entry.

type Fielder

type Fielder interface {
	Fields() Fields
}

Fielder is an interface for providing fields to custom types.

type Fields

type Fields map[string]interface{}

Fields represents a map of entry level data used for structured logging.

func (Fields) Fields

func (f Fields) Fields() Fields

Fields implements Fielder.

func (Fields) Get

func (f Fields) Get(name string) interface{}

Get field value by name.

type Level added in v0.2.1

type Level int

Level of severity.

const (
	InvalidLevel Level = iota - 1
	DebugLevel
	InfoLevel
	WarnLevel
	ErrorLevel
	FatalLevel
)

Log levels.

func (Level) String added in v0.2.1

func (l Level) String() string

String implementation.

type Logger

type Logger interface {

	// Entry implements the main logging interface.
	Entry

	// Activity log within th context of the activity.
	Activity(ctx context.Context, fn ActivityFunc) error

	SetLevel(l Level)
}

Logger is the generic interface for all loggers.

func Default added in v0.1.0

func Default() Logger

Default returns the default logger, if none is set Default will panic.

Directories

Path Synopsis
Package apexlog implements an apex logger wrapper for loggee.Logger
Package apexlog implements an apex logger wrapper for loggee.Logger
Package stdlog implements a loggee wrapper around the standard log package
Package stdlog implements a loggee wrapper around the standard log package

Jump to

Keyboard shortcuts

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