logs

package
v0.0.35 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2021 License: LGPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package logs for the display of errors.

Index

Examples

Constants

View Source
const OSErrCode = 1
View Source
const (
	Panic = false
)

Variables

View Source
var (
	// internal arguments.
	ErrEmpty    = errors.New("value is empty")
	ErrErrorNil = errors.New("error value cannot be nil")
	ErrNameNil  = errors.New("name value cannot be empty")
	ErrShort    = errors.New("word count is too short, less than 3")

	// generic errors.
	ErrEncode    = errors.New("text encoding not known or supported")
	ErrFmt       = errors.New("format is not known")
	ErrHighlight = errors.New("could not format or colorize the element")
	ErrMax       = errors.New("maximum attempts reached")
	ErrTabFlush  = errors.New("tab writer could not write or flush")
	ErrZipFile   = errors.New("could not create the zip archive")

	// logs package errors.
	ErrCmd        = errors.New("the command is invalid")
	ErrFlag       = errors.New("the flag does not work with this command")
	ErrFlagChoice = errors.New("choose a value from the following")
	ErrFlagNil    = errors.New("the flag with a value must be included with this command")
	ErrNotBool    = errors.New("the value must be either true or false")
	ErrNotInt     = errors.New("the value must be a number")
	ErrNotInts    = errors.New("the value must be a single or a list of numbers")
	ErrNotNil     = errors.New("the value cannot be empty")
	ErrSave       = errors.New("save to log file failure")

	// config file.
	ErrConfigName = errors.New("unknown configuration or setting name")
	ErrConfigNew  = errors.New("could not create a configuration file")
	ErrConfigOpen = errors.New("could not open the configuration file")
	ErrConfigRead = errors.New("could not parse or use the configuration file")

	// pipe/stdin.
	ErrPipeEmpty = errors.New("empty text stream from piped stdin (standard input)")
	ErrPipeRead  = errors.New("could not read text stream from piped stdin (standard input)")
	ErrPipeParse = errors.New("could not parse the text stream from piped stdin (standard input)")

	// named file.
	ErrFileName  = errors.New("file does not exist")
	ErrFileOpen  = errors.New("could not open the file")
	ErrFileSave  = errors.New("could not save the file")
	ErrFileSaveD = errors.New("could not save the file to the directory")

	// sample file.
	ErrSampleName = errors.New("sample filename does not exist")
	ErrSampleOpen = errors.New("could not open the sample text")
	ErrSampleHTML = errors.New("could not convert the sample text to a HTML document")

	// template file.
	ErrTmplName  = errors.New("the named template layout does not exist")
	ErrTmplIsDir = errors.New("the named template file is a directory")

	// temporary directory.
	ErrTmpRMD   = errors.New("could not cleanup the temporary directory")
	ErrTmpSaveD = errors.New("could not save file to the temporary directory")

	// temporary file.
	ErrTmpClose = errors.New("could not close the temporary file")
	ErrTmpOpen  = errors.New("could not open the temporary file")
	ErrTmpSave  = errors.New("could not save to the temporary file")
)

Functions

func Fatal added in v0.0.31

func Fatal(err error)

Fatal prints a formatted error and exits.

func FatalCmd added in v0.0.33

func FatalCmd(usage string, args ...string)

FatalCmd prints a problem highlighting the unsupported command.

func FatalExecute added in v0.0.33

func FatalExecute(err error, args ...string)

FatalExecute is the error handler for the root command flags and arguments.

func FatalFlag added in v0.0.33

func FatalFlag(cmd, flag string, err error)

FatalFlag prints a problem with the flag and exits.

func FatalMark added in v0.0.33

func FatalMark(mark string, err, wrap error)

FatalMark formats the errors, highlights the value and exits.

func FatalSave added in v0.0.33

func FatalSave(err error)

FatalSave saves the error to the logfile and exits.

func FatalWrap added in v0.0.33

func FatalWrap(err, wrap error)

FatalWrap formats the errors and exits.

func Hint

func Hint(s string, err error) string

Hint returns a formatted error with a usage suggestion or hint.

func LastEntry added in v0.0.31

func LastEntry() (s string, err error)

LastEntry returns the most recent saved entry in the error log file.

func Name added in v0.0.31

func Name() string

Name is the absolute path and filename of the error log file.

func Save added in v0.0.31

func Save(err error)

Save by appending the error to the logfile.

Example
t := fmt.Sprintf("%s", ErrLogTest)
Save(ErrLogTest)
last, _ := LastEntry()
i := len(last) - len(t) - 1
fmt.Print(last[i:])
Output:

log test

func Sprint added in v0.0.33

func Sprint(err error) string

Sprint formats and returns the error.

Example
fmt.Println(Sprint(ErrTest))
fmt.Println(status)
Output:

Problem:
error.
exit status 1

func SprintCmd added in v0.0.33

func SprintCmd(cmd string, err error) string

SprintCmd returns the command does not exist.

func SprintFlag added in v0.0.33

func SprintFlag(cmd, flag string, err error) string

SprintFlag returns a problem with the flag.

func SprintMark added in v0.0.33

func SprintMark(mark string, err, wrap error) string

SprintMark formats and returns the errors and highlights the marked string.

func SprintWrap added in v0.0.33

func SprintWrap(err, wrap error) string

SprintWrap returns the formatted errors.

Types

This section is empty.

Jump to

Keyboard shortcuts

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