sql debug

Asked by fmarcks

Excuse me, I´m kindly new in OpenERP and I need to debug a module that´s not doing what suppose must do, and I want to log sql expressions that openerp needs in an specific module.

How can I show in the log file of the server the sql queries?

Thanks for your help.

Samuel

Question information

Language:
English Edit question
Status:
Answered
For:
OpenERP Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#1

Hello,

In openerp you can use following option related to logging configuration when you start the server in terminal:

  Logging Configuration:
    --logfile=LOGFILE file where the server log will be stored
    --syslog Send the log to the syslog server
    --log-level=LOG_LEVEL
                        specify the level of the logging. Accepted values:
                        ['info', 'debug_rpc', 'warn', 'critical', 'error',
                        'debug', 'notset']

Like following example:
./openerp-server --addons-path=<path> --loglevel=debug_rpc

Revision history for this message
fmarcks (fmarcks) said :
#2

Thanks for the answer but OpenERP is still not show the sql sentences to the postgresql DB, only show messages about modules or conection.

You know the specific log level which I can try?

I have tried with debug, debug-rpc, info but nothing happens.

Thanks.

Revision history for this message
Vinay Rana (OpenERP) (vra-openerp) said :
#3

Hello,

There is not any option available in tiny for that. So you need to manually trace the code by print statement.

Thanks.

Revision history for this message
Dhara Shah (OpenERP) (dsh-openerp) said :
#4

Hello fmarcks,

There is one option in cursor to start logging sql queries,turn it on for the code where you feel problem exists.
I hope following peace of code can help you to log sql expression..

def create(self,cr,uid,vals,context={}):
 cr.sql_log = True
""" Your code : you will be able to see sql query related to this code server side """
 cr.sql_log = False
 return super(res_partner,self).create(cr,uid,vals,context)

and start server with --log-level=debug option

I hope ,this will solve your problem .
Thanks,
Regards,
Dhara Shah

Can you help with this problem?

Provide an answer of your own, or ask fmarcks for more information if necessary.

To post a message you must log in.