Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaptureHandler ¶
type CaptureHandler struct {
// contains filtered or unexported fields
}
CaptureHandler stores records in memory for test assertions.
func NewCaptureHandler ¶
func NewCaptureHandler() *CaptureHandler
func (*CaptureHandler) Close ¶
func (h *CaptureHandler) Close() error
func (*CaptureHandler) Filter ¶
func (h *CaptureHandler) Filter(stream string, level Level) []Record
Filter returns records matching the given stream and minimum level.
func (*CaptureHandler) Handle ¶
func (h *CaptureHandler) Handle(r Record)
func (*CaptureHandler) Records ¶
func (h *CaptureHandler) Records() []Record
Records returns a copy of all captured records.
type ConsoleHandler ¶
type ConsoleHandler struct {
// contains filtered or unexported fields
}
ConsoleHandler writes formatted log lines to an io.Writer (typically os.Stderr).
func NewConsoleHandler ¶
func NewConsoleHandler(color bool, minLevel Level) *ConsoleHandler
NewConsoleHandler creates a handler that writes to os.Stderr. Only records at or above minLevel are written.
func NewConsoleHandlerWriter ¶
func NewConsoleHandlerWriter(w io.Writer, color bool, minLevel Level) *ConsoleHandler
NewConsoleHandlerWriter creates a handler that writes to the given writer. Useful for testing.
func (*ConsoleHandler) Close ¶
func (h *ConsoleHandler) Close() error
func (*ConsoleHandler) Handle ¶
func (h *ConsoleHandler) Handle(r Record)
type FileHandler ¶
type FileHandler struct {
// contains filtered or unexported fields
}
FileHandler writes log records to per-stream files in a directory. Files are created lazily on the first record for each stream. If combined is true, all records are also written to combined.log.
func NewFileHandler ¶
func NewFileHandler(dir string, minLevel Level, combined bool) (*FileHandler, error)
NewFileHandler creates a file handler that writes to {dir}/{stream}.log files. Only records at or above minLevel are written. If combined is true, all records are also appended to combined.log.
func (*FileHandler) Close ¶
func (h *FileHandler) Close() error
func (*FileHandler) Handle ¶
func (h *FileHandler) Handle(r Record)
type Level ¶
type Level int8
Level represents log severity.
func ParseLevel ¶
ParseLevel converts a lowercase string ("debug", "info", "error") to a Level.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger emits leveled log messages to handlers via a Registry. Create loggers through Registry.NewLogger.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds handlers and per-stream level configuration. It is the central coordinator for the logging system.
func NewRegistry ¶
NewRegistry creates a Registry with the given handlers and per-stream levels. Streams not in the levels map default to LevelInfo.