Python print command not shown in terminal log

Asked by hsm flxCore

In most installations I can modify a module by adding a print command ( print "hello"). After upgrading the specific module, the print line shows up in the terminal log. Now, suddenly, it doesn't do this anymore.
There may be a few differences: The server runs in daemon and I do not use the command line upgrade (-u module). On other installations I use this. Is there a reason to believe that this makes the difference?
Which code changes are then included in the application, and which are not?

Question information

Language:
English Edit question
Status:
Solved
For:
Odoo Server (MOVED TO GITHUB) Edit question
Assignee:
No assignee Edit question
Solved by:
hsm flxCore
Solved:
Last query:
Last reply:
Revision history for this message
Borja López Soilán (NeoPolus) (borjals) said :
#1

You may want to use the OpenERP logger instead of print, as print will only send the messages to the standard output, and under some circumstances daemons may have not standard output available (happened us with OpenERP on FreeBSD), or it may be just discarded.

Instead of:

    print "hello"

You may do:

   import netsvc
   netsvc.Logger().notifyChannel('my_module_or_tag', netsvc.LOG_DEBUG, "Hello")

It will get displayed on the OpenERP log (stdout or the configured output file) like this:

[2010-10-20 19:49:03,017] DEBUG:my_module_or_tag:Hello

Revision history for this message
hsm flxCore (hannes-smit) said :
#2

Thanks Borja, I will give this a try. It seems to be the right answer.