logging

package
v1.5.5 Latest Latest
Warning

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

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

Documentation

Overview

Package logging implements the logger for the pack CLI.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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

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

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 logging.Level) io.Writer

WriterForLevel returns a Writer for the given logging.Level

type LogWriter

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

LogWriter is a writer used for logs

func NewLogWriter

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

NewLogWriter creates a LogWriter

func (*LogWriter) Fd

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

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