regi

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

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

Go to latest
Published: May 13, 2025 License: MPL-2.0 Imports: 8 Imported by: 0

README

regi

A log library

Go Documentation

l := regi.Log(regi.LogfmtLogger{
    Output: regi.NewSyncWriter(os.Stderr),

    // Add some starting context.
    Context: []any{
        "t", &regi.NowValue{Format: time.TimeOnly},
    },
})

// Add some more context later.
l = regi.Set(l, "component", "foo")

// Log
l.Log("msg", "hello!")
// t=23:44:01 component=foo msg=hello!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewLogWriter

func NewLogWriter(l Log) io.Writer

func NewSyncWriter

func NewSyncWriter(w io.Writer) io.Writer

Types

type CallerValue

type CallerValue struct {
	Skip     int
	FullPath bool
}

func (*CallerValue) String

func (v *CallerValue) String() string

type ElapsedValue

type ElapsedValue struct {
	Start time.Time
}

func (*ElapsedValue) String

func (v *ElapsedValue) String() string

type JSONLogger

type JSONLogger struct {
	Output io.Writer

	Context []any
	Indent  string
}

func (*JSONLogger) Log

func (l *JSONLogger) Log(kv ...any) error

func (*JSONLogger) Set

func (l *JSONLogger) Set(kv ...any) Log

type Log

type Log interface {
	Log(kv ...any) error
}

func Set

func Set(l Log, kv ...any) Log

type LogfmtLogger

type LogfmtLogger struct {
	Output io.Writer

	Context    []any
	ContextEnd bool
}

func (*LogfmtLogger) Log

func (l *LogfmtLogger) Log(kv ...any) error

func (*LogfmtLogger) Set

func (l *LogfmtLogger) Set(kv ...any) Log

type NowValue

type NowValue struct {
	Format string
	UTC    bool
}

func (*NowValue) String

func (v *NowValue) String() string

type Setter

type Setter interface {
	Set(kv ...any) Log
}

Jump to

Keyboard shortcuts

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