plog

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLevels = "PFEWID"
View Source
const DefaultLogFormat = "%s (%d) %c %v: %s"
View Source
const DefaultTimeFormat = "2006-01-02 15:04:05.000000"

Variables

View Source
var Default = New()
View Source
var ErrorStackTrace = false

Functions

func Err

func Err(err error) error

func Errorf

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

func Printf

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

func Println

func Println(a ...any)

Types

type ErrStack

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

func (ErrStack) Error

func (e ErrStack) Error() string

func (ErrStack) Stack

func (e ErrStack) Stack() []byte

type Formatter

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

func NewFormatter

func NewFormatter(format, time, level string) *Formatter

func (*Formatter) Bytes

func (f *Formatter) Bytes(l Log) []byte

func (*Formatter) String

func (f *Formatter) String(l Log) (line string)

type Level

type Level int
const (
	Panic Level = iota
	Fatal
	Error
	Warning
	Info
	Debug
)

type Log

type Log struct {
	Level   Level
	Pid     int
	Scopes  []string
	Time    time.Time
	Message string
	Stack   []byte
	Errors  []error
}

type Logger

type Logger interface {
	Out(Output) Logger
	Type(any) Logger
	Scope(string, ...any) Logger
	Set(ctx *context.Context) Logger
	Msg(string) Logger
	P() Logger
	F() Logger
	E() Logger
	W() Logger
	I() Logger
	D() Logger
	Flush()
	Printf(string, ...any)
	Println(...any)
}

func Get

func Get(ctx context.Context) Logger

func New

func New() Logger

func Scope

func Scope(format string, args ...any) Logger

func Type

func Type(a any) Logger

type Output

type Output func(Log)
var DefaultOutput Output = func(log Log) {
	bytes := DefaultFormatter.Bytes(log)
	_, _ = os.Stderr.Write(bytes)
}

Jump to

Keyboard shortcuts

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