Documentation
¶
Overview ¶
Package log is a wrapper around colorizing the log output. It has functions that allow you to simply write output to the screen for various scenarios.
- Start ==> Blue/Primary (action starting) - Success ✓ Green/Secondary (action succeeded) - Info → Cyan/Primary (informational) - Debug ··· Magenta (debugging, verbose only in spirit) - Warn ⚠ Yellow (to stderr, non-fatal) - Error ✗ Red/Destructive (to stderr, fatal-ish)
Index ¶
- Variables
- func Debug(format string, a ...any)
- func Error(format string, a ...any)
- func FileLogActive() bool
- func Info(format string, a ...any)
- func Message(format string, a ...any)
- func ResetWriters()
- func SetFileLog(f *os.File)
- func SetWriters(out, errOut io.Writer)
- func Start(format string, a ...any)
- func Success(format string, a ...any)
- func Verbose(v bool, format string, a ...any)
- func Warn(format string, a ...any)
- type CMDErrorWriter
- type CMDWriter
Constants ¶
This section is empty.
Variables ¶
Out and Err are writers used for normal and error output. Tests may replace them.
Functions ¶
func FileLogActive ¶ added in v1.52.0
func FileLogActive() bool
FileLogActive reports whether file tee output is currently enabled.
func ResetWriters ¶
func ResetWriters()
ResetWriters restores writers to their default stdout/stderr.
func SetFileLog ¶ added in v1.52.0
SetFileLog tees plain (ANSI-stripped) copies of all subsequent log output to f. Pass nil to disable. The caller owns f: it is never closed here. Callers must hold no locks; this takes mu.
func SetWriters ¶
SetWriters allows tests to replace the output writers. It also propagates to theme writers so banner messages stay unified.
Types ¶
type CMDErrorWriter ¶
type CMDErrorWriter struct{}
CMDErrorWriter is an io.Writer that prints to the terminal using Error.
func ErrorWriter ¶
func ErrorWriter() *CMDErrorWriter
ErrorWriter returns a new LogErrorWriter for use as an io.Writer for error output.