Help us shape the future of Go! Take the 2026 Go Developer Survey

log

package
v1.30.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SILENT completely suppresses all output, including errors from third-party libraries.
	// Pass -verbosity 60 to enable.
	SILENT   = 60
	CRITICAL = 50
	ERROR    = 40
	WARNING  = 30
	INFO     = 20
	DEBUG    = 10
	NOTSET   = 0
)
View Source
const MAX_LOG_QLEN = 128
View Source
const QUEUE_SHUTDOWN_TIMEOUT = 500 * time.Millisecond

Variables

This section is empty.

Functions

This section is empty.

Types

type CondLogger

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

func NewCondLogger

func NewCondLogger(logger *log.Logger, verbosity int) *CondLogger

func (*CondLogger) Critical

func (cl *CondLogger) Critical(s string, v ...interface{}) error

func (*CondLogger) Debug

func (cl *CondLogger) Debug(s string, v ...interface{}) error

func (*CondLogger) Error

func (cl *CondLogger) Error(s string, v ...interface{}) error

func (*CondLogger) Info

func (cl *CondLogger) Info(s string, v ...interface{}) error

func (*CondLogger) IsSilent added in v1.22.0

func (cl *CondLogger) IsSilent() bool

IsSilent returns true when all output should be suppressed (verbosity >= SILENT).

func (*CondLogger) Log

func (cl *CondLogger) Log(verb int, format string, v ...interface{}) error

Log writes a message at the given verbosity level. If the current verbosity is >= SILENT, nothing is written.

func (*CondLogger) Warning

func (cl *CondLogger) Warning(s string, v ...interface{}) error

type LogWriter

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

LogWriter is an asynchronous io.WriteCloser that queues log lines into a buffered channel and drains them in a dedicated goroutine. This keeps the hot path (logging inside a handler goroutine) allocation-free and contention-free with respect to the underlying writer (usually os.Stderr).

func (*LogWriter) Close

func (lw *LogWriter) Close()

func (*LogWriter) Write

func (lw *LogWriter) Write(p []byte) (int, error)

type WriteCloser added in v1.22.0

type WriteCloser interface {
	io.Writer
	Close()
}

WriteCloser is the common interface for LogWriter and nullLogWriter.

func NewLogWriter

func NewLogWriter(dst io.Writer) WriteCloser

NewLogWriter returns a WriteCloser that asynchronously forwards log lines to dst. When dst is io.Discard (i.e. verbosity >= SILENT), a zero-cost nullLogWriter is returned — no goroutine is started, no allocations occur.

Jump to

Keyboard shortcuts

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