Skip to content

Commit

Permalink
add json example
Browse files Browse the repository at this point in the history
  • Loading branch information
sdual committed Sep 6, 2024
1 parent 33fa102 commit 0e85d73
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ func main() {
rsHandler := roachslog.NewReachSlogHandler(handler)
slog.SetDefault(slog.New(rsHandler))

err := errors.New("error")
err := doSomething()
slog.Error("error occurred", roachslog.Err(err))
}

func doSomething() error {
return errors.New("error")
}
```

```json
{"time":"2024-09-06T12:44:15.107483+09:00","level":"ERROR","source":{"function":"main.main","file":"/Users/sdual/repos/golang/sample/main.go","line":22},"msg":"error occurred","error":"error","stacktrace":"\nmain.doSomething\n\t/Users/sdual/repos/golang/sample/main.go:26\nmain.main\n\t/Users/sdual/repos/golang/sample/main.go:21\nruntime.main\n\t/Users/sdual/go/1.22.4/pkg/mod/golang.org/[email protected]/src/runtime/proc.go:272\nruntime.goexit\n\t/Users/sdual/go/1.22.4/pkg/mod/golang.org/[email protected]/src/runtime/asm_arm64.s:1223"}
```

0 comments on commit 0e85d73

Please sign in to comment.