Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Payment service] Missing attaching Formatter and StreamHandler to application logger #96

Open
joaomrcsmartins opened this issue May 19, 2022 · 0 comments

Comments

@joaomrcsmartins
Copy link

Hi team, I believe I've found a small bug in the payment service logging. I've been using your demo app (thanks btw for creating it and sharing it) as a "guinea pig" of sorts and particularly focused on the logs. When using the load generator with forced errors (bad calls to /api/payment/pay, I looked into the payment service.

There seems to be missing the part where the Formatter is attached to the StreamHandler and the handler to the logger.

sh = logging.StreamHandler(sys.stdout)
sh.setLevel(logging.INFO)
fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
app.logger.info('Payment gateway {}'.format(PAYMENT_GATEWAY))

It seems to be missing something like this:

sh = logging.StreamHandler(sys.stdout)
sh.setLevel(logging.INFO)
fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
sh.setFormatter(fmt)
app.logger.addHandler(sh)

Also, this part should be done before instantiating the RabbitMQ publisher since it passes the app logger as an argument:

# RabbitMQ
publisher = Publisher(app.logger)

Thanks again for the work to have this demo tool publicly open!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant