Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy patherror_logger_impl.go
More file actions
Latest commit
42 lines (35 loc) · 955 Bytes
/
Copy patherror_logger_impl.go
File metadata and controls
42 lines (35 loc) · 955 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package assert
import (
"fmt"
"io"
"os"
)
typelocationstruct {
Teststring
FileNamestring
Lineint
}
typeerrorLoggerinterface {
Log(location*location, messagestring)
}
vartheLoggererrorLogger=&errorLoggerImpl{writer: os.Stdout}
typeerrorLoggerImplstruct {
writer io.Writer
prevTestNamestring
prevTestLineint
}
const (
formatHeaderFull="\n--- FAIL: %s\n\t%s:%d\n"
formatHeaderShort="\t%s:%d\n"
formatMessage="\t\t%s\n"
)
func (logger*errorLoggerImpl) Log(location*location, messagestring) {
iflogger.prevTestName!=location.Test {
fmt.Fprintf(logger.writer, formatHeaderFull, location.Test, location.FileName, location.Line)
} elseiflogger.prevTestLine!=location.Line {
fmt.Fprintf(logger.writer, formatHeaderShort, location.FileName, location.Line)
}
fmt.Fprintf(logger.writer, formatMessage, message)
logger.prevTestName=location.Test
logger.prevTestLine=location.Line
}