ofek/bit

logging in your project will damage other logging's output format

dc3l1ne opened this issue · 2 comments

Hi ofek!
Your peoject uselogging.debug directly to print debug log, if I defind a logger in my project using code

logger = logging.getLogger("MyLog")
handler  = logging.StreamHandler()
handler.setFormatter(logging.Formatter("%(asctime)s|%(levelname)s|%(name)s|%(message)s"))
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
logger.debug('some debug info')

This will print a normal debug info : 2022-07-12 14:38:40,173 DEBUG MyLog some debug info
Then I import bit to my project and send some coin

from bit import Key
my_key = Key(...)
outputs=[....]
my_key.send(outputs)

If I run logger.debug('some debug info') again, it will output 2 lines as below

2022-07-12 14:41:10,353	DEBUG	MyLog	some debug info
DEBUG:MyLog:some debug info

Because in bit.transaction.estimate_tx_fee you used logging.debug to print debug info, which corrupted my project logger,kindly recommend you to defind a logger in other py file and then import and use it

ofek commented

Can you submit a PR?

Hi, a PR has been submitted, please review