logger

package module
v0.0.0-...-7a0408f Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2024 License: BSD-2-Clause Imports: 14 Imported by: 1

README

logger

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Registry = &CompatRegistry{
	nextId:  1,
	loggers: make(map[int]CompatLogWriter),
}

Functions

func Caller

func Caller() string

func Errorf

func Errorf(format string, args ...any) error

func Format

func Format(format string, args ...any) string

func FormatDepth

func FormatDepth(depth int, format string, args ...any) string

func FuncInfo

func FuncInfo(f interface{}) string

Types

type CompatLogWriter

type CompatLogWriter interface {
	SetLevel(level LogLevel)
	Syslog(bool) error
	Level() LogLevel
	SetPrefix(prefix string)
	Packetf(format string, args ...any)
	Debugf(format string, args ...any)
	Infof(format string, args ...any)
	Warnf(format string, args ...any)
	Errorf(f string, args ...any)
	Fatalf(format string, args ...any)
	ErrFmt(format string, args ...any) error
	Prefix() string
	Write(data []byte) (int, error)
	Json(label string, data any, indent bool)
	Flush()
	SetId(id int)
	Id() int
}

func NewCompatLogWriter

func NewCompatLogWriter(level LogLevel) CompatLogWriter

func NewTestCompatLogWriter

func NewTestCompatLogWriter(t *testing.T) CompatLogWriter

type CompatRegistry

type CompatRegistry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func (*CompatRegistry) Add

func (r *CompatRegistry) Add(log CompatLogWriter)

func (*CompatRegistry) Command

func (r *CompatRegistry) Command(args []string) []string

func (*CompatRegistry) List

func (r *CompatRegistry) List() []CompatLogWriter

func (*CompatRegistry) LookupById

func (r *CompatRegistry) LookupById(id int) CompatLogWriter

func (*CompatRegistry) NewId

func (r *CompatRegistry) NewId() int

type LogLevel

type LogLevel int
const (
	LogLevel_PACKET LogLevel = iota
	LogLevel_DEBUG
	LogLevel_INFO
	LogLevel_WARN
	LogLevel_ERROR
	LogLevel_FATAL
)

func NewLogLevelFromString

func NewLogLevelFromString(s string) (LogLevel, error)

func (LogLevel) String

func (i LogLevel) String() string

type LogWriter

type LogWriter interface {
	Printf(format string, args ...any)
	Fatalf(format string, args ...any)
	SetPrefix(prefix string)
	Errorf(f string, args ...any) error
	PrettyPrint(arg interface{})
}

func NewLogWriter

func NewLogWriter() LogWriter

func NewTestLogWriter

func NewTestLogWriter(t *testing.T) LogWriter

type TestLogWriter

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

func (TestLogWriter) Errorf

func (lw TestLogWriter) Errorf(f string, args ...any) error

func (TestLogWriter) Fatalf

func (lw TestLogWriter) Fatalf(format string, args ...any)

func (TestLogWriter) PrettyPrint

func (lw TestLogWriter) PrettyPrint(arg interface{})

func (TestLogWriter) Printf

func (lw TestLogWriter) Printf(format string, args ...any)

func (TestLogWriter) SetPrefix

func (lw TestLogWriter) SetPrefix(prefix string)

Jump to

Keyboard shortcuts

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