log2

package
v0.210504.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: CC0-1.0 Imports: 10 Imported by: 1

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 (self 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 (self *Log) Clone(level Level) *Log

func (*Log) Debug

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

func (*Log) Debugf

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

func (*Log) Enabled

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

func (*Log) Error

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

func (*Log) Errorf

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

func (*Log) Fatal

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

func (*Log) Fatalf

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

func (*Log) Info

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

func (*Log) Infof

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

func (*Log) Log

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

func (*Log) Logf

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

func (*Log) Printf

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

compatibility with eclipse.paho.mqtt

func (*Log) Println

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

func (*Log) SetErrorFunc

func (self *Log) SetErrorFunc(f ErrorFunc)

func (*Log) SetFlags

func (self *Log) SetFlags(f int)

func (*Log) SetLevel

func (self *Log) SetLevel(l Level)

func (*Log) SetOutput

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

func (*Log) SetPrefix

func (self *Log) SetPrefix(prefix string)

func (*Log) Stdlib

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

Jump to

Keyboard shortcuts

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