logging

package
v0.0.0-...-2f2621b Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: Apache-2.0 Imports: 5 Imported by: 22

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LogLevel

type LogLevel int

LogLevel defines log levels

const (
	DEBUG LogLevel = iota
	INFO
	WARN
	ERROR
)

func (LogLevel) String

func (l LogLevel) String() string

type Logger

type Logger struct {
	Level     LogLevel
	Timestamp bool
	// contains filtered or unexported fields
}

Logger implements a simple logger with 4 levels

func NewLogger

func NewLogger(level LogLevel, target string) (*Logger, error)

NewLogger logger factory

func (*Logger) Debug

func (l *Logger) Debug(message string) error

Debug level debug

func (*Logger) Destroy

func (l *Logger) Destroy() error

Destroy cleanup resources

func (*Logger) Error

func (l *Logger) Error(message string) error

Error level error

func (*Logger) Info

func (l *Logger) Info(message string) error

Info level info

func (*Logger) Metadata

func (l *Logger) Metadata(metadata map[string]interface{})

Metadata set metadata to include in message

func (*Logger) SetConsole

func (l *Logger) SetConsole()

SetConsole sets logger target to console

func (*Logger) SetFile

func (l *Logger) SetFile(path string, permissions os.FileMode) error

SetFile sets logfile. If logger target was console, switch to file mode

func (*Logger) SetLogLevel

func (l *Logger) SetLogLevel(level LogLevel)

SetLogLevel ..

func (*Logger) Warn

func (l *Logger) Warn(message string) error

Warn level warn

type Metadata

type Metadata map[string]interface{}

Metadata convenience type for setting metadata

Jump to

Keyboard shortcuts

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