Documentation ¶
Overview ¶
Package logging provides a common Logger interface together with some infrastructure code. Integrations with other logging frameworks are provided in subpackages.
Index ¶
- func TestWriter(delegate testDelegate) io.Writer
- type DefaultLoggerFactory
- type ErrorLogger
- type ErrorWriter
- type Logger
- type LoggerFactory
- type LoggerWriter
- func (l *LoggerWriter) Debug(parameters ...interface{})
- func (l *LoggerWriter) Error(parameters ...interface{})
- func (l *LoggerWriter) Info(parameters ...interface{})
- func (l *LoggerWriter) Printf(format string, parameters ...interface{})
- func (l *LoggerWriter) Trace(parameters ...interface{})
- func (l *LoggerWriter) Warn(parameters ...interface{})
- type PrintLogger
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TestWriter ¶
TestWriter produces an io.Writer that outputs to testDelegate.Log with a single string. Use this function to create a test logger: &LoggerWriter{TestWriter(t)}.
Types ¶
type DefaultLoggerFactory ¶
DefaultLoggerFactory provides a simple way to create Logger instances adapted onto log.Logger.
type ErrorLogger ¶
type ErrorLogger interface {
Error(parameters ...interface{})
}
ErrorLogger provides the interface for outputting errors to a log sink
type ErrorWriter ¶
type ErrorWriter struct {
ErrorLogger
}
ErrorWriter adapts io.Writer onto ErrorLogger so that all output from Write() goes to Error(...). This is useful for HTTP error logs.
type Logger ¶
type Logger interface { ErrorLogger Trace(parameters ...interface{}) Debug(parameters ...interface{}) Info(parameters ...interface{}) Warn(parameters ...interface{}) }
Logger defines the expected methods to be provided by logging infrastructure. This interface uses different idioms than those used by golang's stdlib Logger.
func DefaultLogger ¶
func DefaultLogger() Logger
func TestLogger ¶
func TestLogger(delegate testDelegate) Logger
TestLogger is a convenience for &LoggerWriter{TestWriter(t)}
type LoggerFactory ¶
type LoggerFactory interface { // Returns a new, distinct Logger instance using this factory's configuration NewLogger(name string) (Logger, error) }
LoggerFactory represents the behavior of a type which can create a Logger. Integrations must supply an implementation of this interface, typically configured through JSON.
type LoggerWriter ¶
LoggerWriter is a default, built-in logging type that simply writes output to an embedded io.Writer. This is a "poor man's" Logger. It should normally only be used in utilities and tests.
This logger will panic if any io errors occur.
func (*LoggerWriter) Debug ¶
func (l *LoggerWriter) Debug(parameters ...interface{})
func (*LoggerWriter) Error ¶
func (l *LoggerWriter) Error(parameters ...interface{})
func (*LoggerWriter) Info ¶
func (l *LoggerWriter) Info(parameters ...interface{})
func (*LoggerWriter) Printf ¶
func (l *LoggerWriter) Printf(format string, parameters ...interface{})
func (*LoggerWriter) Trace ¶
func (l *LoggerWriter) Trace(parameters ...interface{})
func (*LoggerWriter) Warn ¶
func (l *LoggerWriter) Warn(parameters ...interface{})
type PrintLogger ¶
type PrintLogger struct {
Delegate Logger
}
PrintLogger exposes a Printf method for infrastructure that uses that method for logging.
func (PrintLogger) Printf ¶
func (printLogger PrintLogger) Printf(format string, parameters ...interface{})