Documentation ¶
Overview ¶
Package logging implements the logger for the pack CLI.
Package logging defines the minimal interface that loggers must support to be used by client.
Index ¶
- Constants
- func GetWriterForLevel(logger Logger, level Level) io.Writer
- func IsQuiet(logger Logger) bool
- func ScanLinesKeepNewLine(data []byte, atEOF bool) (advance int, token []byte, err error)
- func Tip(l Logger, format string, v ...interface{})
- func WithClock(clock func() time.Time) func(writers *LogWithWriters)
- func WithVerbose() func(writers *LogWithWriters)
- type Level
- type LogWithWriters
- func (lw *LogWithWriters) HandleLog(e *log.Entry) error
- func (lw *LogWithWriters) IsVerbose() bool
- func (lw *LogWithWriters) WantQuiet(f bool)
- func (lw *LogWithWriters) WantTime(f bool)
- func (lw *LogWithWriters) WantVerbose(f bool)
- func (lw *LogWithWriters) Writer() io.Writer
- func (lw *LogWithWriters) WriterForLevel(level Level) io.Writer
- type Logger
- type PrefixWriter
- type PrefixWriterOption
Constants ¶
const ( // InvalidFileDescriptor based on https://golang.org/src/os/file_unix.go?s=2183:2210#L57 InvalidFileDescriptor = ^(uintptr(0)) )
Variables ¶
This section is empty.
Functions ¶
func GetWriterForLevel ¶
GetWriterForLevel retrieves the appropriate Writer for the log level provided.
See isSelectableWriter
func ScanLinesKeepNewLine ¶
A customized implementation of bufio.ScanLines that preserves new line characters.
func WithClock ¶
func WithClock(clock func() time.Time) func(writers *LogWithWriters)
WithClock is an option used to initialize a LogWithWriters with a given clock function
func WithVerbose ¶
func WithVerbose() func(writers *LogWithWriters)
WithVerbose is an option used to initialize a LogWithWriters with Verbose turned on
Types ¶
type LogWithWriters ¶
LogWithWriters is a logger used with the pack CLI, allowing users to print logs for various levels, including Info, Debug and Error
func NewLogWithWriters ¶
func NewLogWithWriters(stdout, stderr io.Writer, opts ...func(*LogWithWriters)) *LogWithWriters
NewLogWithWriters creates a logger to be used with pack CLI.
func (*LogWithWriters) HandleLog ¶
func (lw *LogWithWriters) HandleLog(e *log.Entry) error
HandleLog handles log events, printing entries appropriately
func (*LogWithWriters) IsVerbose ¶
func (lw *LogWithWriters) IsVerbose() bool
IsVerbose returns whether verbose logging is on
func (*LogWithWriters) WantQuiet ¶
func (lw *LogWithWriters) WantQuiet(f bool)
WantQuiet reduces the number of logs returned
func (*LogWithWriters) WantTime ¶
func (lw *LogWithWriters) WantTime(f bool)
WantTime turns timestamps on in log entries
func (*LogWithWriters) WantVerbose ¶
func (lw *LogWithWriters) WantVerbose(f bool)
WantVerbose increases the number of logs returned
func (*LogWithWriters) Writer ¶
func (lw *LogWithWriters) Writer() io.Writer
Writer returns the base Writer for the LogWithWriters
func (*LogWithWriters) WriterForLevel ¶
func (lw *LogWithWriters) WriterForLevel(level Level) io.Writer
WriterForLevel returns a Writer for the given Level
type Logger ¶
type Logger interface { Debug(msg string) Debugf(fmt string, v ...interface{}) Info(msg string) Infof(fmt string, v ...interface{}) Warn(msg string) Warnf(fmt string, v ...interface{}) Error(msg string) Errorf(fmt string, v ...interface{}) Writer() io.Writer IsVerbose() bool }
Logger defines behavior required by a logging package used by pack libraries
func NewSimpleLogger ¶
NewSimpleLogger creates a simple logger for the pack library.
type PrefixWriter ¶
type PrefixWriter struct {
// contains filtered or unexported fields
}
PrefixWriter is a buffering writer that prefixes each new line. Close should be called to properly flush the buffer.
func NewPrefixWriter ¶
func NewPrefixWriter(w io.Writer, prefix string, opts ...PrefixWriterOption) *PrefixWriter
NewPrefixWriter writes by w will be prefixed
func (*PrefixWriter) Close ¶
func (w *PrefixWriter) Close() error
Close writes any pending data in the buffer
type PrefixWriterOption ¶
type PrefixWriterOption func(c *PrefixWriter)
func WithReaderFactory ¶
func WithReaderFactory(factory func(data []byte) io.Reader) PrefixWriterOption