From 941f6ebc104f5bd49cd3670169dc795812d604ae Mon Sep 17 00:00:00 2001 From: Vo Minh Thu Date: Wed, 6 Feb 2013 11:34:59 +0100 Subject: [PATCH] [FIX] logging: sys.stdout has not a fileno() method when running behind mod_wsgi. bzr revid: vmt@openerp.com-20130206103459-2mmgagrh59c23804 --- openerp/netsvc.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/openerp/netsvc.py b/openerp/netsvc.py index 533b1659191..d6f9dc49d84 100644 --- a/openerp/netsvc.py +++ b/openerp/netsvc.py @@ -186,7 +186,13 @@ def init_logger(): # Normal Handler on standard output handler = logging.StreamHandler(sys.stdout) - if isinstance(handler, logging.StreamHandler) and os.isatty(handler.stream.fileno()): + # Check that handler.stream has a fileno() method: when running OpenERP + # behind Apache with mod_wsgi, handler.stream will have type mod_wsgi.Log, + # which has no fileno() method. (mod_wsgi.Log is what is being bound to + # sys.stderr when the logging.StreamHandler is being constructed above.) + if isinstance(handler, logging.StreamHandler) \ + and hasattr(handler.stream, 'fileno') \ + and os.isatty(handler.stream.fileno()): formatter = ColoredFormatter(format) else: formatter = DBFormatter(format)