output

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 9 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	OutputType     string
	LoggingLevel   verbosity.Level
	StandardWriter io.WriteCloser

	ErrorHandler func(err error)
	HintHandler  func(hints []string)
	// contains filtered or unexported fields
}

type Output

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

func New

func New(options Options) *Output

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) Debugf

func (o Output) Debugf(format string, a ...any)

func (Output) Errorf

func (o Output) Errorf(format string, a ...any)

func (Output) Fatal

func (o Output) Fatal(a ...any)

func (Output) FatalErr

func (o Output) FatalErr(err error)

func (Output) FatalWithHints

func (o Output) FatalWithHints(hints []string, a ...any)

func (Output) Fatalf

func (o Output) Fatalf(format string, a ...any)

func (Output) FatalfErrorWithHints

func (o Output) FatalfErrorWithHints(err error, hints []string, format string, a ...any)

func (Output) FatalfWithHintExamples

func (o Output) FatalfWithHintExamples(hintExamples [][]string, format string, a ...any)

func (Output) FatalfWithHints

func (o Output) FatalfWithHints(hints []string, format string, a ...any)

func (Output) Infof

func (o Output) Infof(format string, a ...any)

func (Output) InfofWithHintExamples

func (o Output) InfofWithHintExamples(hintExamples [][]string, format string, a ...any)

InfofWithHintExamples logs an info-level message with a given format and arguments. It also displays additional hints with example usage in the output.

func (Output) InfofWithHints

func (o Output) InfofWithHints(hints []string, format string, a ...any)

func (Output) Panic

func (o Output) Panic(a ...any)

func (Output) Panicf

func (o Output) Panicf(format string, a ...any)

func (Output) Struct

func (o Output) Struct(in interface{}) (bytes []byte)

func (Output) Tracef

func (o Output) Tracef(format string, a ...any)

func (Output) Warnf

func (o Output) Warnf(format string, a ...any)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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