logging

package
v2.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2024 License: Apache-2.0 Imports: 5 Imported by: 43

Documentation

Overview

Package logging provides a simple logger interface and implementations

Index

Constants

View Source
const (
	// LEVEL_DEBUG = 0
	LEVEL_DEBUG = iota
	// LEVEL_INFO = 1
	LEVEL_INFO
	// LEVEL_WARNING = 2
	LEVEL_WARNING
	// LEVEL_ERROR = 3
	LEVEL_ERROR
	// LEVEL_CRITICAL = 4
	LEVEL_CRITICAL
)

Variables

View Source
var (
	// ErrInvalidLogLevel is used when an invalid log level has been used.
	ErrInvalidLogLevel = errors.New("invalid log level")

	// NoOp is the NO-OP logger
	NoOp, _ = NewLogger("CRITICAL", io.Discard, "")
)

Functions

This section is empty.

Types

type BasicLogger

type BasicLogger struct {
	Level  int
	Prefix string
	Logger *log.Logger
}

func NewLogger

func NewLogger(level string, out io.Writer, prefix string) (BasicLogger, error)

NewLogger creates and returns a Logger object

func (BasicLogger) Critical

func (l BasicLogger) Critical(v ...interface{})

Critical logs a message using CRITICAL as log level.

func (BasicLogger) Debug

func (l BasicLogger) Debug(v ...interface{})

Debug logs a message using DEBUG as log level.

func (BasicLogger) Error

func (l BasicLogger) Error(v ...interface{})

Error logs a message using ERROR as log level.

func (BasicLogger) Fatal

func (l BasicLogger) Fatal(v ...interface{})

Fatal is equivalent to l.Critical(fmt.Sprint()) followed by a call to os.Exit(1).

func (BasicLogger) Info

func (l BasicLogger) Info(v ...interface{})

Info logs a message using INFO as log level.

func (BasicLogger) Warning

func (l BasicLogger) Warning(v ...interface{})

Warning logs a message using WARNING as log level.

type Logger

type Logger interface {
	Debug(v ...interface{})
	Info(v ...interface{})
	Warning(v ...interface{})
	Error(v ...interface{})
	Critical(v ...interface{})
	Fatal(v ...interface{})
}

Logger collects logging information at several levels

Jump to

Keyboard shortcuts

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