ofek / bit

Bitcoin made easy.
https://ofek.dev/bit/
MIT License
1.25k stars 216 forks source link

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

Open dc3l1ne opened 2 years ago

dc3l1ne commented 2 years ago

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 2 years ago

Can you submit a PR?

dc3l1ne commented 2 years ago

Hi, a PR has been submitted, please review