Documentation
¶
Index ¶
- Variables
- type FunLogger
- func (l *FunLogger) Check(format string, a ...any)
- func (l *FunLogger) Debug(format string, a ...any)
- func (l *FunLogger) Error(err error)
- func (l *FunLogger) Exit(code int)
- func (l *FunLogger) Info(format string, a ...any)
- func (l *FunLogger) Loading(format string, a ...any) context.CancelCauseFunc
- func (l *FunLogger) SetVerbosity(v Verbosity)
- func (l *FunLogger) Trace(format string, a ...any)
- func (l *FunLogger) Warning(format string, a ...any)
- type Logger
- type Verbosity
Constants ¶
This section is empty.
Variables ¶
var ErrLoadingFailed = errors.New("loading failed")
ErrLoadingFailed is the sentinel cause passed to a Loading cancel function to indicate the operation failed (displays red X instead of green checkmark).
Functions ¶
This section is empty.
Types ¶
type FunLogger ¶
type FunLogger struct {
// The logs are `io.Copy`'d to this in a mutex. It's common to set this to a
// file, or leave it default which is `os.Stderr`. You can also set this to
// something more adventurous, such as logging to Kafka.
Out io.Writer
// Function to exit the application, defaults to `os.Exit()`
ExitFunc exitFunc
// Wg is a WaitGroup that can be used to wait for the loading animation to finish.
Wg *sync.WaitGroup
// IsCI is a boolean that is set to true if the logger is running in a CI environment.
IsCI bool
// contains filtered or unexported fields
}
FunFonts implements the Logger interface using emojis for messages.
func (*FunLogger) Check ¶
Check prints an information message with a check emoji. Only prints if Verbosity >= VerbosityNormal.
func (*FunLogger) Debug ¶ added in v0.3.0
Debug prints a debug message. Only prints if Verbosity >= VerbosityVerbose.
func (*FunLogger) Error ¶
Error prints an error message with an X emoji. Always prints regardless of verbosity level.
func (*FunLogger) Info ¶
Info prints an information message with no emoji. Only prints if Verbosity >= VerbosityNormal.
func (*FunLogger) Loading ¶
func (l *FunLogger) Loading(format string, a ...any) context.CancelCauseFunc
Loading starts a loading animation in a background goroutine and returns a CancelCauseFunc. The caller MUST invoke the returned function to stop:
- cancel(nil) → success (green checkmark)
- cancel(logger.ErrLoadingFailed) → failure (red X)
Each invocation is independent — multiple concurrent Loading calls do not interfere with each other.
func (*FunLogger) SetVerbosity ¶ added in v0.3.0
SetVerbosity sets the verbosity level for the logger.
type Logger ¶
type Logger interface {
Info(format string, a ...any)
Check(format string, a ...any)
Warning(format string, a ...any)
Error(err error)
Loading(format string, a ...any) context.CancelCauseFunc
Debug(format string, a ...any)
Trace(format string, a ...any)
SetVerbosity(v Verbosity)
}
Printer interface defines methods for logging info, warning, and error messages.