elalog

package
v0.8.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KBSize = 1024 << (10 * iota)
	MBSize
	GBSize
)
View Source
const (
	// Llongfile modifies the logger output to include full path and line number
	// of the logging callsite, e.g. /a/b/c/main.go:123.
	Llongfile uint32 = 1 << iota

	// Lshortfile modifies the logger output to include filename and line number
	// of the logging callsite, e.g. main.go:123.  Overrides Llongfile.
	Lshortfile
)

Flags to modify Backend's behavior.

Variables

This section is empty.

Functions

func NewFileWriter

func NewFileWriter(path string, maxFileSize, maxFolderSize int64) *fileWriter

Types

type Backend

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

Backend is a logging backend. Subsystems created from the backend write to the backend's Writer. Backend provides atomic writes to the Writer from all subsystems.

func NewBackend

func NewBackend(w io.Writer, flags ...uint32) *Backend

NewBackend creates a logger backend from a Writer.

func (*Backend) Logger

func (b *Backend) Logger(subsystemTag string, level Level) Logger

Logger returns a new logger for a particular subsystem that writes to the Backend b. A tag describes the subsystem and is included in all log messages. The logger uses the info verbosity level by default.

type Level

type Level uint32

Level is the level at which a logger is configured. All messages sent to a level which is below the current level are filtered.

const (
	LevelDebug Level = iota
	LevelInfo
	LevelWarn
	LevelError
	LevelFatal
	LevelOff
)

Level constants.

func LevelFromString

func LevelFromString(s string) (l Level, ok bool)

LevelFromString returns a level based on the input string s. If the input can't be interpreted as a valid log level, the info level and false is returned.

func (Level) String

func (l Level) String() string

String returns the tag of the logger used in log messages, or "OFF" if the level will not produce any log output.

type Logger

type Logger interface {
	// Debugf formats message according to format specifier and writes to
	// log with LevelDebug.
	Debugf(format string, params ...interface{})

	// Infof formats message according to format specifier and writes to
	// log with LevelInfo.
	Infof(format string, params ...interface{})

	// Warnf formats message according to format specifier and writes to
	// to log with LevelWarn.
	Warnf(format string, params ...interface{})

	// Errorf formats message according to format specifier and writes to
	// to log with LevelError.
	Errorf(format string, params ...interface{})

	// Fatalf formats message according to format specifier and writes to
	// log with LevelFatal.
	Fatalf(format string, params ...interface{})

	// Debug formats message using the default formats for its operands
	// and writes to log with LevelDebug.
	Debug(v ...interface{})

	// Info formats message using the default formats for its operands
	// and writes to log with LevelInfo.
	Info(v ...interface{})

	// Warn formats message using the default formats for its operands
	// and writes to log with LevelWarn.
	Warn(v ...interface{})

	// Error formats message using the default formats for its operands
	// and writes to log with LevelError.
	Error(v ...interface{})

	// Fatal formats message using the default formats for its operands
	// and writes to log with LevelFatal.
	Fatal(v ...interface{})

	// Level returns the current logging level.
	Level() Level

	// SetLevel changes the logging level to the passed level.
	SetLevel(level Level)
}

Logger is an interface which describes a level-based logger. A default implementation of Logger is implemented by this package and can be created by calling (*Backend).Logger.

var Disabled Logger

Disabled is a Logger that will never output anything.

Jump to

Keyboard shortcuts

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