Documentation
¶
Index ¶
- Constants
- type CondLogger
- func (cl *CondLogger) Critical(s string, v ...interface{}) error
- func (cl *CondLogger) Debug(s string, v ...interface{}) error
- func (cl *CondLogger) Error(s string, v ...interface{}) error
- func (cl *CondLogger) Info(s string, v ...interface{}) error
- func (cl *CondLogger) IsSilent() bool
- func (cl *CondLogger) Log(verb int, format string, v ...interface{}) error
- func (cl *CondLogger) Warning(s string, v ...interface{}) error
- type LogWriter
- type WriteCloser
Constants ¶
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 )
const MAX_LOG_QLEN = 128
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).
type WriteCloser ¶ added in v1.22.0
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.