cmdutil

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2019 License: MIT Imports: 8 Imported by: 1

Documentation

Overview

Package cmdutil contains utility methods that are useful for command-line programs.

Index

Constants

View Source
const (
	EnvLogrusLevel  = "LOGRUS_LEVEL"
	EnvLogrusFormat = "LOGRUS_FORMAT"
)

Logrus-related environment keys.

View Source
const (
	LogrusFormatJSON = "json"
	LogrusFormatText = "text"
)

Valid environment values for the key EnvLogrusFormat.

View Source
const (
	EnvSentryDSN = "SENTRY_DSN"
)

Raven and Sentry-related environment variables.

Variables

View Source
var FatalExitCode = 1

FatalExitCode is the exit code that all Fatal* methods exit with after printing.

Functions

func Err

func Err(a ...zero.Interface) (n int, err error)

Err is like fmt.Print, but writes to standard error.

func Errf

func Errf(format string, a ...zero.Interface) (n int, err error)

Errf is like fmt.Printf, but writes to standard error.

func Errln

func Errln(a ...zero.Interface) (n int, err error)

Errln is like fmt.Println, but writes to standard error.

func Fatal

func Fatal(a ...zero.Interface)

Fatal is like Err, but exits with an error code after printing.

func Fatalf

func Fatalf(format string, a ...zero.Interface)

Fatalf is like Errf, but exits with an error code after printing.

func Fatalln

func Fatalln(a ...zero.Interface)

Fatalln is like Errln, but exits with an error code after printing.

func Must

func Must(err error)

Must panics if err is not nil.

It is used to wrap side-effect-inducing function calls that return an error.

func NewLogger added in v0.4.1

func NewLogger(opts ...LogrusOption) *logrus.Entry

NewLogger creates an application-level logrus.Entry.

func NewRaven added in v0.4.1

func NewRaven(opts ...RavenOption) *raven.Client

NewRaven creates a new raven.Client.

Types

type LogrusConfig added in v0.4.1

type LogrusConfig struct {
	// Logging-related options.
	Output        io.Writer
	TextFormatter logrus.TextFormatter
	JSONFormatter logrus.JSONFormatter

	// Extensions-related options.
	Raven *raven.Client
}

A LogrusConfig configures a logrus.Logger.

type LogrusOption added in v0.4.1

type LogrusOption func(*LogrusConfig)

A LogrusOption modifies a LogrusConfig.

func WithLogrusSentryHook added in v0.4.1

func WithLogrusSentryHook(rc *raven.Client) LogrusOption

WithLogrusSentryHook adds a Sentry reporting hook to a logrus.Logger.

type RavenConfig added in v0.4.1

type RavenConfig struct {
	Release string
}

RavenConfig configures a raven.Client.

type RavenOption added in v0.4.1

type RavenOption func(*RavenConfig)

A RavenOption modifies a RavenConfig.

func WithRavenRelease added in v0.4.1

func WithRavenRelease(release string) RavenOption

WithRavenRelease sets the release tag for a raven.Client.

Jump to

Keyboard shortcuts

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