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