Documentation ¶
Index ¶
- Variables
- type ContextTree
- type Kind
- type ParseContext
- type ParseReporter
- func (reporter *ParseReporter) ReleaseContext(contextToRel *ParseContext)
- func (reporter *ParseReporter) ReportFailuref(template string, args ...interface{})
- func (reporter *ParseReporter) ReportGuessf(guess *guesses.Guess, template string, args ...interface{})
- func (reporter *ParseReporter) ReportSkipf(template string, args ...interface{})
- func (reporter *ParseReporter) ReportSuccessf(template string, args ...interface{})
- func (reporter *ParseReporter) SetContextf(context string, args ...interface{}) *ParseContext
- func (reporter *ParseReporter) SetWriter(writer io.Writer)
- func (reporter *ParseReporter) WriteReports()
- type Report
- type Reports
Constants ¶
This section is empty.
Variables ¶
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 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.