Skip to content

Commit d334d4c

Browse files
committed
Incerement default verbosity level
1 parent 8c0162c commit d334d4c

File tree

2 files changed

+25
-16
lines changed

2 files changed

+25
-16
lines changed

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,25 @@ Output:
5555
```
5656
Error with stack trace:
5757
foo failed
58-
./samples.go:34 main.foo
59-
./samples.go:10 main.main
60-
go1.20.2/rc/runtime/proc.go:250 runtime.main
61-
go1.20.2/rc/runtime/asm_amd64.s:1598 runtime.goexit
58+
./pkg/samples.go:34
59+
main.foo
60+
./pkg/samples.go:10
61+
main.main
62+
go1.20.2/rc/runtime/proc.go:250
63+
runtime.main
64+
go1.20.2/rc/runtime/asm_amd64.s:1598
65+
runtime.goexit
6266
caused by: bar failed
63-
./samples.go:38 main.bar
64-
./samples.go:33 main.foo
65-
./samples.go:10 main.main
66-
go1.20.2/rc/runtime/proc.go:250 runtime.main
67-
go1.20.2/rc/runtime/asm_amd64.s:1598 runtime.goexit
67+
./pkg/samples.go:38
68+
main.bar
69+
./pkg/samples.go:33
70+
main.foo
71+
./pkg/samples.go:10
72+
main.main
73+
go1.20.2/rc/runtime/proc.go:250
74+
runtime.main
75+
go1.20.2/rc/runtime/asm_amd64.s:1598
76+
runtime.goexit
6877
6978
Go std error:
7079
std error
@@ -78,10 +87,10 @@ Errors can be formatted with different verbosity levels with:
7887
fmt.Println(errors.Formatv(err), verbosity)
7988

8089
...or by changing the global verbosity level:
81-
errors.Config.Verbosity = 4
90+
errors.Config.Verbosity = 5
8291
```
8392

84-
The default verbosity level is 4.
93+
The default verbosity level is 5.
8594

8695
Verbosity level samples generated with `go run ./samples`:
8796
```
@@ -118,7 +127,7 @@ caused by: bar failed
118127
go1.20.2/rc/runtime/proc.go:250
119128
go1.20.2/rc/runtime/asm_amd64.s:1598
120129
121-
>>> Verbosity: 4 (DEFAULT)
130+
>>> Verbosity: 4
122131
foo failed
123132
./samples.go:34 main.foo
124133
./samples.go:10 main.main
@@ -131,7 +140,7 @@ caused by: bar failed
131140
go1.20.2/rc/runtime/proc.go:250 runtime.main
132141
go1.20.2/rc/runtime/asm_amd64.s:1598 runtime.goexit
133142
134-
>>> Verbosity: 5
143+
>>> Verbosity: 5 (DEFAULT)
135144
foo failed
136145
./samples.go:34
137146
main.foo

errors.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ func (f Frame) RelFile() string {
310310
name := f.File()
311311
relPath, ok := trimBasePath(Config.BasePath, name)
312312
if ok {
313-
return relPath
313+
return "./" + relPath
314314
}
315315
relPath, ok = trimBasePath(Config.BaseCachePath, name)
316316
if ok {
@@ -332,10 +332,10 @@ func trimBasePath(basePath string, path string) (string, bool) {
332332
if strings.HasPrefix(basePath, "**/") {
333333
i := strings.LastIndex(path, basePath[3:])
334334
if i > 0 {
335-
return "./" + path[i+len(basePath)-3:], true
335+
return path[i+len(basePath)-3:], true
336336
}
337337
} else if strings.HasPrefix(path, basePath) {
338-
return "./" + path[len(basePath):], true
338+
return path[len(basePath):], true
339339
}
340340
return "", false
341341
}

0 commit comments

Comments
 (0)