[IMP]:Environment Information
bzr revid: nch@tinyerp.com-20090707100207-kmfwmpks7kis1v7b
This commit is contained in:
parent
2b82c3148c
commit
8f300df195
|
@ -24,7 +24,6 @@
|
|||
#
|
||||
##############################################################################
|
||||
|
||||
|
||||
import SimpleXMLRPCServer
|
||||
import SocketServer
|
||||
import logging
|
||||
|
@ -95,7 +94,7 @@ def init_logger():
|
|||
logger = logging.getLogger()
|
||||
# create a format for log messages and dates
|
||||
formatter = logging.Formatter('[%(asctime)s] %(levelname)s:%(name)s:%(message)s')
|
||||
|
||||
|
||||
logging_to_stdout = False
|
||||
if tools.config['syslog']:
|
||||
# SysLog Handler
|
||||
|
@ -117,7 +116,7 @@ def init_logger():
|
|||
handler = logging.handlers.TimedRotatingFileHandler(logf,'D',1,30)
|
||||
except Exception, ex:
|
||||
sys.stderr.write("ERROR: couldn't create the logfile directory. Logging to the standard output.\n")
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
handler = logging.StreamHandler(sys.stdout)
|
||||
logging_to_stdout = True
|
||||
else:
|
||||
# Normal Handler on standard output
|
||||
|
@ -156,7 +155,10 @@ def init_logger():
|
|||
|
||||
|
||||
class Logger(object):
|
||||
|
||||
def notifyChannel(self, name, level, msg):
|
||||
from service.web_services import common
|
||||
|
||||
log = logging.getLogger(tools.ustr(name))
|
||||
|
||||
if level == LOG_DEBUG_RPC and not hasattr(log, level):
|
||||
|
@ -168,6 +170,9 @@ class Logger(object):
|
|||
if isinstance(msg, Exception):
|
||||
msg = tools.exception_to_unicode(msg)
|
||||
|
||||
if level in (LOG_ERROR,LOG_CRITICAL):
|
||||
msg = common().get_server_environment() + msg
|
||||
|
||||
result = tools.ustr(msg).strip().split('\n')
|
||||
if len(result)>1:
|
||||
for idx, s in enumerate(result):
|
||||
|
@ -197,7 +202,7 @@ class Agent(object):
|
|||
for timer in self._timers[db]:
|
||||
if not timer.isAlive():
|
||||
self._timers[db].remove(timer)
|
||||
|
||||
|
||||
@classmethod
|
||||
def cancel(cls, db_name):
|
||||
"""Cancel all timers for a given database. If None passed, all timers are cancelled"""
|
||||
|
@ -205,7 +210,7 @@ class Agent(object):
|
|||
if db_name is None or db == db_name:
|
||||
for timer in cls._timers[db]:
|
||||
timer.cancel()
|
||||
|
||||
|
||||
@classmethod
|
||||
def quit(cls):
|
||||
cls.cancel(None)
|
||||
|
|
|
@ -505,27 +505,22 @@ GNU Public Licence.
|
|||
l.notifyChannel('migration', netsvc.LOG_ERROR, tb_s)
|
||||
raise
|
||||
|
||||
def get_server_environment(self,lang=False):
|
||||
def get_server_environment(self):
|
||||
try:
|
||||
if '.bzr' in os.listdir((os.getcwd()[0:-3])):
|
||||
fp = open(os.path.join(os.getcwd()[0:-3],'.bzr/branch/last-revision'))
|
||||
rev_no = fp.read()
|
||||
fp.close()
|
||||
else:
|
||||
rev_no = 'Bazaar Not Installed !'
|
||||
except:
|
||||
rev_no = 'Bazaar Not Installed !'
|
||||
if not lang:
|
||||
lang = os.environ.get('LANG', '').split('.')[0]
|
||||
environment = 'Environment_Information : \n' \
|
||||
'Operating System : %s\n' \
|
||||
rev_no = os.popen('bzr revno').read()
|
||||
except Exception,e:
|
||||
bzr_info = 'Exception: %s\n' % (str(e))
|
||||
|
||||
os_lang = os.environ.get('LANG', '').split('.')[0]
|
||||
environment = '\nEnvironment_Information : \n' \
|
||||
'PlatForm : %s\n' \
|
||||
'Operating System : %s\n' \
|
||||
'Operating System Version : %s\n' \
|
||||
'Operating System Locale : %s\n'\
|
||||
'Python Version : %s\n'\
|
||||
'Locale : %s\n' \
|
||||
'OpenERP-Server Version : %s\n'\
|
||||
'OpenERP-Server Last Revision ID : %s' \
|
||||
%(os.name,sys.platform,str(sys.version.split('\n')[1]),str(sys.version[0:5]), lang, release.version,rev_no)
|
||||
'Last revision no: %s' \
|
||||
%(sys.platform,os.name,str(sys.version.split('\n')[1]),os_lang,str(sys.version[0:5]),release.version,rev_no)
|
||||
return environment
|
||||
common()
|
||||
|
||||
|
@ -660,7 +655,6 @@ class report_spool(netsvc.Service):
|
|||
tb = sys.exc_info()
|
||||
tb_s = "".join(traceback.format_exception(*tb))
|
||||
logger = netsvc.Logger()
|
||||
logger.notifyChannel('web-services', netsvc.LOG_ERROR,common().get_server_environment(context.get('lang',False)))
|
||||
logger.notifyChannel('web-services', netsvc.LOG_ERROR,
|
||||
'Exception: %s\n%s' % (str(exception), tb_s))
|
||||
self._reports[id]['exception'] = ExceptionWithTraceback(tools.exception_to_unicode(exception), tb)
|
||||
|
|
Loading…
Reference in New Issue