File tree Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Expand file tree Collapse file tree 4 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -7,5 +7,4 @@ cd "$(git rev-parse --show-toplevel)"
7
7
# shellcheck disable=SC2046
8
8
shellcheck -x $( git ls-files " *.sh" )
9
9
go vet ./...
10
- # Re enable later.
11
- # go run golang.org/x/lint/golint -set_exit_status ./...
10
+ go run golang.org/x/lint/golint -set_exit_status ./...
Original file line number Diff line number Diff line change @@ -9,11 +9,14 @@ import (
9
9
10
10
type skipKey struct {}
11
11
12
+ // With appends to the skip offset in the context and returns
13
+ // a new context with the new skip offset.
12
14
func With (ctx context.Context , skip int ) context.Context {
13
15
skip += From (ctx )
14
16
return context .WithValue (ctx , skipKey {}, skip )
15
17
}
16
18
19
+ // From returns the skip offset.
17
20
func From (ctx context.Context ) int {
18
21
l , _ := ctx .Value (skipKey {}).(int )
19
22
return l
Original file line number Diff line number Diff line change 4
4
"context"
5
5
)
6
6
7
+ // Logger is the core interface for logging.
7
8
type Logger interface {
8
9
// Debug means a potentially noisy log.
9
10
Debug (ctx context.Context , msg string , fields ... Field )
@@ -31,17 +32,26 @@ type field struct {
31
32
value fieldValue
32
33
}
33
34
35
+ // Field represents a log field.
34
36
type Field interface {
35
37
LogKey () string
36
38
Value
37
39
}
38
40
41
+ // Value represents a log value.
42
+ // The value returned will be logged.
43
+ // Your own types can implement this interface to
44
+ // override their logging appearance.
39
45
type Value interface {
40
46
LogValue () interface {}
41
47
}
42
48
49
+ // ValueFunc is a function that computes its logging
50
+ // representation. Use it to override the logging
51
+ // representation of a structure inline.
43
52
type ValueFunc func () interface {}
44
53
54
+ // LogValue implements Value.
45
55
func (fn ValueFunc ) LogValue () interface {} {
46
56
return fn ()
47
57
}
Original file line number Diff line number Diff line change @@ -5,10 +5,15 @@ import (
5
5
"testing"
6
6
)
7
7
8
+ // TestOptions represents the options for the logger returned
9
+ // by Test.
8
10
type TestOptions struct {
11
+ // IgnoreErrors causes the test logger to not fatal the test
12
+ // on Fatal and not error the test on Error or Critical.
9
13
IgnoreErrors bool
10
14
}
11
15
16
+ // Test creates a Logger that writes logs to tb.
12
17
func Test (tb testing.TB , opts * TestOptions ) Logger {
13
18
if opts == nil {
14
19
opts = & TestOptions {}
You can’t perform that action at this time.
0 commit comments