logger

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2018 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoneLvl = iota
	InfoLvl
	VerboseLvl
	DebugLvl
)

Variables

This section is empty.

Functions

func Blue

func Blue(l Logger) *color.Color

func CtxWithForkedOutput

func CtxWithForkedOutput(ctx context.Context, writer io.Writer) context.Context

Returns a context containing a logger that forks all of its output to both the parent context's logger and to the given `io.Writer`

func Green

func Green(l Logger) *color.Color

func NewPrefixedWriter

func NewPrefixedWriter(prefix string, underlying io.Writer) *prefixedWriter

func Red

func Red(l Logger) *color.Color

func WithLogger

func WithLogger(ctx context.Context, logger Logger) context.Context

func Yellow

func Yellow(l Logger) *color.Color

Types

type FuncLoggerWriter

type FuncLoggerWriter struct {
	// contains filtered or unexported fields
}

func (FuncLoggerWriter) Write

func (fw FuncLoggerWriter) Write(b []byte) (int, error)

type Level

type Level int

type Logger

type Logger interface {
	// log information that we always want to show
	Infof(format string, a ...interface{})
	// log information that a tilt user might not want to see on every run, but that they might find
	// useful when debugging their Tiltfile/docker/k8s configs
	Verbosef(format string, a ...interface{})
	// log information that is likely to only be of interest to tilt developers
	Debugf(format string, a ...interface{})

	Write(level Level, s string)

	// gets an io.Writer that filters to the specified level for, e.g., passing to a subprocess
	Writer(level Level) io.Writer

	Level() Level

	SupportsColor() bool
}

Logger with better controls for levels and colors.

Note that our loggers often serve as both traditional loggers (where each call to Log() is a discrete log entry that may be emitted as JSON or with newlines) and as Writers (where each call to Write() may be part of a larger output stream, and each message may not end in a newline).

Logger implementations that bridge these two worlds should have discrete messages (like Infof) append a newline to the string before passing it to Write().

func Get

func Get(ctx context.Context) Logger

func NewFuncLogger

func NewFuncLogger(supportsColor bool, level Level, write func(level Level, b []byte) error) Logger

func NewLogger

func NewLogger(level Level, writer io.Writer) Logger

Jump to

Keyboard shortcuts

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