#42 debug SQL queries recorded through logging module

closed-accepted
Oleg Broytman
None
5
2007-02-22
2006-01-28
No

The patch adds support for standard logging module for
DBConnection classes which is crucial for using
sqlobject in cgi scripts -- you can't use STDOUT
because it is sent to the browser.

Logging is activated if user specifies logger key, the
key also serves as a logger name to be used.

This is a duplicate of the previous ticket, only with a
file attacheed (hope so).

Discussion

  • patch to add logging support to DBConnection

     
  • Oleg Broytman
    Oleg Broytman
    2006-01-31

    • status: open --> open-invalid
     
  • Oleg Broytman
    Oleg Broytman
    2006-01-31

    Logged In: YES
    user_id=4799

    Module logging is only available in Python 2.3. SQLObject is
    supposed to work with Python 2.2. You have to catch
    ImportError and provide a graceful fallback.

    After 0.8 I'd like to deprecate support for Python 2.2.

     
  • Logged In: YES
    user_id=113894

    Oleg, I was considered checking for logging module but then
    decided that if a person specifies 'logger' parameter to db
    connection then he should know what he's doing.

    If you insist, I can add some way of handling this error but
    please elaborate how exactly do you want me to handle it.

     
  • Oleg Broytman
    Oleg Broytman
    2006-01-31

    • status: open-invalid --> open
     
  • Oleg Broytman
    Oleg Broytman
    2006-01-31

    Logged In: YES
    user_id=4799

    Aha, that's better. Can you aslo add a test that sets up a
    logger (logging to a stderr or a separate file) and a patch
    for documentation (describe the "logger" keyword in a DB URI)?

     
  • Logged In: YES
    user_id=113894

    Here is new patch

     
  • new version; includes error handling, doc and logging test setup

     
  • Oleg Broytman
    Oleg Broytman
    2006-02-03

    Logged In: YES
    user_id=4799

    I see you patch sqlobject/tests/dbtest.py but do not create
    any test. If it's not too hard can you also add a test that
    at least call setupLogging() and run a few SQL queries to
    make sure logging works. Even better - log to a file and
    test if the file contains what is expected.

     
  • Logged In: YES
    user_id=113894

    Oleg, I spent half an hour the other day trying to
    create/run a test but haven't succeed. So, no, I cannot
    provide a test.

    I you're not willing to submit the patch in the current
    form, well, so be it.

     
  • Oleg Broytman
    Oleg Broytman
    2006-02-03

    Logged In: YES
    user_id=4799

    Can I remove setupLogging() from dbtest.py?

    PS. What's the problem with tests?

     
  • Oleg Broytman
    Oleg Broytman
    2007-02-22

    Logged In: YES
    user_id=4799
    Originator: NO

    It's finally applied to the trunk in the revision 2344. Thank you for the job and patience!

    I extended the patch and docs a bit - add 'loglevel'.

     
  • Oleg Broytman
    Oleg Broytman
    2007-02-22

    • assigned_to: nobody --> phd
    • status: open --> closed-accepted