logging

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2025 License: Apache-2.0 Imports: 3 Imported by: 8

README

go-logging

A simple interface inspired by logrus to use in libraries, enabling easy replacement of logrus with other logging solutions.

Usage

Simply use Logger interface in your code and use dependency injection to provide logging functionality to deeper layers.

License

Apache 2.0 License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Fields

type Fields map[string]interface{}

type Level

type Level uint32
const (
	// PanicLevel level, highest level of severity. Logs and then calls panic with the
	// message passed to Debug, Info, ...
	PanicLevel Level = iota
	// FatalLevel level. Logs and then calls `logger.Exit(1)`. It will exit even if the
	// logging level is set to Panic.
	FatalLevel
	// ErrorLevel level. Logs. Used for errors that should definitely be noted.
	// Commonly used for hooks to send errors to an error tracking service.
	ErrorLevel
	// WarnLevel level. Non-critical entries that deserve eyes.
	WarnLevel
	// InfoLevel level. General operational entries about what's going on inside the
	// application.
	InfoLevel
	// DebugLevel level. Usually only enabled when debugging. Very verbose logging.
	DebugLevel
	// TraceLevel level. Designates finer-grained informational events than the Debug.
	TraceLevel
)

func ParseLevel

func ParseLevel(lvl string) (Level, error)

ParseLevel takes a string level and returns the Logrus log level constant. Borrowed from logrus.

type LimitedLogger

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

func (*LimitedLogger) Log

func (l *LimitedLogger) Log(level Level, args ...interface{})

func (*LimitedLogger) Logger

func (l *LimitedLogger) Logger() Logger

func (*LimitedLogger) WithAdditionalFields

func (l *LimitedLogger) WithAdditionalFields(fields Fields) Logger

func (*LimitedLogger) WithFields

func (l *LimitedLogger) WithFields(fields Fields) Logger

type Logger

type Logger interface {
	Log(level Level, args ...interface{})
	WithFields(fields Fields) Logger
	WithAdditionalFields(fields Fields) Logger
	Logger() Logger
}

func Limit

func Limit(logger Logger, level Level) Logger

type NoOpLogger

type NoOpLogger int

func (NoOpLogger) Log

func (n NoOpLogger) Log(level Level, args ...interface{})

func (NoOpLogger) Logger

func (n NoOpLogger) Logger() Logger

func (NoOpLogger) WithAdditionalFields

func (n NoOpLogger) WithAdditionalFields(fields Fields) Logger

func (NoOpLogger) WithFields

func (n NoOpLogger) WithFields(fields Fields) Logger

Directories

Path Synopsis
logrus module

Jump to

Keyboard shortcuts

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