Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BufferWriter ¶
BufferWriter provides a writer that records all log messages. This logger is most useful for tests.
func NewBufferWriter ¶
func NewBufferWriter() BufferWriter
type Config ¶
type Config struct { // Level sets the minimum log level for the logger. Level Level `json:"level"` // Destination is the place the logger writes to. Destination Destination `json:"destination"` // T is the Go test for logging purposes. T *testing.T `json:"-" yaml:"-"` // Stdout is the standard output used by the DestinationStdout destination. If not set, os.Stdout is used. Stdout io.Writer `json:"-" yaml:"-"` }
Config is the configuration for the logger.
type Destination ¶
type Destination string
Destination is the place a LogWriter writes to.
const ( // DestinationStdout writes to the standard output. DestinationStdout Destination = "stdout" // DestinationTest writes the logs to the *testing.T facility. DestinationTest Destination = "test" )
func (Destination) Validate ¶
func (d Destination) Validate() error
type Labels ¶
Labels are applied to a message to indicate where they are coming from or other relevant data.
type Level ¶
type Level string
Level is the logging level.
const ( // LevelDebug logs for debugging purposes. These logs are likely to contain excessive amounts of information. LevelDebug Level = "debug" // LevelInfo logs informational messages. LevelInfo Level = "info" // LevelWarning logs warning messages. LevelWarning Level = "warning" // LevelError logs error messages. LevelError Level = "error" )
func (Level) ShouldPrint ¶
ShouldPrint returns true if the a message at messageLevel should be printed if l is the current minimum level.
type Logger ¶
type Logger interface { Debugf(format string, args ...interface{}) Infof(format string, args ...interface{}) Warningf(format string, args ...interface{}) Errorf(format string, args ...interface{}) // WithLabel creates a child logger with this label attached. WithLabel(name string, value string) Logger }
Logger provides pluggable logging for Arcalot.
func NewGoLogger ¶ added in v1.2.0
NewGoLogger writes to the Go log facility. If no logger is passed, the standard logger is used.
func NewTestLogger ¶ added in v1.2.0
NewTestLogger creates a logger that writes to the Go test output.
type Message ¶
type Message struct { Timestamp time.Time `json:"timestamp"` Level Level `json:"level"` Labels Labels `json:"labels"` Message string `json:"message"` }
Message is a single log message.
type Writer ¶
type Writer interface { // Write writes a message to the output. Write(Message) error // Rotate gets called if logs need to be rotated. Rotate() io.Closer }
Writer is an abstraction over the possible logging targets.
func NewGoLogWriter ¶
NewGoLogWriter creates a log writer that writes to the Go log facility. The optional logger parameter can be used to pass one scoped logger, otherwise the global logger is used. If multiple loggers are passed the function will panic.
func NewTestWriter ¶
NewTestWriter returns a writer that logs via the Go test facility.