web2py / py4web

Other
263 stars 129 forks source link

Give a way to disable logging of errors in py4web's error table #554

Closed lucadealfaro closed 2 years ago

lucadealfaro commented 3 years ago

py4web tries to log errors in its internal table. The problem is that, when py4web is deployed, this breaks things, because often (e.g., on a readonly file system), the sqlite database where py4web tries to log errors is simply not available. There needs to be a way to say "py4web, please, stop doing your thing with that error ticket table. Just let the errors go to the logs".

lucadealfaro commented 3 years ago

A student commented:

i was able to get around that by setting the os.environ['PY4WEB_SERVICE_DB_URI'] variable of main.py (located in the gae folder) to the uri of cloud mysql database

But one should be able to do without the service db altogether in deployment.

KellerKev commented 3 years ago

I like this db error table feature a lot and now even more so that I know that I can even log it into a separate db. But I get that some environments benefit from the logs are just thrown in the terminal. Maybe we can find a way to enable / disable db logging. If disabled logs go into the terminal again instead of the db.

On Mon, Jun 7, 2021, 21:21 Luca de Alfaro @.***> wrote:

A student commented:

i was able to get around that by setting the os.environ['PY4WEB_SERVICE_DB_URI'] variable of main.py (located in the gae folder) to the uri of cloud mysql database

But one should be able to do without the service db altogether in deployment.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/554#issuecomment-856194748, or unsubscribe https://github.com/notifications/unsubscribe-auth/AB224IBF6KIULXOEF2AD6QLTRUL4NANCNFSM46IJ6XRA .

lucadealfaro commented 3 years ago

Yes, this could be a simple configuration option. The error table is great in some applications, but it is a hindrance when you deploy e.g. on the google cloud or other places where there is already a sophisticated logging system in place, and you don't want py4web to create "under the radar screen" another table for you. There are times you don't want the web server to do more than needed.

mdipierro commented 3 years ago

Currently the logic is:

try:
    log error in database  # fails on GAE
except:
    logging.error(the previous traceback)  # on GAE

Can you please double check. Is this now working as intended?

agavgavi commented 3 years ago

Could the issue be arising from the constructor of ErrorStorage trying to create a database table? That might not be caught in the try/except which could lead to an issue.

On the other hand if that is caught it may be that Luca is just asking for the option to disable it which I feel is a good case, it's always worthwhile to have options.

mdipierro commented 3 years ago

The constructor is also called in the try except. It should be caught. I just did a minor change to the logic anyway, would it be easy to try again and let me know what you see?

On Mon, Jun 7, 2021 at 11:09 PM Andrew Gavgavian @.***> wrote:

Could the issue be arising from the constructor of ErrorStorage trying to create a database table? That might not be caught in the try/except which could lead to an issue.

On the other hand if that is caught it may be that Luca is just asking for the option to disable it which I feel is a good case, it's always worthwhile to have options.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/web2py/py4web/issues/554#issuecomment-856475750, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHLZT2FVJXEMDR3NXTHQX3TRWXZDANCNFSM46IJ6XRA .

mdipierro commented 2 years ago

We added "py4web run apps --logfile=:stdout|:stderr|{filename}"