vocdoni-node icon indicating copy to clipboard operation
vocdoni-node copied to clipboard

WIP: log: allow more granular logging with --logLevel=component:level

Open altergui opened this issue 3 years ago • 8 comments

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

altergui avatar Feb 16 '22 20:02 altergui

(i did include a trivial nitpick to ipfssync.go) :eyes:

altergui avatar Feb 16 '22 20:02 altergui

LGTM

p4u avatar Feb 17 '22 10:02 p4u

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.

altergui avatar Feb 18 '22 15:02 altergui

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.

mvdan avatar Feb 18 '22 15:02 mvdan

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.

mvdan avatar Mar 01 '22 15:03 mvdan

@altergui there is something blocking this PR ?

jordipainan avatar Mar 10 '22 12:03 jordipainan

yeah, i need to address all the points of the review and push a better version

altergui avatar Mar 10 '22 12:03 altergui

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

jordipainan avatar Mar 10 '22 14:03 jordipainan

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.

altergui avatar Jan 27 '23 15:01 altergui