solog

package module
v0.0.0-...-dd6550e Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 9 Imported by: 0

README

solog

Fast, structured, leveled logging in Go.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Colors = [...]*color.Color{
	TraceILevel: color.New(color.FgWhite),
	DebugLevel:  color.New(color.FgWhite),
	InfoLevel:   color.New(color.FgBlue),
	WarnLevel:   color.New(color.FgYellow),
	ErrorLevel:  color.New(color.FgRed),
	FatalLevel:  color.New(color.FgRed),
}
View Source
var Strings = [...]string{
	TraceILevel: "•",
	DebugLevel:  "•",
	InfoLevel:   "•",
	WarnLevel:   "•",
	ErrorLevel:  "⨯",
	FatalLevel:  "⨯",
}

Functions

This section is empty.

Types

type ConsoleOutput

type ConsoleOutput struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

This is a struct for a console output type

func NewConsoleOutput

func NewConsoleOutput(w io.Writer) *ConsoleOutput

func (*ConsoleOutput) Write

func (c *ConsoleOutput) Write(entry *Entry) error

type Entry

type Entry struct {
	Time    time.Time
	Level   Level
	Message string
	Context map[string]interface{}
}

type FileOutput

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

func (FileOutput) Write

func (f FileOutput) Write(entry *Entry) error

type ILogger

type ILogger interface {
	Trace(message string)
	Tracef(format string, args ...interface{})
	Debug(message string)
	Debugf(format string, args ...interface{})
	Info(message string)
	Infof(format string, args ...interface{})
	Warn(message string)
	Warnf(format string, args ...interface{})
	Error(message string)
	Errorf(format string, args ...interface{})
	Fatal(message string)
	Fatalf(format string, args ...interface{})
}

type Level

type Level int32
const (
	// TraceILevel is for logging very low-level library information
	TraceILevel Level = iota
	// Debug is for logging low-level library information
	DebugLevel
	// InfoLevel is for logging normal library operation
	InfoLevel
	// WarnLevel is for logging potential errors library operation
	WarnLevel
	// ErrorLevel is for logging abnormal, but non-fatal library operation
	ErrorLevel
	// FatalLevel is for fatal errors.
	FatalLevel
)

func (*Level) Get

func (l *Level) Get() Level

Get retrieves the current level value

func (*Level) Set

func (l *Level) Set(level Level)

Set updates the current level to the supplied value.

func (*Level) String

func (l *Level) String() string

String retrieves the string representation of the current level

type Logger

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

func NewLogger

func NewLogger(level Level, output Output) *Logger

func (*Logger) Debug

func (l *Logger) Debug(message string)

func (*Logger) Debugf

func (l *Logger) Debugf(format string, args ...interface{})

func (*Logger) Error

func (l *Logger) Error(message string)

func (*Logger) Errorf

func (l *Logger) Errorf(format string, args ...interface{})

func (*Logger) Fatal

func (l *Logger) Fatal(message string)

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, args ...interface{})

func (*Logger) Info

func (l *Logger) Info(message string)

func (*Logger) Infof

func (l *Logger) Infof(format string, args ...interface{})

func (*Logger) Trace

func (l *Logger) Trace(message string)

func (*Logger) Tracef

func (l *Logger) Tracef(format string, args ...interface{})

func (*Logger) Warn

func (l *Logger) Warn(message string)

func (*Logger) Warnf

func (l *Logger) Warnf(format string, args ...interface{})

type Output

type Output interface {
	// This function takes an entry as an argument and returns an error
	Write(entry *Entry) error
}

This is an interface for an output type

Jump to

Keyboard shortcuts

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