reporter

package
v0.0.0-...-116fc4f Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	KindSuccess = &Kind{
		"SUCCESS",
		"✔",
		color.New(color.FgGreen),
	}
	KindSkip = &Kind{
		"SKIP",
		"?",
		color.New(color.FgYellow),
	}
	KindFailure = &Kind{
		"FAILURE",
		"✘",
		color.New(color.FgRed),
	}
	KindGuess = &Kind{
		"GUESS",
		"💡",
		color.New(color.FgBlue),
	}
)

Functions

This section is empty.

Types

type ContextTree

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

ParseContext is the scope in which reported events occurred.

func NewContextTree

func NewContextTree(root string) *ContextTree

func (*ContextTree) AddContext

func (tree *ContextTree) AddContext(message string) *ParseContext

func (*ContextTree) PrettyPrint

func (tree *ContextTree) PrettyPrint() string

func (*ContextTree) ReleaseContext

func (tree *ContextTree) ReleaseContext()

type Kind

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

func (*Kind) Sprint

func (kind *Kind) Sprint(message string) string

type ParseContext

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

ParseContext is the scope in which reported events occurred.

func NewParseContext

func NewParseContext(message string, parent *ParseContext, level int) *ParseContext

func (*ParseContext) AddChildContext

func (context *ParseContext) AddChildContext(child *ParseContext)

func (*ParseContext) AddChildReport

func (context *ParseContext) AddChildReport(child *Report)

func (*ParseContext) PrettyPrint

func (context *ParseContext) PrettyPrint() string

type ParseReporter

type ParseReporter struct {
	Failures  Reports
	Guesses   Reports
	Successes Reports
	Skips     Reports
	// contains filtered or unexported fields
}

ParseReporter is a struct allowing to report parsing events with a dynamic scope for advanced pretty-print.

func NewParseReporter

func NewParseReporter(rootContext string) *ParseReporter

NewParseReporter creates an instance of ParseReporter

func (*ParseReporter) ReleaseContext

func (reporter *ParseReporter) ReleaseContext(contextToRel *ParseContext)

ReleaseContext release current context. It should be passed the ParseContext instance returned by SetContextf

Typical usage :

context := SetContextf("new context %v", stringer)
defer ReleaseContext(context)

func (*ParseReporter) ReportFailuref

func (reporter *ParseReporter) ReportFailuref(template string, args ...interface{})

ReportSuccessf childReports a parsing failure (unexpected course of events). Use ReportSkipf when the error is recoverable. It can be called like fmt.Sprint

func (*ParseReporter) ReportGuessf

func (reporter *ParseReporter) ReportGuessf(guess *guesses.Guess, template string, args ...interface{})

ReportGuessf childReports a Guess It can be called like fmt.Sprint

func (*ParseReporter) ReportSkipf

func (reporter *ParseReporter) ReportSkipf(template string, args ...interface{})

ReportSkipf childReports a skipped element during parsing. It can be called like fmt.Sprint

func (*ParseReporter) ReportSuccessf

func (reporter *ParseReporter) ReportSuccessf(template string, args ...interface{})

ReportSuccessf childReports a parsing success It can be called like fmt.Sprint

func (*ParseReporter) SetContextf

func (reporter *ParseReporter) SetContextf(context string, args ...interface{}) *ParseContext

SetContextf sets current context which is a dynamic logging scope. It can be called like fmt.Sprint, and returns the ParseContext instance which should be given to ReleaseContext later.

Typical usage :

context := SetContextf("new context %v", stringer)
defer ReleaseContext(context)

func (*ParseReporter) SetWriter

func (reporter *ParseReporter) SetWriter(writer io.Writer)

SetWriter sets the writer to which childReports should be written to.

func (*ParseReporter) WriteReports

func (reporter *ParseReporter) WriteReports()

WriteReports pretty-print reports to the configured writer if any.

type Report

type Report struct {
	Kind    *Kind
	Message string
	// contains filtered or unexported fields
}

func (*Report) PrettyPrint

func (report *Report) PrettyPrint() string

type Reports

type Reports []*Report

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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