[IMP] openerp.loglevels: removed calls to openerp.loglevels.Logger().

bzr revid: vmt@openerp.com-20120124173017-c66z3kq11wmbrrke
This commit is contained in:
Vo Minh Thu 2012-01-24 18:30:17 +01:00
parent 402bddc06a
commit f057f2afa5
8 changed files with 37 additions and 34 deletions

View File

@ -19,12 +19,15 @@
#
##############################################################################
import logging
import time, os
import netsvc
import report,pooler,tools
from operator import itemgetter
_logger = logging.getLogger(__name__)
def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows):
import pydot
cr.execute('select * from wkf_activity where wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
@ -126,13 +129,12 @@ def graph_instance_get(cr, graph, inst_id, nested=False):
class report_graph_instance(object):
def __init__(self, cr, uid, ids, data):
logger = netsvc.Logger()
try:
import pydot
except Exception,e:
logger.notifyChannel('workflow', netsvc.LOG_WARNING,
'Import Error for pydot, you will not be able to render workflows\n'
'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html')
_logger.warning(
'Import Error for pydot, you will not be able to render workflows.\n'
'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html.')
raise e
self.done = False
@ -170,7 +172,7 @@ showpage'''
except Exception, e:
import traceback, sys
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
logger.notifyChannel('workflow', netsvc.LOG_ERROR, 'Exception in call: ' + tb_s)
_logger.error('Exception in call: ' + tb_s)
# string is in PS, like the success message would have been
ps_string = '''%PS-Adobe-3.0
/inch {72 mul} def

View File

@ -1797,7 +1797,7 @@ class BaseModel(object):
res.insert(0, ("Can't find field '%s' in the following view parts composing the view of object model '%s':" % (field, model), None))
msg = "\n * ".join([r[0] for r in res])
msg += "\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model"
netsvc.Logger().notifyChannel('orm', netsvc.LOG_ERROR, msg)
_logger.error(msg)
raise except_orm('View error', msg)
return arch, fields
@ -2970,7 +2970,7 @@ class BaseModel(object):
query = 'UPDATE "%s" SET "%s"=%s' % (self._table, k, ss[0])
cr.execute(query, (ss[1](default),))
cr.commit()
netsvc.Logger().notifyChannel('data', netsvc.LOG_DEBUG, "Table '%s': setting default value of new column %s" % (self._table, k))
_logger.debug("Table '%s': setting default value of new column %s", self._table, k)
# remember the functions to call for the stored fields
if isinstance(f, fields.function):

View File

@ -18,6 +18,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import logging
import mako
from lxml import etree
from mako.template import Template
@ -25,6 +26,8 @@ from mako.lookup import TemplateLookup
import openerp.netsvc as netsvc
import traceback, sys, os
_logger = logging.getLogger(__name__)
class makohtml2html(object):
def __init__(self, html, localcontext):
self.localcontext = localcontext
@ -125,8 +128,7 @@ class makohtml2html(object):
return final_html
except Exception,e:
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR,
'report :\n%s\n%s\n' % (tb_s, str(e)))
_logger.error('report :\n%s\n%s\n', tb_s, str(e))
def parseNode(html, localcontext = {}):
r = makohtml2html(html, localcontext)

View File

@ -110,8 +110,7 @@ class TinySocketServerThread(threading.Thread,netsvc.Server):
self.socket.bind((self.__interface, self.__port))
self.socket.listen(5)
self.threads = []
netsvc.Logger().notifyChannel("web-services", netsvc.LOG_INFO,
"starting NET-RPC service on %s:%s" % (interface or '0.0.0.0', port,))
_logger.info("starting NET-RPC service on %s:%s", interface or '0.0.0.0', port)
def run(self):
try:

View File

@ -339,10 +339,9 @@ class db(netsvc.ExportService):
from openerp.osv.orm import except_orm
from openerp.osv.osv import except_osv
l = netsvc.Logger()
for db in databases:
try:
l.notifyChannel('migration', netsvc.LOG_INFO, 'migrate database %s' % (db,))
_logger.info('migrate database %s', db)
tools.config['update']['base'] = True
pooler.restart_pool(db, force_demo=False, update_module=True)
except except_orm, inst:
@ -352,7 +351,7 @@ class db(netsvc.ExportService):
except Exception:
import traceback
tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
l.notifyChannel('web-services', netsvc.LOG_ERROR, tb_s)
_logger.error(tb_s)
raise
return True
@ -428,7 +427,6 @@ GNU Public Licence.
def exp_get_migration_scripts(self, contract_id, contract_password):
l = netsvc.Logger()
import openerp.tools.maintenance as tm
try:
rc = tm.remote_contract(contract_id, contract_password)
@ -437,7 +435,7 @@ GNU Public Licence.
if rc.status != 'full':
raise tm.RemoteContractException('Can not get updates for a partial contract')
l.notifyChannel('migration', netsvc.LOG_INFO, 'starting migration with contract %s' % (rc.name,))
_logger.info('starting migration with contract %s', rc.name)
zips = rc.retrieve_updates(rc.id, openerp.modules.get_modules_with_version())
@ -445,12 +443,12 @@ GNU Public Licence.
backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
if zips and not os.path.isdir(backup_directory):
l.notifyChannel('migration', netsvc.LOG_INFO, 'create a new backup directory to \
store the old modules: %s' % (backup_directory,))
_logger.info('create a new backup directory to \
store the old modules: %s', backup_directory)
os.makedirs(backup_directory)
for module in zips:
l.notifyChannel('migration', netsvc.LOG_INFO, 'upgrade module %s' % (module,))
_logger.info('upgrade module %s', module)
mp = openerp.modules.get_module_path(module)
if mp:
if os.path.isdir(mp):
@ -467,7 +465,7 @@ GNU Public Licence.
try:
base64_decoded = base64.decodestring(zips[module])
except Exception:
l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to read the module %s' % (module,))
_logger.error('unable to read the module %s', module)
raise
zip_contents = StringIO(base64_decoded)
@ -476,13 +474,13 @@ GNU Public Licence.
try:
tools.extract_zip_file(zip_contents, tools.config['addons_path'] )
except Exception:
l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to extract the module %s' % (module, ))
_logger.error('unable to extract the module %s', module)
rmtree(module)
raise
finally:
zip_contents.close()
except Exception:
l.notifyChannel('migration', netsvc.LOG_ERROR, 'restore the previous version of the module %s' % (module, ))
_logger.error('restore the previous version of the module %s', module)
nmp = os.path.join(backup_directory, module)
if os.path.isdir(nmp):
copytree(nmp, tools.config['addons_path'])
@ -496,7 +494,7 @@ GNU Public Licence.
except Exception, e:
import traceback
tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
l.notifyChannel('migration', netsvc.LOG_ERROR, tb_s)
_logger.error(tb_s)
raise
def exp_get_server_environment(self):
@ -527,8 +525,8 @@ GNU Public Licence.
return tools.config.get('login_message', False)
def exp_set_loglevel(self, loglevel, logger=None):
l = netsvc.Logger()
l.set_loglevel(int(loglevel), logger)
# TODO Previously, the level was set on the now deprecated
# `openerp.netsvc.Logger` class.
return True
def exp_get_stats(self):

View File

@ -19,10 +19,14 @@
#
##############################################################################
import logging
from translate import _
_logger = logging.getLogger(__name__)
#-------------------------------------------------------------
#ENGLISH
#-------------------------------------------------------------
from translate import _
to_19 = ( 'Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six',
'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen',
@ -105,11 +109,11 @@ def amount_to_text(nbr, lang='en', currency='euro'):
"""
import openerp.loglevels as loglevels
# if nbr > 10000000:
# netsvc.Logger().notifyChannel('translate', netsvc.LOG_WARNING, _("Number too large '%d', can not translate it"))
# _logger.warning(_("Number too large '%d', can not translate it"))
# return str(nbr)
if not _translate_funcs.has_key(lang):
loglevels.Logger().notifyChannel('translate', loglevels.LOG_WARNING, _("no translation function found for lang: '%s'" % (lang,)))
_logger.warning(_("no translation function found for lang: '%s'"), lang)
#TODO: (default should be en) same as above
lang = 'en'
return _translate_funcs[lang](abs(nbr), currency)

View File

@ -20,6 +20,7 @@
##############################################################################
import copy
import logging
import openerp.netsvc as netsvc
from openerp.tools.misc import UpdateableStr, UpdateableDict
@ -30,10 +31,11 @@ import openerp.pooler as pooler
from openerp.osv.osv import except_osv
from openerp.osv.orm import except_orm
from openerp.netsvc import Logger, LOG_ERROR
import sys
import warnings
_logger = logging.getLogger(__name__)
class except_wizard(Exception):
def __init__(self, name, value):
self.name = name
@ -170,9 +172,7 @@ class interface(netsvc.Service):
import traceback
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(
sys.exc_type, sys.exc_value, sys.exc_traceback))
logger = Logger()
logger.notifyChannel("web-services", LOG_ERROR,
'Exception in call: ' + tb_s)
_logger.error('Exception in call: ' + tb_s)
raise
return res

View File

@ -34,8 +34,6 @@ def log(cr,ident,act_id,info=''):
#info: %s
#""" % (ident[1], ident[2], ident[0], act_id, info)
#netsvc.Logger().notifyChannel('wkf_log', netsvc.LOG_DEBUG, msg)
#cr.execute('insert into wkf_logs (res_type, res_id, uid, act_id, time, info) values (%s,%s,%s,%s,current_time,%s)', (ident[1],int(ident[2]),int(ident[0]),int(act_id),info))
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: