output

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: MIT Imports: 10 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) Debug added in v1.2.1

func (o Output) Debug(msg string)

func (Output) Debugf

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

func (Output) Error added in v1.2.1

func (o Output) Error(msg string)

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) FatalErrorWithHints added in v1.2.1

func (o Output) FatalErrorWithHints(err error, hints []string, msg string)

func (Output) FatalWithHintExamples added in v1.2.1

func (o Output) FatalWithHintExamples(hintExamples [][]string, msg string)

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) Info added in v1.2.1

func (o Output) Info(msg string)

func (Output) InfoWithHintExamples added in v1.2.1

func (o Output) InfoWithHintExamples(hintExamples [][]string, msg string)

func (Output) InfoWithHints added in v1.2.1

func (o Output) InfoWithHints(hints []string, msg string)

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) Trace added in v1.2.1

func (o Output) Trace(msg string)

func (Output) Tracef

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

func (Output) Warn added in v1.2.1

func (o Output) Warn(msg string)

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