vocdoni-node
vocdoni-node copied to clipboard
WIP: log: allow more granular logging with --logLevel=component:level
note that this commit doesn't change any of the current logging behaviour, keeping backwards compatibility for code using log.Init()
to use granular logging, call log.InitWithLevels()
- fix Logger() since it was returning an unwrapped logger with CallerSkip(1)
- if using log.Named("somename"), prefix [somename] in logs
this addresses issue #460 "Reduce ipfsSync log messages", in an extensible way
supersedes #469, implementing @mvdan suggestion https://github.com/vocdoni/vocdoni-node/pull/469#issuecomment-1033037869
(i did include a trivial nitpick to ipfssync.go) :eyes:
LGTM
thanks for the review! i did look for ways to avoid renaming and cleaner init'ing, but couldn't wrap my head around it. will try again :) and rework this PR.
also, while hacking on this i noticed that both ipfs and tendermint have their own log
packages which (unsurprisingly) wrap zap and have the same features that i'm trying to develop, so i want to evaluate using them directly.
my 2c: neither tendermint nor go-ipfs guarantee any form of stability for their Go APIs, especially not for packages that aren't really intended for direct use, like logging. So I'd probably not want to use them.
Also: bear in mind that init
functions get run sequentially, so anything that they do doesn't require a mutex. You only need a mutex if any of the loggers are modified after they start being used asynchronously by different goroutines.
@altergui there is something blocking this PR ?
yeah, i need to address all the points of the review and push a better version
yeah, i need to address all the points of the review and push a better version
perfect! no rush just asked in the case there is something external that is blocking you. Thank you <3
i'm closing this PR since it would need a big rebase or rewrite from scratch, and i believe #746 might have solved the usecase for this feature, at least partially.