logging

package
v0.19.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package logging implements the logger for the pack CLI.

Index

Constants

View Source
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 IsTerminal added in v0.18.0

func IsTerminal(w io.Writer) (uintptr, bool)

IsTerminal returns whether a writer is a terminal

func WithClock added in v0.7.0

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 added in v0.11.0

func WithVerbose() func(writers *LogWithWriters)

WithVerbose is an option used to initialize a LogWithWriters with Verbose turned on

Types

type LogWithWriters added in v0.7.0

type LogWithWriters struct {
	sync.Mutex
	log.Logger
	// contains filtered or unexported fields
}

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 added in v0.7.0

func (lw *LogWithWriters) HandleLog(e *log.Entry) error

HandleLog handles log events, printing entries appropriately

func (*LogWithWriters) IsVerbose added in v0.7.0

func (lw *LogWithWriters) IsVerbose() bool

IsVerbose returns whether verbose logging is on

func (*LogWithWriters) WantQuiet added in v0.7.0

func (lw *LogWithWriters) WantQuiet(f bool)

WantQuiet reduces the number of logs returned

func (*LogWithWriters) WantTime added in v0.7.0

func (lw *LogWithWriters) WantTime(f bool)

WantTime turns timestamps on in log entries

func (*LogWithWriters) WantVerbose added in v0.7.0

func (lw *LogWithWriters) WantVerbose(f bool)

WantVerbose increases the number of logs returned

func (*LogWithWriters) Writer added in v0.7.0

func (lw *LogWithWriters) Writer() io.Writer

Writer returns the base Writer for the LogWithWriters

func (*LogWithWriters) WriterForLevel added in v0.7.0

func (lw *LogWithWriters) WriterForLevel(level logging.Level) io.Writer

WriterForLevel returns a Writer for the given logging.Level

type LogWriter added in v0.12.0

type LogWriter struct {
	sync.Mutex
	// contains filtered or unexported fields
}

LogWriter is a writer used for logs

func NewLogWriter added in v0.12.0

func NewLogWriter(writer io.Writer, clock func() time.Time, wantTime bool) *LogWriter

NewLogWriter creates a LogWriter

func (*LogWriter) Fd added in v0.12.0

func (tw *LogWriter) Fd() uintptr

Fd returns the file descriptor of the writer. This is used to ensure it is a Console, and can therefore display streams of text

func (*LogWriter) Write added in v0.12.0

func (tw *LogWriter) Write(buf []byte) (n int, err error)

Write writes a message prepended by the time to the set io.Writer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL