Commit graph

65 commits

Author SHA1 Message Date
wit liu
a83c43f240
all: use 0x-prefix string for type Address in log message (#1874) 2025-12-19 08:55:21 +04:00
Daniel Liu
c922f26d0c
all: replace strings.Split with more efficient strings.SplitSeq (#1698) 2025-12-07 15:42:23 +05:30
Daniel Liu
241a5b3fb2
all: using testing.B.Loop (#1554)
* p2p: using testing.B.Loop

* core/state: using testing.B.Loop

* eth: using testing.B.Loop

* log: using testing.B.Loop

* core: using testing.B.Loop

* core/vm: using testing.B.Loop

* core/types: using testing.B.Loop

* crypto: using testing.B.Loop
2025-09-24 07:59:48 +08:00
Daniel Liu
915c71f2c4
log: fix SetDefault for custom loggers #31368 (#1511)
Currently, even though it takes in a `Logger` interface,
`log.SetDefualt` enforces that the concrete type of the provided logger
is `*logger` because:
1. in `init` `root.Store` is called with a `*logger`
2. `atomic.Value` panics if the concrete type provided in `Store` is not
consistent across calls.
([ref](https://pkg.go.dev/sync/atomic#Value.Store))

> All calls to Store for a given Value must use values of the same
concrete type.

This PR changes to use `sync.RWMutex` and adds a test that panics on
`master`.

Co-authored-by: Stephen Buttolph <stephen@avalabs.org>
2025-09-17 08:28:13 +08:00
Daniel Liu
ba9fa91375
log: remove unused parameter #30432 (#1509)
Co-authored-by: asamuj <105436033+asamuj@users.noreply.github.com>
2025-09-17 08:26:34 +08:00
Daniel Liu
5bfaf068a4 log: fix issues with benchmarks (#30667) 2024-11-15 10:02:43 +08:00
Daniel Liu
54f8e028ca log: fix some functions comments (#29907)
updates some docstrings
---------

Co-authored-by: rjl493456442 <garyrong0905@gmail.com>
2024-11-15 10:02:43 +08:00
Daniel Liu
9e034475c8 log: default JSON log handler should log all verbosity levels (#29471)
Co-authored-by: lightclient <lightclient@protonmail.com>
2024-11-15 10:02:42 +08:00
Daniel Liu
368b2781ae log: using maps.Clone (#29392) 2024-11-15 10:02:42 +08:00
Daniel Liu
6831a49fea log: replace the outdated link (#29412) 2024-11-15 10:02:42 +08:00
Daniel Liu
946c085f9f log: use native log/slog instead of golang/exp (#29302) 2024-11-15 10:02:42 +08:00
Daniel Liu
40fd68a124 log: replace tmp with bytes.Buffer.AvailableBuffer (#29287) 2024-11-15 10:02:42 +08:00
Daniel Liu
20a62e4743 log: add Handler getter to Logger interface (#28793)
log: Add Handler getter to Logger interface
2024-11-15 10:02:42 +08:00
Daniel Liu
fb25ddfa57 log: fix docstring names (#28923) 2024-11-15 10:02:42 +08:00
Daniel Liu
966a03f297 log: emit error level string as "error", not "eror" (#28774) 2024-11-15 10:02:42 +08:00
Daniel Liu
31ceca5ef1 log: avoid setting default slog logger in init (#28747)
slog.SetDefault has undesirable side effects. It also sets the default logger destination,
for example. So we should not call it by default in init.
2024-11-15 10:02:42 +08:00
Daniel Liu
14acdf2dd1 log: remove lazy, remove unused interfaces, unexport methods (#28622)
This change

- Removes interface `log.Format`,
- Removes method `log.FormatFunc`,
- unexports `TerminalHandler.TerminalFormat` formatting methods (renamed to `TerminalHandler.format`)
- removes the notion of `log.Lazy` values

The lazy handler was useful in the old log package, since it
could defer the evaluation of costly attributes until later in the
log pipeline: thus, if the logging was done at 'Trace', we could
skip evaluation if logging only was set to 'Info'.

With the move to slog, this way of deferring evaluation is no longer
needed, since slog introduced 'Enabled': the caller can thus do
the evaluate-or-not decision at the callsite, which is much more
straight-forward than dealing with lazy reflect-based evaluation.

Also, lazy evaluation would not work with 'native' slog, as in, these
two statements would be evaluated differently:

```golang
  log.Info("foo", "my lazy", lazyObj)
  slog.Info("foo", "my lazy", lazyObj)
```
2024-11-15 10:02:42 +08:00
Daniel Liu
9ae7402e35 slog: faster and less memory-consumption (#28621)
These changes improves the performance of the non-coloured terminal formatting, _quite a lot_.

```
name               old time/op    new time/op    delta
TerminalHandler-8    10.2µs ±15%     5.4µs ± 9%  -47.02%  (p=0.008 n=5+5)

name               old alloc/op   new alloc/op   delta
TerminalHandler-8    2.17kB ± 0%    0.40kB ± 0%  -81.46%  (p=0.008 n=5+5)

name               old allocs/op  new allocs/op  delta
TerminalHandler-8      33.0 ± 0%       5.0 ± 0%  -84.85%  (p=0.008 n=5+5)
```

I tried to _somewhat_ organize the commits, but the it might still be a bit chaotic. Some core insights:

- The function `terminalHandler.Handl` uses a mutex, and writes all output immediately to 'upstream'. Thus, it can reuse a scratch-buffer every time.
- This buffer can be propagated internally, making all the internal formatters either write directly to it,
- OR, make  use of the `tmp := buf.AvailableBuffer()` in some cases, where a byte buffer "extra capacity" can be temporarily used.
- The `slog` package  uses `Attr` by value. It makes sense to minimize operating on them, since iterating / collecting into a new slice, iterating again etc causes copy-on-heap. Better to operate on them only once.
- If we want to do padding, it's better to copy from a constant `space`-buffer than to invoke `bytes.Repeat` every single time.
2024-11-15 10:02:42 +08:00
Daniel Liu
ec4ca1ed6a all: replace log15 with slog (#28187) 2024-11-15 10:02:42 +08:00
Daniel Liu
b04ce3213a log: test for logging-output (#28373) 2024-11-15 10:02:42 +08:00
Daniel Liu
f9cae3b9aa internal, log: remove code for old unsupported go-versions (#28090) 2024-11-15 10:02:42 +08:00
Daniel Liu
41c4c9ba88 log: avoid stack lookups when not needed/used (#28069) 2024-11-15 10:02:42 +08:00
Daniel Liu
6b81e68537 log: use atomic types (#27763)
Co-authored-by: Felix Lange <fjl@twurst.com>
2024-11-15 10:02:42 +08:00
Daniel Liu
f75958c0ac 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>
2024-11-15 10:02:42 +08:00
Daniel Liu
2359a9ed34 log: add special casing of uint256 into the logger (#26936) 2024-11-15 10:02:42 +08:00
Daniel Liu
5eca853e52 log: improve documentation (#26753)
Add usage examples
2024-11-15 10:02:42 +08:00
Daniel Liu
ed4f989ff3 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
2024-11-15 10:02:42 +08:00
Daniel Liu
dce80d77b7 log: better sanitation (#26556) 2024-11-15 10:02:42 +08:00
Daniel Liu
0902dcf37c 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.
2024-11-15 10:02:41 +08:00
Daniel Liu
07443431d3 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>
2024-11-15 10:02:41 +08:00
Daniel Liu
aedfea681b all: make logs a bit easier on the eye to digest (#22665) 2024-11-15 10:02:41 +08:00
Daniel Liu
3d21631145 log: fix typos in comments (#21118) 2024-11-15 10:02:41 +08:00
Daniel Liu
cd9e18984e log: properly escape character sequences (#20987) 2024-11-15 10:02:41 +08:00
Daniel Liu
25a7e096ff log: delete RotatingFileHandler (#20586) 2024-11-15 10:02:41 +08:00
Daniel Liu
4d9936574b log: fix staticcheck warnings (#20388) 2024-11-15 10:02:41 +08:00
Daniel Liu
6873ca0687 log: change http:// to https:// on links in README.md (#20178)
docs: change http to https on links in log/README.md
2024-11-15 10:02:41 +08:00
Daniel Liu
81f59cb0ee log: do not pad values longer than 40 characters (#19592)
* log: Do not pad too long values

* log: gofmt
2024-11-15 10:02:41 +08:00
Daniel Liu
7865057840 internal/debug: support color terminal for cygwin/msys2 (#17740) 2024-11-15 10:02:41 +08:00
Daniel Liu
49e889eb7c log: logging feature (#17097) 2024-11-15 10:02:41 +08:00
Daniel Liu
38e5efbfe4 log: Change time format (#17054)
- Keep the tailing zeros.
- Limit precision to milliseconds.
2024-11-15 10:02:41 +08:00
Daniel Liu
f391463457 log: fixes for golint warnings (#16775) 2024-11-15 10:02:41 +08:00
Daniel Liu
643f02356d log: changed if-else blocks to conform with golint (#16661) 2024-11-15 10:02:41 +08:00
Daniel Liu
a79411fa06 all: fix staticcheck warning ST1005: incorrectly formatted error string 2024-10-24 09:48:20 +08:00
olumuyiwadad
b5abbfed79 new EVM Upgrade
- Solidity Upgraded up to v0.8.0
-  Fixed and Added eth_chainId
- Fix error in TransactionRecipet
- Reward halving issue fixed
2021-09-21 16:53:46 +05:30
olumuyiwadad
571c41f891 FIx Bad block error. 2021-09-17 17:59:06 +05:30
HackyMiner
44eb69561a internal/debug: support color terminal for cygwin/msys2 (#17740)
- update go-colorable, go-isatty, go-runewidth packages
- use go-isatty instead of log/term and remove log/term package
2018-09-29 16:15:39 +02:00
Kurkó Mihály
a9835c1816 cmd, dashboard, log: log collection and exploration (#17097)
* cmd, dashboard, internal, log, node: logging feature

* cmd, dashboard, internal, log: requested changes

* dashboard, vendor: gofmt, govendor, use vendored file watcher

* dashboard, log: gofmt -s -w, goimports

* dashboard, log: gosimple
2018-07-11 10:59:04 +03:00
Paweł Bylica
6d8a1bfb08
log: Change time format
- Keep the tailing zeros.
- Limit precision to milliseconds.
2018-06-25 11:22:23 +02:00
Elad
1836366ac1 all: library changes for swarm-network-rewrite (#16898)
This commit adds all changes needed for the merge of swarm-network-rewrite.
The changes:

- build: increase linter timeout
- contracts/ens: export ensNode
- log: add Output method and enable fractional seconds in format
- metrics: relax test timeout
- p2p: reduced some log levels, updates to simulation packages
- rpc: increased maxClientSubscriptionBuffer to 20000
2018-06-14 11:21:17 +02:00
kiel barry
09d44247f7 log: fixes for golint warnings (#16775) 2018-05-22 10:28:43 +03:00