Skip to content

Commit

Permalink
Incerement default verbosity level
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendelski committed Mar 21, 2023
1 parent 8c0162c commit d334d4c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
35 changes: 22 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,16 +55,25 @@ Output:
```
Error with stack trace:
foo failed
./samples.go:34 main.foo
./samples.go:10 main.main
go1.20.2/rc/runtime/proc.go:250 runtime.main
go1.20.2/rc/runtime/asm_amd64.s:1598 runtime.goexit
./pkg/samples.go:34
main.foo
./pkg/samples.go:10
main.main
go1.20.2/rc/runtime/proc.go:250
runtime.main
go1.20.2/rc/runtime/asm_amd64.s:1598
runtime.goexit
caused by: bar failed
./samples.go:38 main.bar
./samples.go:33 main.foo
./samples.go:10 main.main
go1.20.2/rc/runtime/proc.go:250 runtime.main
go1.20.2/rc/runtime/asm_amd64.s:1598 runtime.goexit
./pkg/samples.go:38
main.bar
./pkg/samples.go:33
main.foo
./pkg/samples.go:10
main.main
go1.20.2/rc/runtime/proc.go:250
runtime.main
go1.20.2/rc/runtime/asm_amd64.s:1598
runtime.goexit
Go std error:
std error
Expand All @@ -78,10 +87,10 @@ Errors can be formatted with different verbosity levels with:
fmt.Println(errors.Formatv(err), verbosity)

...or by changing the global verbosity level:
errors.Config.Verbosity = 4
errors.Config.Verbosity = 5
```

The default verbosity level is 4.
The default verbosity level is 5.

Verbosity level samples generated with `go run ./samples`:
```
Expand Down Expand Up @@ -118,7 +127,7 @@ caused by: bar failed
go1.20.2/rc/runtime/proc.go:250
go1.20.2/rc/runtime/asm_amd64.s:1598
>>> Verbosity: 4 (DEFAULT)
>>> Verbosity: 4
foo failed
./samples.go:34 main.foo
./samples.go:10 main.main
Expand All @@ -131,7 +140,7 @@ caused by: bar failed
go1.20.2/rc/runtime/proc.go:250 runtime.main
go1.20.2/rc/runtime/asm_amd64.s:1598 runtime.goexit
>>> Verbosity: 5
>>> Verbosity: 5 (DEFAULT)
foo failed
./samples.go:34
main.foo
Expand Down
6 changes: 3 additions & 3 deletions errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (f Frame) RelFile() string {
name := f.File()
relPath, ok := trimBasePath(Config.BasePath, name)
if ok {
return relPath
return "./" + relPath
}
relPath, ok = trimBasePath(Config.BaseCachePath, name)
if ok {
Expand All @@ -332,10 +332,10 @@ func trimBasePath(basePath string, path string) (string, bool) {
if strings.HasPrefix(basePath, "**/") {
i := strings.LastIndex(path, basePath[3:])
if i > 0 {
return "./" + path[i+len(basePath)-3:], true
return path[i+len(basePath)-3:], true
}
} else if strings.HasPrefix(path, basePath) {
return "./" + path[len(basePath):], true
return path[len(basePath):], true
}
return "", false
}
Expand Down

0 comments on commit d334d4c

Please sign in to comment.