Documentation ¶
Overview ¶
Package termlog provides facilities for logging to a terminal geared towards interactive use.
Index ¶
- Variables
- func NewContext(ctx context.Context, logger Logger) context.Context
- func SetOutput(w io.Writer)
- type Group
- type Log
- func (*Log) Color(state bool)
- func (l *Log) Enable(name string)
- func (l *Log) Group() Group
- func (l *Log) Notice(format string, args ...interface{})
- func (l *Log) NoticeAs(name string, format string, args ...interface{})
- func (l *Log) Quiet()
- func (l *Log) Say(format string, args ...interface{})
- func (l *Log) SayAs(name string, format string, args ...interface{})
- func (l *Log) Shout(format string, args ...interface{})
- func (l *Log) ShoutAs(name string, format string, args ...interface{})
- func (l *Log) Stream(header string) Stream
- func (l *Log) Warn(format string, args ...interface{})
- func (l *Log) WarnAs(name string, format string, args ...interface{})
- type LogTest
- type Logger
- type Palette
- type Stream
- type TermLog
Constants ¶
This section is empty.
Variables ¶
var DefaultPalette = Palette{ Say: color.New(), Notice: color.New(color.FgBlue), Warn: color.New(color.FgYellow), Shout: color.New(color.FgRed), Timestamp: color.New(color.FgCyan), Header: color.New(color.FgBlue), }
DefaultPalette is a sensbile default palette, with the following foreground colours:
Say: Terminal default Notice: Blue Warn: Yellow Shout: Red Timestamp: Cyan
Functions ¶
func NewContext ¶
NewContext creates a new context with an included Logger
Types ¶
type Group ¶
type Group interface { Logger Done() Quiet() }
Group is a collected group of log entries. Logs are only displayed once the Done method is called.
type Log ¶
Log is the top-level log structure
func NewLog ¶
func NewLog() *Log
NewLog creates a new Log instance and initialises it with a set of defaults.
type LogTest ¶
type LogTest struct { Log *Log // contains filtered or unexported fields }
LogTest lets test suites work with log output
type Logger ¶
type Logger interface { Say(format string, args ...interface{}) Notice(format string, args ...interface{}) Warn(format string, args ...interface{}) Shout(format string, args ...interface{}) SayAs(name string, format string, args ...interface{}) NoticeAs(name string, format string, args ...interface{}) WarnAs(name string, format string, args ...interface{}) ShoutAs(name string, format string, args ...interface{}) }
Logger logs things
func FromContext ¶
FromContext retrieves a Logger from a context. If no logger is present, we return a new silenced logger that will produce no output.
type Palette ¶
type Palette struct { Timestamp *color.Color Say *color.Color Notice *color.Color Warn *color.Color Shout *color.Color Header *color.Color }
Palette defines the colour of output