Documentation ¶
Index ¶
Constants ¶
const ( AnsiReset = "\033[0m" AnsiDim = "\033[0;2m" AnsiYellow = "\033[1;33m" AnsiRed = "\033[1;31m" )
Variables ¶
var ( SetColor = map[Level]string{ "debug": AnsiDim, "info": AnsiReset, "warning": AnsiYellow, "error": AnsiRed, } ResetColor = AnsiReset )
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 logs with the debug log level. This is the finest and least-consequential log type. Debugf(format string, args ...interface{}) // Infof logs with the Info log level. Infof(format string, args ...interface{}) // Warningf logs with the Warning log level. Warningf(format string, args ...interface{}) // Errorf logs with the Error log level. Errorf(format string, args ...interface{}) // Writef allows logging with convenient programmatic setting of level Writef(level Level, 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 ¶
NewGoLogger writes to the Go log facility. If no logger is passed, the standard logger is used.
func NewTestLogger ¶
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.