Remove code duplication in logging and refactor it a bit.
Remove code duplication in logging and refactor it a bit.

nopara73/HiddenWallet,nopara73/HiddenWallet,nopara73/HiddenWallet,nopara73/HiddenWallet