ethersphere / bee

Bee is a Swarm client implemented in Go. It’s the basic building block for the Swarm network: a private; decentralized; and self-sustaining network for permissionless publishing and access to your (application) data.
https://www.ethswarm.org
BSD 3-Clause "New" or "Revised" License
1.44k stars 338 forks source link

Enabling loggerV2 logs? #4636

Open ldeffenb opened 3 months ago

ldeffenb commented 3 months ago

Context

2.0.0

Summary

Verbosity 5 logs don't show those coded as loggerV2?

Expected behavior

I would expect all coded logs to show up when running with --verbosity 5

Actual behavior

Logs that I see in the source do not appear in the log output. Consider: https://github.com/ethersphere/bee/blob/501f8a4ef9caddd2d080829270a77cdd67cf1573/pkg/puller/puller.go#L292 I KNOW that this node has pulled historical chunks, so why is this log not showing up? In fact, none of the "syncWorker" logs are in my log output. https://github.com/ethersphere/bee/blob/501f8a4ef9caddd2d080829270a77cdd67cf1573/pkg/puller/puller.go#L367

Steps to reproduce

Run a new node with --verbosity 5 and capture the log output. it will definitely need to pullsync the reserve from the swarm, but this log never shows up?

Possible solution

That's what I'm asking for! Is there a way for these p.logger.V(2).Register() logs to get into the output?

istae commented 2 months ago

you can get v2 loggers to print using the loggers API see https://docs.ethswarm.org/docs/bee/working-with-bee/logs-and-files#logging-api-usage the point of this whole feature was to get multiple levels of logging verbosity beyond the normal info->warning->debug albeit i do find it overly complex

ldeffenb commented 2 months ago

@istae So there's no way to enable it in the config or on the command line? And it doesn't follow the --verbosity settings either? Dumb and dumber, if you ask me!

ldeffenb commented 1 month ago

you can get v2 loggers to print using the loggers API

I cannot locate it right now, but I believe there are some v2 loggers that are dynamically created and destroyed. They are of such short duration that they are impossible to enable via the loggers API. Consider these 2 examples.

https://github.com/ethersphere/bee/blob/501f8a4ef9caddd2d080829270a77cdd67cf1573/pkg/puller/puller.go#L187-L190 https://github.com/ethersphere/bee/blob/501f8a4ef9caddd2d080829270a77cdd67cf1573/pkg/puller/puller.go#L291-L297 The first one of those exists only for the duration of cleaning up after a disconnect. The second lasts longer, but any attempt to enable it via the API will definitely miss the first set of logs from the newly created logger.