Documentation
¶
Index ¶
- Constants
- func CompleteTask(v ...interface{})
- func Debug(v ...interface{})
- func Fail(v ...interface{})
- func IsTerminal(fd int) bool
- func SetJournal(w interface{})
- func SetLevel(d displayLevel)
- func SetStandard(l *AppLogger)
- func StartTask(v ...interface{})
- func Trace(v ...interface{})
- func User(v ...interface{})
- func Warn(v ...interface{})
- func WriterIsTerminal(writer io.Writer) bool
- type AppLogger
- func (l *AppLogger) CompleteTask(v ...interface{})
- func (l *AppLogger) Debug(v ...interface{})
- func (l *AppLogger) DisplayLevel(level displayLevel)
- func (l *AppLogger) Fail(v ...interface{})
- func (l *AppLogger) JournalFile(w interface{})
- func (l *AppLogger) StartTask(v ...interface{})
- func (l *AppLogger) Trace(v ...interface{})
- func (l *AppLogger) User(v ...interface{})
- func (l *AppLogger) Warn(v ...interface{})
- func (l *AppLogger) Writer() *LoggedWriter
- type LoggedWriter
- type OptSetter
Constants ¶
const ( // DEBUG shows all DEBUG displayLevel = iota // TRACE shows application flow, suitable for support TRACE // USER shows user-appropriate messages USER // WARN shows warnings WARN // FAIL is bad FAIL // SILENT shows nothing SILENT )
Variables ¶
This section is empty.
Functions ¶
func CompleteTask ¶
func CompleteTask(v ...interface{})
CompleteTask stops the spinner and prints a newline
func Debug ¶
func Debug(v ...interface{})
Debug logs the entry and prints to stdout if level <= DEBUG
func IsTerminal ¶
IsTerminal returns true if the given file descriptor is a terminal. Swiped from golang.org/x/crypto/ssh/terminal
func SetJournal ¶
func SetJournal(w interface{})
SetJournal sets the standard logger's journal writer
func SetStandard ¶
func SetStandard(l *AppLogger)
SetStandard sets the standard logger to the supplied logger
func StartTask ¶
func StartTask(v ...interface{})
StartTask logs the entry at USER level and displays a spinner for long-running tasks
func Trace ¶
func Trace(v ...interface{})
Trace logs the entry and prints to stdout if level <= TRACE
func WriterIsTerminal ¶
WriterIsTerminal returns true if the given io.Writer converts to an *os.File and the file's fd is a terminal.
Types ¶
type AppLogger ¶
type AppLogger struct { Level displayLevel // contains filtered or unexported fields }
AppLogger is a logger with methods for displaying entries to the user after recording them to a journal.
func StandardLogger ¶
func StandardLogger() *AppLogger
StandardLogger returns the standard logger configured by the library
func (*AppLogger) CompleteTask ¶
func (l *AppLogger) CompleteTask(v ...interface{})
CompleteTask stops the spinner and prints a newline
func (*AppLogger) Debug ¶
func (l *AppLogger) Debug(v ...interface{})
Debug logs the entry and prints to stdout if level <= DEBUG
func (*AppLogger) DisplayLevel ¶
func (l *AppLogger) DisplayLevel(level displayLevel)
DisplayLevel sets the logger's display level
func (*AppLogger) Fail ¶
func (l *AppLogger) Fail(v ...interface{})
Fail logs the entry and prints to stderr if level <= FAIL
func (*AppLogger) JournalFile ¶
func (l *AppLogger) JournalFile(w interface{})
JournalFile configures the logger's journaler
func (*AppLogger) StartTask ¶
func (l *AppLogger) StartTask(v ...interface{})
StartTask logs the entry at USER level and displays a spinner for long-running tasks
func (*AppLogger) Trace ¶
func (l *AppLogger) Trace(v ...interface{})
Trace logs the entry and prints to stdout if level <= TRACE
func (*AppLogger) User ¶
func (l *AppLogger) User(v ...interface{})
User logs the entry and prints to stdout if level <= USER
func (*AppLogger) Warn ¶
func (l *AppLogger) Warn(v ...interface{})
Warn logs the entry and prints to stderr if level <= WARN
func (*AppLogger) Writer ¶
func (l *AppLogger) Writer() *LoggedWriter
Writer returns an io.Writer for injecting our logging into third-party libraries
type LoggedWriter ¶
type LoggedWriter struct {
// contains filtered or unexported fields
}
LoggedWriter implements io.Writer and is used to redirect logging from 3rd-party libraries to this library.
func Writer ¶
func Writer() *LoggedWriter
Writer returns an io.Writer for injecting our logging into 3rd-party libraries
func (*LoggedWriter) Level ¶
func (w *LoggedWriter) Level(level displayLevel) *LoggedWriter
Level optionally sets the LoggedWriter log level
func (*LoggedWriter) Prefix ¶
func (w *LoggedWriter) Prefix(prefix string) *LoggedWriter
Prefix optionally sets the LoggedWriter prefix
type OptSetter ¶
type OptSetter func(*AppLogger)
OptSetter sets logger options
func DisplayLevel ¶
func DisplayLevel(d displayLevel) OptSetter
DisplayLevel sets the logger's display level
func JournalFile ¶
func JournalFile(w interface{}) OptSetter
JournalFile configures the logger's journaler