Documentation ¶
Overview ¶
A simple package for dealing with logging module output during the unit testing cycle.
Example ¶
// Setup buffer := SetupBuffer() defer buffer.DumpToStdout() // Unit tests go here. // Clear the buffer so nothing ends up being printed. buffer.Clear()
Output:
Index ¶
- type LogBuffer
- func (l *LogBuffer) Clear()
- func (l *LogBuffer) DumpToFile(path string)
- func (l *LogBuffer) DumpToStdout()
- func (l *LogBuffer) FinishTest(t Logger)
- func (l *LogBuffer) Flush() error
- func (l *LogBuffer) Lines() []string
- func (l *LogBuffer) NewLines() []string
- func (l *LogBuffer) Write(ld *logray.LineData) error
- type Logger
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogBuffer ¶
type LogBuffer struct {
// contains filtered or unexported fields
}
This will be used as a Output object as a logging destination. It is configured to capture all logs and store them in memory, flushing them only if the unit test fails.
func SetupBuffer ¶
func SetupBuffer() *LogBuffer
Sets up everything needed to unit test against a LogBuffer object. The returned object will use numerical counters rather than dates in order to make the output predictable.
func (*LogBuffer) DumpToFile ¶
func (*LogBuffer) DumpToStdout ¶
func (l *LogBuffer) DumpToStdout()
Dumps all the lines in the buffer to stdout.
func (*LogBuffer) FinishTest ¶
Dumps the logs in the log buffer if the test failed, otherwise clears them for the next test.
Click to show internal directories.
Click to hide internal directories.