#
##############################################################################
-
import SimpleXMLRPCServer
import SocketServer
import logging
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
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
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):
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):
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"""
if db_name is None or db == db_name:
for timer in cls._timers[db]:
timer.cancel()
-
+
@classmethod
def quit(cls):
cls.cancel(None)
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()
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)