Skip to content

*: refine panic log#967

Merged
you06 merged 1 commit intotikv:masterfrom
crazycs520:refine-log2
Sep 11, 2023
Merged

*: refine panic log#967
you06 merged 1 commit intotikv:masterfrom
crazycs520:refine-log2

Conversation

@crazycs520
Copy link
Contributor

@crazycs520 crazycs520 commented Sep 11, 2023

close #966

Following is a tiny test:

Before this PR:

func TestLog(t *testing.T) {
	defer func() {
		if r := recover(); r != nil {
			logutil.BgLogger().Warn("recover panic", zap.Reflect("r", r))
		}
	}()
	s := []int{}
	s[0] = 1
}

You will get the following log:

[2023/09/11 14:36:19.797 +08:00] [WARN] [client_test.go:729] ["recover panic"] [r={}]

This PR, use zap.Any instead of zap.Reflect, You will get the following log:

[2023/09/11 14:36:49.106 +08:00] [WARN] [client_test.go:729] ["recover panic"] [r="runtime error: index out of range [0] with length 0"]

Signed-off-by: crazycs520 <crazycs520@gmail.com>
@crazycs520 crazycs520 marked this pull request as ready for review September 11, 2023 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The panic log doesn't contain the panic reason information

4 participants