log

package module
v0.0.0-...-5b45b46 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: MIT Imports: 0 Imported by: 0

README

logger-abstract

A simple log abstraction, following a generally used pattern in loggers out there, to easily support switching logging system in mid flight.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Contextual

type Contextual interface {
	Leveled

	With(fields ...interface{}) Leveled
}

Contextual is an interface that allows context addition to a log statement before calling the final print (message/level) method.

type ContextualExtended

type ContextualExtended interface {
	LeveledExtended

	With(fields ...interface{}) LeveledExtended
}

ContextualExtended extends Contextual with Print-methods

type ContextualExtendedLogger

type ContextualExtendedLogger interface {
	Logger
	ContextualExtended
}

type ContextualLogger

type ContextualLogger interface {
	Logger
	Contextual
}

type Level

type Level int
const (
	DEBUG Level = iota
	INFO
	WARN
	ERROR
	PANIC
	FATAL
)

type Leveled

type Leveled interface {
	Standard

	Debug(args ...interface{})
	Debugf(format string, args ...interface{})
	Debugln(args ...interface{})

	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Errorln(args ...interface{})

	Info(args ...interface{})
	Infof(format string, args ...interface{})
	Infoln(args ...interface{})

	Warn(args ...interface{})
	Warnf(format string, args ...interface{})
	Warnln(args ...interface{})
}

Leleved is an interface with commonly used log level methods.

type LeveledExtended

type LeveledExtended interface {
	StandardExtended
	Leveled
}

LeveledExtended extends Leveled with Print-methods

type Logger

type Logger interface {
	Log(l Level, args ...interface{})
}

Logger is the basic interface that logs a message with a level. This is separate, since many loggers don't actually implement this method.

type Standard

type Standard interface {
	Fatal(args ...interface{})
	Fatalf(format string, args ...interface{})
	Fatalln(args ...interface{})

	Panic(args ...interface{})
	Panicf(format string, args ...interface{})
	Panicln(args ...interface{})
}

Standard is the interface used by Go's standard library's log package, except the Print functions, since those are often omitted by loggers. For a version that includes that, see thr "Extended" versions.

type StandardExtended

type StandardExtended interface {
	Standard

	Print(args ...interface{})
	Printf(format string, args ...interface{})
	Println(args ...interface{})
}

StandardExtended is like Standard, but also with print functions. The stdlib logger implements StandardExtended.

Directories

Path Synopsis
Package zap implements a mapper from "go.uber.org/zap"
Package zap implements a mapper from "go.uber.org/zap"

Jump to

Keyboard shortcuts

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