util

package
v0.0.0-...-39d6a1f Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEBUG LogLevel = 0
	INFO  LogLevel = 1
	WARN  LogLevel = 2
	ERROR LogLevel = 3

	FormatLayoutJSON        FormatLayoutType = "json"
	FormatLayoutText        FormatLayoutType = "text"
	FormatLayoutStackdriver FormatLayoutType = "stackdriver"
)
View Source
const (
	DefaultSuggestionsMinimumDistance = 2
)

Variables

View Source
var ColorAnswer = color.New(color.FgCyan).SprintFunc()

ColorAnswer returns a new function that returns answer-colorized (cyan) strings for the given arguments with fmt.Sprint().

View Source
var ColorBold = color.New(color.Bold).SprintFunc()

ColorBold returns a new function that returns bold-colorized (bold) strings for the given arguments with fmt.Sprint().

View Source
var ColorDebug = color.New(color.FgCyan).SprintFunc()
View Source
var ColorError = color.New(color.FgRed).SprintFunc()

ColorError returns a new function that returns error-colorized (red) strings for the given arguments with fmt.Sprint().

View Source
var ColorInfo = color.New(color.FgGreen).SprintFunc()

ColorInfo returns a new function that returns info-colorized (green) strings for the given arguments with fmt.Sprint().

View Source
var ColorStatus = color.New(color.FgBlue).SprintFunc()

ColorStatus returns a new function that returns status-colorized (blue) strings for the given arguments with fmt.Sprint().

View Source
var ColorWarning = color.New(color.FgYellow).SprintFunc()

ColorWarning returns a new function that returns warning-colorized (yellow) strings for the given arguments with fmt.Sprint().

View Source
var Version string

set at build time

Functions

func ColorNameValues

func ColorNameValues() []string

ColorNameValues returns all the color names sorted

func Contains

func Contains(arr []string, str string) bool

func GetColor

func GetColor(optionName string, colorNames []string) (*color.Color, error)

GetColor returns the color for the list of colour names and option name

func GetFilePath

func GetFilePath(r *http.Request) string

func GetRootPath

func GetRootPath() string

func HandleError

func HandleError(w http.ResponseWriter, e error)

func HomeDir

func HomeDir() string

func InvalidArg

func InvalidArg(value string, values []string) error

func InvalidArgError

func InvalidArgError(value string, err error) error

func InvalidArgf

func InvalidArgf(value string, message string, a ...interface{}) error

func InvalidOption

func InvalidOption(name string, value string, values []string) error

func InvalidOptionError

func InvalidOptionError(option string, value interface{}, err error) error

InvalidOptionError returns an error that shows the invalid option

func InvalidOptionf

func InvalidOptionf(option string, value interface{}, message string, a ...interface{}) error

InvalidOptionf returns an error that shows the invalid option

func LoadTemplate

func LoadTemplate(w http.ResponseWriter, temp templates.Template, content interface{})

func Log

func Log(level LogLevel, messages ...interface{})

func Logger

func Logger() *logrus.Entry

func MissingArgument

func MissingArgument(name string) error

MissingArgument reports a missing command line argument name

func MissingEnv

func MissingEnv(name string) error

MissingEnv reports a missing environment variable

func MissingOption

func MissingOption(name string) error

MissingOption reports a missing command line option using the full name expression

func MissingOptionWithOptions

func MissingOptionWithOptions(name string, options []string) error

MissingOptionWithOptions reports a missing command line option using the full name expression along with a list of available values

func SuggestionsFor

func SuggestionsFor(typedName string, values []string, suggestionsMinimumDistance int, explicitSuggestions ...string) []string

Types

type FormatLayoutType

type FormatLayoutType string

type LogLevel

type LogLevel int

type TextFormat

type TextFormat struct {
	ShowInfoLevel   bool
	ShowTimestamp   bool
	TimestampFormat string
}

JenkinsXTextFormat lets use a custom text format

func NewTextFormat

func NewTextFormat() *TextFormat

NewTextFormat creates the default text formatter

func (*TextFormat) Format

func (f *TextFormat) Format(entry *logrus.Entry) ([]byte, error)

type UnsupportedError

type UnsupportedError struct{}

func (UnsupportedError) Error

func (e UnsupportedError) Error() string

Jump to

Keyboard shortcuts

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