Commit graph

77 commits

Author SHA1 Message Date
Jared Wasinger
6ba58e97a9 remove Inner method from Logger interface 2023-11-22 21:45:45 +08:00
jwasinger
5b0252bf41
Update log/root.go
Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-22 19:05:04 +08:00
Jared Wasinger
0031bebd98 reinstate use of atomic.Value for holding root logger object 2023-11-22 15:36:52 +08:00
Jared Wasinger
31dcb3daa8 fix fmt.Stringer values in json handler 2023-11-22 15:00:36 +08:00
Jared Wasinger
e411480a43 don't stack-overflow 2023-11-22 14:04:52 +08:00
Jared Wasinger
eb04be1635 add Write method to Logger interface to allow expressing all operations in the root logger in terms of Logger 2023-11-22 13:50:26 +08:00
Jared Wasinger
98166316b9 internal/testlog, log: add Inner method to log.Logger to expose wrapped slog.Logger. fix log.SetDefault to also set slog default logger. 2023-11-21 23:03:48 +08:00
Jared Wasinger
ec2e836aa3 remove outdated code from logger 2023-11-20 23:23:06 +08:00
Jared Wasinger
a110d6aa1e use separate time formats for logfmt/json handlers 2023-11-17 17:48:59 +08:00
Jared Wasinger
e89763002b log: move more instances of 'nil' to '<nil>' 2023-11-16 16:05:14 +08:00
Jared Wasinger
a6198dab39 make big.Int/uint256.Int nil value be formatted as 'nil', not '<nil>' 2023-11-15 18:05:16 +08:00
Jared Wasinger
a86ccc4212 simplify TerminalHandler constructor/WithAttrs by omitting explicit instantiation for value types that take defaults 2023-11-15 17:06:59 +08:00
Jared Wasinger
cdde508ef1 FormatLogfmtValue should escape error and fmt.Stringer values 2023-11-15 17:06:59 +08:00
Jared Wasinger
3b7e759215 ... and copy patterns too 2023-11-15 17:06:59 +08:00
Jared Wasinger
e25cb5ce80 log: copy siteCache map when instantiating GlogHandler via WithAttrs method 2023-11-15 17:06:59 +08:00
Martin Holst Swende
c9dc6d7658 log: fix terminal format 2023-11-15 17:06:59 +08:00
Jared Wasinger
de3c7fbc1b log: remove formatShared. 2023-11-15 17:06:59 +08:00
Jared Wasinger
c5cd6fe922 format nil big.Int values as 'nil' instead of '<nil>' 2023-11-15 17:06:32 +08:00
Jared Wasinger
d960dc8fa7 express built-in time key as String attribute instead of Any 2023-11-15 17:06:32 +08:00
Jared Wasinger
655e6fc1fd fix logfmt time field value formatting 2023-11-15 17:06:32 +08:00
Martin Holst Swende
b61bbbfd0f log, debug: make terminal handler public, change how to reset fieldpadding map 2023-11-15 17:06:32 +08:00
Jared Wasinger
3ab42db894 re-add testlogger. add minimal adaption/copy of TerminalHandler format to testlog package. Make logfmt value formatting public from log package. 2023-11-15 17:06:32 +08:00
Jared Wasinger
a4f99966ab remove FuncHandler 2023-11-15 17:06:32 +08:00
Jared Wasinger
32a47ad53b move fieldPadding logic into terminalHandler. make TerminalFormat private member function of terminalHandler 2023-11-15 17:06:32 +08:00
Jared Wasinger
5beed9f75d add missing parts from previous commit 2023-11-15 17:06:32 +08:00
Jared Wasinger
14bc27f178 pass handler attrs to TerminalFormat as a parameter instead of adding them to record. add unit test for this 2023-11-15 17:06:32 +08:00
Jared Wasinger
dad6ef06fe use log package JSONHandler wrapper 2023-11-15 17:06:32 +08:00
jwasinger
bd684ceac7 Update log/handler.go
Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-11-15 17:06:32 +08:00
Jared Wasinger
3e11e89d57 remove builtinHandler 2023-11-15 17:06:32 +08:00
Jared Wasinger
a59f2544c0 remove unused LogfmtFormat 2023-11-15 17:06:32 +08:00
Jared Wasinger
46b65e228b remove extra spaces. add test for nil big.Int/uint256.Int. move log.backtrace/log.debug flags to flags_legacy.go 2023-11-15 17:06:32 +08:00
Jared Wasinger
3419543ce0 formatting fix. error->eror 2023-11-15 17:06:32 +08:00
Jared Wasinger
dfea5f3160 don't add comma's in logfmt formatted big.Int and uint256.Int 2023-11-15 17:06:32 +08:00
Jared Wasinger
7045f6ed72 address feedback: make diff smaller by adding backward-compatible log levels and logger interface method 2023-11-15 17:06:32 +08:00
Jared Wasinger
0d145d224f add back code mistakenly removed in rebase 2023-11-15 17:06:32 +08:00
Jared Wasinger
928246416a all: replace log15 with slog 2023-11-15 17:06:32 +08:00
Martin Holst Swende
58ae1df684
cmd/geth: test for logging-output (#28373)
This PR is a bit in preparation for the slog work in #28187 .

Our current test re logging mostly test the internals, but we have no real end-to-end test of the logging output. This PR introduces a simple reexec-based log tester. This also relies upon a special mode in geth, which can be made to eject a set of predefined log messages (only available if the build-tag `integrationtests` is used

e.g. go run --tags=integrationtests ./cmd/geth --log.format terminal logtest

While working on this, I also noticed a quirk in the setup: when geth was configured to use a file output, then two separate handlers were used (one handler for the file, one handler for the console). Using two separate handlers means that two formatters are used, thus the formatting of any/all records happened twice. This PR changes the mechanism to use two separate io.Writers instead, which is both more optimal and fixes a bug which occurs due to a global statefulness in the formatter.
2023-10-25 17:57:12 +02:00
Martin Holst Swende
43df612268
internal, log: remove code for old unsupported go-versions (#28090) 2023-09-13 01:42:32 -04:00
Martin Holst Swende
a8d7201ec5
log: avoid stack lookups when not needed/used (#28069)
Avoids the somewhat expensive stack.Caller invocation by checking if it is needed
2023-09-07 08:48:49 -04:00
ucwong
5c30541c2a
log: use atomic types (#27763)
Co-authored-by: Felix Lange <fjl@twurst.com>
2023-08-05 00:58:53 +02:00
ucwong
81d328a73e
log: report error when ctx key is non-string (#27226)
* log/format.go : invalid string cast fix

* log: some polish

---------

Co-authored-by: Martin Holst Swende <martin@swende.se>
2023-05-08 05:38:50 -04:00
Péter Szilágyi
8a9a73c99b
log: add special casing of uint256 into the logger (#26936) 2023-03-21 12:01:43 +02:00
Nate Armstrong
a36c68f12c
log: improve documentation (#26753)
Add usage examples
2023-02-22 07:39:41 -05:00
Felix Lange
8c18b48bf1
log: allow tabs in log messages (#26630)
* log: allow tabs in log messages

This fixes a regression where panic reports in RPC handlers were quoted
because they contain tab characters.

* Update format.go
2023-02-08 11:39:17 +02:00
Martin Holst Swende
17017b2516
log: better sanitation (#26556) 2023-01-30 18:43:12 +01:00
ucwong
fd4230f695
log: fix typo in comment (#26569) 2023-01-30 08:33:03 -05:00
Felix Lange
b628d72766
build: upgrade to go 1.19 (#25726)
This changes the CI / release builds to use the latest Go version. It also
upgrades golangci-lint to a newer version compatible with Go 1.19.

In Go 1.19, godoc has gained official support for links and lists. The
syntax for code blocks in doc comments has changed and now requires a
leading tab character. gofmt adapts comments to the new syntax
automatically, so there are a lot of comment re-formatting changes in this
PR. We need to apply the new format in order to pass the CI lint stage with
Go 1.19.

With the linter upgrade, I have decided to disable 'gosec' - it produces
too many false-positive warnings. The 'deadcode' and 'varcheck' linters
have also been removed because golangci-lint warns about them being
unmaintained. 'unused' provides similar coverage and we already have it
enabled, so we don't lose much with this change.
2022-09-10 13:25:40 +02:00
aaronbuchwald
6c3fea0fc9
log: modify lock defer unlock order in sync handler (#24667)
This modifies the order of Lock() defer Unlock() to follow the more
typically used pattern.
2022-04-08 16:02:16 +02:00
Felix Lange
8a134014b4
all: add go:build lines (#23468)
Generated by go1.17 fmt ./...
2021-08-25 18:46:29 +02:00
Felix Lange
fda93f643e
log: fix formatting of big.Int (#22679)
* log: fix formatting of big.Int

The implementation of formatLogfmtBigInt had two issues: it crashed when
the number was actually large enough to hit the big integer case, and
modified the big.Int while formatting it.

* log: don't call FormatLogfmtInt64 for int16

* log: separate from decimals back, not front

Co-authored-by: Péter Szilágyi <peterke@gmail.com>
2021-04-16 09:27:16 +03:00