~therp-nl/openobject-server/7.0-lp1124130

« back to all changes in this revision

Viewing changes to openerp/netsvc.py

  • Committer: Vo Minh Thu
  • Date: 2013-02-06 10:34:59 UTC
  • Revision ID: vmt@openerp.com-20130206103459-2mmgagrh59c23804
[FIX] logging: sys.stdout has not a fileno() method when running behind mod_wsgi.

Show diffs side-by-side

added added

removed removed

Lines of Context:
186
186
        # Normal Handler on standard output
187
187
        handler = logging.StreamHandler(sys.stdout)
188
188
 
189
 
    if isinstance(handler, logging.StreamHandler) and os.isatty(handler.stream.fileno()):
 
189
    # Check that handler.stream has a fileno() method: when running OpenERP
 
190
    # behind Apache with mod_wsgi, handler.stream will have type mod_wsgi.Log,
 
191
    # which has no fileno() method. (mod_wsgi.Log is what is being bound to
 
192
    # sys.stderr when the logging.StreamHandler is being constructed above.)
 
193
    if isinstance(handler, logging.StreamHandler) \
 
194
        and hasattr(handler.stream, 'fileno') \
 
195
        and os.isatty(handler.stream.fileno()):
190
196
        formatter = ColoredFormatter(format)
191
197
    else:
192
198
        formatter = DBFormatter(format)