logger

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogLevelInfo  = "info"
	LogLevelDebug = "debug"
	LogLevelTrace = "trace"
	LogLevelWarn  = "warn"
	LogLevelError = "error"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CharmLogger

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

CharmLogger is a charms/lipgloss based logger

func (*CharmLogger) Debug

func (l *CharmLogger) Debug(message string, keyvals ...any)

func (*CharmLogger) Debugf

func (l *CharmLogger) Debugf(format string, keyvals ...any)

func (*CharmLogger) Error

func (l *CharmLogger) Error(message string, keyvals ...any)

func (*CharmLogger) Fatal

func (l *CharmLogger) Fatal(message string, keyvals ...any)

func (*CharmLogger) Info

func (l *CharmLogger) Info(message string, keyvals ...any)

func (*CharmLogger) Infof

func (l *CharmLogger) Infof(format string, keyvals ...any)

func (*CharmLogger) IsDebug

func (l *CharmLogger) IsDebug() bool

func (*CharmLogger) IsError

func (l *CharmLogger) IsError() bool

func (*CharmLogger) IsInfo

func (l *CharmLogger) IsInfo() bool

func (*CharmLogger) IsTrace

func (l *CharmLogger) IsTrace() bool

func (*CharmLogger) IsWarn

func (l *CharmLogger) IsWarn() bool

func (*CharmLogger) Level

func (l *CharmLogger) Level() string

func (*CharmLogger) Output

func (l *CharmLogger) Output() io.Writer

func (*CharmLogger) Print

func (l *CharmLogger) Print(message string, keyvals ...any)

func (*CharmLogger) SetInteractive

func (l *CharmLogger) SetInteractive(interactive string, isTerminal bool)

func (*CharmLogger) SetLevel

func (l *CharmLogger) SetLevel(level string) error

func (*CharmLogger) SetOutput

func (l *CharmLogger) SetOutput(w io.Writer)

func (*CharmLogger) StandardWriter

func (l *CharmLogger) StandardWriter() io.Writer

func (*CharmLogger) Trace

func (l *CharmLogger) Trace(message string, keyvals ...any)

func (*CharmLogger) Warn

func (l *CharmLogger) Warn(message string, keyvals ...any)

func (*CharmLogger) WithPrefix

func (l *CharmLogger) WithPrefix(prefix string) Logger

type Logger

type Logger interface {
	// Set the logger level
	SetLevel(level string) error

	Level() string

	// Set the logger output
	SetOutput(w io.Writer)

	Output() io.Writer

	// Print prints a log message
	Print(message string, keyvals ...any)
	// Info logs to info level
	Info(message string, keyvals ...any)
	// Debug logs to debug level
	Debug(message string, keyvals ...any)
	// Error logs to error level
	Error(message string, keyvals ...any)
	// Fatal logs to fatal level
	Fatal(message string, keyvals ...any)
	// Warn logs to warn level
	Warn(message string, keyvals ...any)
	// Trace logs to trace level
	Trace(message string, keyvals ...any)
	// Infof logs formatted info level
	Infof(format string, keyvals ...any)
	// Debugf logs formatted debug level
	Debugf(format string, keyvals ...any)

	StandardWriter() io.Writer

	IsInfo() bool
	IsDebug() bool
	IsError() bool
	IsTrace() bool
	IsWarn() bool

	WithPrefix(string) Logger

	SetInteractive(string, bool)
}

Logger defines a abstract logger that can be used to log to the output

func New

func New(w io.Writer, level string) Logger

func NewTestLogger

func NewTestLogger(t *testing.T) Logger

Logger that sends all output to a string buffer the captured log output can be retrieved by accessing the string buffer at LogOutput In the instance of a test failure, the log output is written to StdOut

type NullLogger

type NullLogger struct {
	Logger
	LogOutput *strings.Builder
}

Jump to

Keyboard shortcuts

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