clog

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const BlankLine = ""

BlankLine is an empty string meant to be used in CLIMessage and CLIError construction.

Variables

This section is empty.

Functions

func Bold

func Bold(a string) string

Bold provides a convenience wrapper around color.New for brevity when logging.

func Causef

func Causef(format string, a ...interface{}) string

Causef formats according to the given format specifier and prepends a bolded "cause: " header.

func Hintf

func Hintf(format string, a ...interface{}) string

Hintf formats according to the given format specifier and prepends a bolded "hint: " header.

func Log

func Log(err error)

Log logs the given error to stderr, defaulting to "fatal" if the error is not a CLIError. If the error is a CLIError, the plain error chain is ignored and the CLIError is logged on its own.

func LogDebug

func LogDebug(header string, lines ...string)

LogDebug prints the given debug message to stderr if and only if the env var `DEBUG` is nonempty.

func LogInfo

func LogInfo(header string, lines ...string)

LogInfo prints the given info message to stderr.

func LogSuccess

func LogSuccess(header string, lines ...string)

LogSuccess prints the given info message to stderr.

func LogWarn

func LogWarn(header string, lines ...string)

LogWarn prints the given warn message to stderr.

func SetOutput

func SetOutput(w io.Writer)

SetOutput sets the package-level writer target for log functions.

func Tipf

func Tipf(format string, a ...interface{}) string

Tipf formats according to the given format specifier and prepends a bolded "tip: " header.

Types

type CLIError

type CLIError struct {
	CLIMessage
	// contains filtered or unexported fields
}

CLIError wraps a CLIMessage and allows consumers to treat it as a normal error.

func Error

func Error(header string, lines ...string) CLIError

Error creates an error with the level "error".

func Fatal

func Fatal(header string, lines ...string) CLIError

Fatal creates an error with the level "fatal".

type CLIMessage

type CLIMessage struct {
	Level  string
	Color  color.Attribute
	Header string
	Lines  []string
}

CLIMessage provides a human-readable message for CLI errors and messages.

func (CLIMessage) String

func (m CLIMessage) String() string

String formats the CLI message for consumption by a human.

Jump to

Keyboard shortcuts

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