]> Cypherpunks repositories - gostls13.git/commit
log/slog: remove special float handling from JSONHandler
authorJonathan Amsterdam <jba@google.com>
Wed, 19 Apr 2023 20:51:05 +0000 (16:51 -0400)
committerJonathan Amsterdam <jba@google.com>
Thu, 4 May 2023 20:20:40 +0000 (20:20 +0000)
commit0022bd37a7f2483312950bcafbb3916ab76635ec
tree40a2d450c4653c66177f300020232babfb415e60
parent0212b80eacaf03365810ea93e0380aefe8b8ab42
log/slog: remove special float handling from JSONHandler

Remove the special-case handling of NaN and infinities from
appendJSONValue, making JSONHandler behave almost exactly like
a json.Encoder without HTML escaping.

The only differences are:

- Encoding errors are turned into strings, instead of causing the Handle method to fail.

- Values of type `error` are displayed as strings by calling their `Error` method.

Fixes #59345.

Change-Id: Id06bd952bbfef596e864bd5fd3f9f4f178f738c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/486855
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
src/log/slog/json_handler.go
src/log/slog/json_handler_test.go