Documentation
¶
Overview ¶
Package Output provides a number of methods for logging and handling errors, including Debugf, Errorf, Fatalf, FatalErr, Infof, Panic, Panicf, Struct, Tracef, and Warnf. These methods allow the caller to specify the desired verbosity level, adds a newline to the end of the log message if necessary, and handle errors and hints in a variety of ways.
Trace("Something very low level.") - not localized Debug("Useful debugging information.") - not localized Info("Something noteworthy happened!") - localized Warn("You should probably take a look at this.") - localized Error("Something failed but I'm not quitting.") - localized Fatal("Bye.") - localized, calls os.Exit(1) after logging Panic("I'm bailing.") - not localized, calls panic() after logging
Index ¶
- type Options
- type Output
- func (o Output) Debug(msg string)
- func (o Output) Debugf(format string, a ...any)
- func (o Output) Error(msg string)
- func (o Output) Errorf(format string, a ...any)
- func (o Output) Fatal(a ...any)
- func (o Output) FatalErr(err error)
- func (o Output) FatalErrorWithHints(err error, hints []string, msg string)
- func (o Output) FatalWithHintExamples(hintExamples [][]string, msg string)
- func (o Output) FatalWithHints(hints []string, a ...any)
- func (o Output) Fatalf(format string, a ...any)
- func (o Output) FatalfErrorWithHints(err error, hints []string, format string, a ...any)
- func (o Output) FatalfWithHintExamples(hintExamples [][]string, format string, a ...any)
- func (o Output) FatalfWithHints(hints []string, format string, a ...any)
- func (o Output) Info(msg string)
- func (o Output) InfoWithHintExamples(hintExamples [][]string, msg string)
- func (o Output) InfoWithHints(hints []string, msg string)
- func (o Output) Infof(format string, a ...any)
- func (o Output) InfofWithHintExamples(hintExamples [][]string, format string, a ...any)
- func (o Output) InfofWithHints(hints []string, format string, a ...any)
- func (o Output) Panic(a ...any)
- func (o Output) Panicf(format string, a ...any)
- func (o Output) Struct(in interface{}) (bytes []byte)
- func (o Output) Trace(msg string)
- func (o Output) Tracef(format string, a ...any)
- func (o Output) Warn(msg string)
- func (o Output) Warnf(format string, a ...any)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Output ¶
type Output struct {
// contains filtered or unexported fields
}
func New ¶
New initializes a new Output instance with the specified options. If options are not provided, default values are used. The function sets the error callback and the hint callback based on the value of the unitTesting field in the provided options. If unitTesting is true, the error callback is set to panic on error, otherwise it is set to use cobra.CheckErr to handle errors.
func (Output) FatalErrorWithHints ¶ added in v1.2.1
func (Output) FatalWithHintExamples ¶ added in v1.2.1
func (Output) FatalWithHints ¶
func (Output) FatalfErrorWithHints ¶
func (Output) FatalfWithHintExamples ¶
func (Output) FatalfWithHints ¶
func (Output) InfoWithHintExamples ¶ added in v1.2.1
func (Output) InfoWithHints ¶ added in v1.2.1
func (Output) InfofWithHintExamples ¶
InfofWithHintExamples logs an info-level message with a given format and arguments. It also displays additional hints with example usage in the output.