log2

package
v0.220327.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Overview

Package log2 solves these issues: - log level filtering, e.g. show debug messages in internal tests only - safe concurrent change of log level

Primary goal was to run parallel tests and log into t.Logf() safely, and TBH, would have been enough to pass around explicit stdlib *log.Logger. Well, log levels is just a cherry on top.

Index

Constants

View Source
const (
	// type specified here helped against accidentally passing flags as level
	Lmicroseconds     int = log.Lmicroseconds
	Lshortfile        int = log.Lshortfile
	LStdFlags         int = log.Ltime | Lshortfile
	LInteractiveFlags int = log.Ltime | Lshortfile | Lmicroseconds
	LServiceFlags     int = Lshortfile
	LTestFlags        int = Lshortfile | Lmicroseconds
)
View Source
const (
	LError = iota
	LInfo
	LDebug
	LAll = math.MaxInt32
)
View Source
const ContextKey = "run/log"

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorFunc

type ErrorFunc func(error)

type FmtFunc

type FmtFunc func(format string, args ...interface{})

type FmtFuncWriter

type FmtFuncWriter struct{ FmtFunc }

func (FmtFuncWriter) Write

func (ffw FmtFuncWriter) Write(b []byte) (int, error)

type Level

type Level int32

type Log

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

func ContextValueLogger

func ContextValueLogger(ctx context.Context) *Log

func NewFunc

func NewFunc(f FmtFunc, level Level) *Log

func NewStderr

func NewStderr(level Level) *Log

func NewTest

func NewTest(t testing.TB, level Level) *Log

func NewWriter

func NewWriter(w io.Writer, level Level) *Log

func (*Log) Clone

func (lg *Log) Clone(level Level) *Log

func (*Log) Debug

func (lg *Log) Debug(args ...interface{})

func (*Log) Debugf

func (lg *Log) Debugf(format string, args ...interface{})

func (*Log) Enabled

func (lg *Log) Enabled(level Level) bool

func (*Log) Error

func (lg *Log) Error(args ...interface{})

func (*Log) Errorf

func (lg *Log) Errorf(format string, args ...interface{})

func (*Log) Fatal

func (lg *Log) Fatal(args ...interface{})

func (*Log) Fatalf

func (lg *Log) Fatalf(format string, args ...interface{})

func (*Log) Info

func (lg *Log) Info(args ...interface{})

func (*Log) Infof

func (lg *Log) Infof(format string, args ...interface{})

func (*Log) Log

func (lg *Log) Log(level Level, s string)

func (*Log) Logf

func (lg *Log) Logf(level Level, format string, args ...interface{})

func (*Log) Printf

func (lg *Log) Printf(format string, args ...interface{})

compatibility with eclipse.paho.mqtt

func (*Log) Println

func (lg *Log) Println(args ...interface{})

func (*Log) SetErrorFunc

func (lg *Log) SetErrorFunc(f ErrorFunc)

func (*Log) SetFlags

func (lg *Log) SetFlags(f int)

func (*Log) SetLevel

func (lg *Log) SetLevel(l Level)

func (*Log) SetOutput

func (lg *Log) SetOutput(w io.Writer)

func (*Log) SetPrefix

func (lg *Log) SetPrefix(prefix string)

func (*Log) Stdlib

func (lg *Log) Stdlib() *log.Logger

Jump to

Keyboard shortcuts

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