diff --git a/addons/account/account.py b/addons/account/account.py index 570227aef46..071350e8bd0 100644 --- a/addons/account/account.py +++ b/addons/account/account.py @@ -29,6 +29,7 @@ import pooler from osv import fields, osv import decimal_precision as dp from tools.translate import _ +_logger = logging.getLogger(__name__) def check_cycle(self, cr, uid, ids, context=None): """ climbs the ``self._table.parent_id`` chains for 100 levels or @@ -294,7 +295,7 @@ class account_account(osv.osv): if aml_query.strip(): wheres.append(aml_query.strip()) filters = " AND ".join(wheres) - logging.getLogger('account').debug('Filters: %s'%filters) + _logger.debug('Filters: %s'%filters) # IN might not work ideally in case there are too many # children_and_consolidated, in that case join on a # values() e.g.: @@ -310,7 +311,7 @@ class account_account(osv.osv): " GROUP BY l.account_id") params = (tuple(children_and_consolidated),) + query_params cr.execute(request, params) - logging.getLogger('account').debug('Status: %s'%cr.statusmessage) + _logger.debug('Status: %s'%cr.statusmessage) for res in cr.dictfetchall(): accounts[res['id']] = res @@ -2094,7 +2095,7 @@ class account_tax(osv.osv): } def compute(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None): - logging.getLogger('account').debug("Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included") + _logger.debug("Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included") return self._compute(cr, uid, taxes, price_unit, quantity, product, partner) def _compute(self, cr, uid, taxes, price_unit, quantity, product=None, partner=None): diff --git a/addons/account/installer.py b/addons/account/installer.py index 6cf52f58f6c..541929c35e9 100644 --- a/addons/account/installer.py +++ b/addons/account/installer.py @@ -30,11 +30,11 @@ from tools.translate import _ from osv import fields, osv import netsvc import tools +_logger = logging.getLogger(__name__) class account_installer(osv.osv_memory): _name = 'account.installer' _inherit = 'res.config.installer' - __logger = logging.getLogger(_name) def _get_charts(self, cr, uid, context=None): modules = self.pool.get('ir.module.module') @@ -149,7 +149,7 @@ class account_installer(osv.osv_memory): cr, uid, ids, context=context) chart = self.read(cr, uid, ids, ['charts'], context=context)[0]['charts'] - self.__logger.debug('Installing chart of accounts %s', chart) + self._logger.debug('Installing chart of accounts %s', chart) return modules | set([chart]) account_installer() diff --git a/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py b/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py index cc412092ccf..5dcaafe4845 100644 --- a/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py +++ b/addons/account_bank_statement_extensions/report/bank_statement_balance_report.py @@ -24,11 +24,12 @@ import time from report import report_sxw import pooler import logging +_logger = logging.getLogger(__name__) class bank_statement_balance_report(report_sxw.rml_parse): def set_context(self, objects, data, ids, report_type=None): - #logging('bank.statement.balance.report').warning('addons.'+__name__, 'set_context, objects = %s, data = %s, ids = %s' % (objects, data, ids)) + #_logger.warning('addons.'+__name__, 'set_context, objects = %s, data = %s, ids = %s' % (objects, data, ids)) cr = self.cr uid = self.uid context = self.context diff --git a/addons/account_coda/wizard/account_coda_import.py b/addons/account_coda/wizard/account_coda_import.py index 9d32d80f0c5..daa8bbd1026 100644 --- a/addons/account_coda/wizard/account_coda_import.py +++ b/addons/account_coda/wizard/account_coda_import.py @@ -28,6 +28,7 @@ import logging import re from traceback import format_exception from sys import exc_info +_logger = logging.getLogger(__name__) class account_coda_import(osv.osv_memory): _name = 'account.coda.import' @@ -815,7 +816,7 @@ class account_coda_import(osv.osv_memory): ttype = line['type'] == 'supplier' and 'payment' or 'receipt', date = line['val_date'], context = context) - #logging('account.coda').warning('voucher_dict = %s' % voucher_dict) + #_logger.warning('voucher_dict = %s' % voucher_dict) voucher_line_vals = False if voucher_dict['value']['line_ids']: for line_dict in voucher_dict['value']['line_ids']: @@ -888,19 +889,19 @@ class account_coda_import(osv.osv_memory): nb_err += 1 err_string += _('\nError ! ') + str(e) tb = ''.join(format_exception(*exc_info())) - logging('account.coda').error('Application Error while processing Statement %s\n%s' % (statement.get('name', '/'),tb)) + _logger.error('Application Error while processing Statement %s\n%s' % (statement.get('name', '/'),tb)) except Exception, e: cr.rollback() nb_err += 1 err_string += _('\nSystem Error : ') + str(e) tb = ''.join(format_exception(*exc_info())) - logging('account.coda').error('System Error while processing Statement %s\n%s' % (statement.get('name', '/'),tb)) + _logger.error('System Error while processing Statement %s\n%s' % (statement.get('name', '/'),tb)) except : cr.rollback() nb_err += 1 err_string = _('\nUnknown Error : ') + str(e) tb = ''.join(format_exception(*exc_info())) - logging('account.coda').error('Unknown Error while processing Statement %s\n%s' % (statement.get('name', '/'),tb)) + _logger.error('Unknown Error while processing Statement %s\n%s' % (statement.get('name', '/'),tb)) # end 'for statement in coda_statements' diff --git a/addons/auth_openid/controllers/main.py b/addons/auth_openid/controllers/main.py index af30566a643..0ee7f98a020 100644 --- a/addons/auth_openid/controllers/main.py +++ b/addons/auth_openid/controllers/main.py @@ -44,8 +44,8 @@ from .. import utils -_logger = logging.getLogger('web.auth_openid') -oidutil.log = logging.getLogger('openid').debug +_logger = logging.getLogger(__name__) +oidutil.log = _logger.debug class GoogleAppsAwareConsumer(consumer.GenericConsumer): diff --git a/addons/base_crypt/crypt.py b/addons/base_crypt/crypt.py index 9b91f7d3108..8a9d1ac1dc7 100644 --- a/addons/base_crypt/crypt.py +++ b/addons/base_crypt/crypt.py @@ -42,8 +42,10 @@ from osv import fields,osv import pooler from tools.translate import _ from service import security +import logging magic_md5 = '$1$' +_logger = logging.getLogger(__name__) def gen_salt( length=8, symbols=ascii_letters + digits ): seed() @@ -179,8 +181,7 @@ class users(osv.osv): cr = pooler.get_db(db).cursor() return self._login(cr, db, login, password) except Exception: - import logging - logging.getLogger('netsvc').exception('Could not authenticate') + _logger.exception('Could not authenticate') return Exception('Access Denied') finally: if cr is not None: diff --git a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py index 2aab8596862..42198337450 100644 --- a/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py +++ b/addons/base_report_designer/plugin/openerp_report_designer/bin/script/lib/logreport.py @@ -27,21 +27,20 @@ LOG_INFO='info' LOG_WARNING='warn' LOG_ERROR='error' LOG_CRITICAL='critical' +_logger = logging.getLogger(__name__) def log_detail(self): import os - logger = logging.getLogger() logfile_name = os.path.join(tempfile.gettempdir(), "openerp_report_designer.log") hdlr = logging.FileHandler(logfile_name) formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s') hdlr.setFormatter(formatter) - logger.addHandler(hdlr) - logger.setLevel(logging.INFO) + _logger.addHandler(hdlr) + _logger.setLevel(logging.INFO) class Logger(object): def log_write(self,name,level,msg): - log = logging.getLogger(name) - getattr(log,level)(msg) + getattr(_logger,level)(msg) def shutdown(self): logging.shutdown() diff --git a/addons/base_vat/base_vat.py b/addons/base_vat/base_vat.py index 7b8363ffd6b..e76442b62fe 100644 --- a/addons/base_vat/base_vat.py +++ b/addons/base_vat/base_vat.py @@ -23,11 +23,12 @@ import logging import string import datetime import re +_logger = logging.getLogger(__name__) try: import vatnumber except ImportError: - logging.getLogger('base_vat').warning("VAT validation partially unavailable because the `vatnumber` Python library cannot be found. " + _logger.warning("VAT validation partially unavailable because the `vatnumber` Python library cannot be found. " "Install it to support more countries, for example with `easy_install vatnumber`.") vatnumber = None diff --git a/addons/caldav/caldav_node.py b/addons/caldav/caldav_node.py index 71e9bdc2468..da5c5f017a6 100644 --- a/addons/caldav/caldav_node.py +++ b/addons/caldav/caldav_node.py @@ -23,6 +23,7 @@ from document_webdav import nodes from document.nodes import _str2time, nodefd_static import logging from orm_utils import get_last_modified +_logger = logging.getLogger(__name__) try: from tools.dict_tools import dict_merge2 @@ -223,7 +224,6 @@ class node_calendar(nodes.node_class): res = [] if not filters: return res - _log = logging.getLogger('caldav.query') if filters.localName == 'calendar-query': res = [] for filter_child in filters.childNodes: diff --git a/addons/caldav/calendar.py b/addons/caldav/calendar.py index 94d28e4ad37..b72f524f2be 100644 --- a/addons/caldav/calendar.py +++ b/addons/caldav/calendar.py @@ -34,6 +34,7 @@ import logging from caldav_node import res_node_calendar from orm_utils import get_last_modified from tools.safe_eval import safe_eval as eval +_logger = logging.getLogger(__name__) try: import vobject @@ -240,7 +241,6 @@ def map_data(cr, uid, obj, context=None): class CalDAV(object): __attribute__ = {} - _logger = logging.getLogger('document.caldav') def ical_set(self, name, value, type): """ set calendar Attribute diff --git a/addons/caldav/calendar_collection.py b/addons/caldav/calendar_collection.py index 1abbf573ef0..3a5604b2f67 100644 --- a/addons/caldav/calendar_collection.py +++ b/addons/caldav/calendar_collection.py @@ -23,6 +23,7 @@ from osv import osv, fields from tools.translate import _ import caldav_node import logging +_logger = logging.getLogger(__name__) class calendar_collection(osv.osv): _inherit = 'document.directory' @@ -44,8 +45,7 @@ class calendar_collection(osv.osv): root_cal_dir = self.browse(cr,uid, root_id, context=context) return root_cal_dir.name except Exception: - logger = logging.getLogger('document') - logger.warning('Cannot set root directory for Calendars:', exc_info=True) + _logger.warning('Cannot set root directory for Calendars:', exc_info=True) return False return False diff --git a/addons/crm/crm_meeting.py b/addons/crm/crm_meeting.py index cadd813a959..1e21d535c55 100644 --- a/addons/crm/crm_meeting.py +++ b/addons/crm/crm_meeting.py @@ -26,6 +26,7 @@ import logging from osv import fields, osv import tools from tools.translate import _ +_logger = logging.getLogger(__name__) class crm_lead(base_stage, osv.osv): """ CRM Leads """ @@ -180,7 +181,7 @@ class res_users(osv.osv): 'user_id': user_id}, context=context) except: # Tolerate a missing shortcut. See product/product.py for similar code. - logging.getLogger('orm').debug('Skipped meetings shortcut for user "%s"', data.get('name',' value and each data_i have a external id => in data_id['id'] """ - self.logger.info(' Importing %s into %s' % (table, model)) + _logger.info(' Importing %s into %s' % (table, model)) if not datas: return (0, 'No data found') mapping['id'] = 'id_new' @@ -188,7 +187,7 @@ class import_framework(Thread): model_obj = self.obj.pool.get(model) if not model_obj: raise ValueError(_("%s is not a valid model name") % model) - self.logger.debug(_(" fields imported : ") + str(fields)) + _logger.debug(_(" fields imported : ") + str(fields)) (p, r, warning, s) = model_obj.import_data(self.cr, self.uid, fields, res, mode='update', current_module=self.module_name, noupdate=True, context=self.context) for (field, field_name) in self_dependencies: self._import_self_dependencies(model_obj, field, datas) @@ -431,9 +430,9 @@ class import_framework(Thread): 'auto_delete' : True}) email_obj.send(self.cr, self.uid, [email_id]) if error: - self.logger.error(_("Import failed due to an unexpected error")) + _logger.error(_("Import failed due to an unexpected error")) else: - self.logger.info(_("Import finished, notification email sended")) + _logger.info(_("Import finished, notification email sended")) def get_email_subject(self, result, error=False): """ diff --git a/addons/import_sugarcrm/sugar.py b/addons/import_sugarcrm/sugar.py index 35103a41173..df2aa386992 100644 --- a/addons/import_sugarcrm/sugar.py +++ b/addons/import_sugarcrm/sugar.py @@ -33,7 +33,7 @@ import import_sugarcrm import logging import sys - +_logger = logging.getLogger(__name__) debug = False @@ -119,7 +119,7 @@ def get_contact_by_email(portType, username, password, email_address=None): email_list.append(list.Email_address) return email_list except Exception,e: - logging.getLogger('sugarcrm_soap').error('Exception: %s\n' % (tools.ustr(e))) + _logger.error('Exception: %s\n' % (tools.ustr(e))) return False def get_document_revision_search(portType, sessionid, module_id=None): diff --git a/addons/l10n_be_invoice_bba/invoice.py b/addons/l10n_be_invoice_bba/invoice.py index 333319df454..4cdbca84c0a 100644 --- a/addons/l10n_be_invoice_bba/invoice.py +++ b/addons/l10n_be_invoice_bba/invoice.py @@ -24,6 +24,7 @@ import re, time, random from osv import fields, osv from tools.translate import _ import logging +_logger = logging.getLogger(__name__) """ account.invoice object: @@ -40,7 +41,7 @@ class account_invoice(osv.osv): context=context) res[[i for i,x in enumerate(res) if x[0] == 'none'][0]] = ('none', 'Free Communication') res.append(('bba', 'BBA Structured Communication')) - #logging('l1on.be.invoice.bba').warning('reference_type = %s' %res ) + #l_logger.warning('reference_type = %s' %res ) return res def check_bbacomm(self, val): @@ -67,7 +68,7 @@ class account_invoice(osv.osv): result = super(account_invoice, self).onchange_partner_id(cr, uid, ids, type, partner_id, date_invoice, payment_term, partner_bank_id, company_id) # reference_type = self.default_get(cr, uid, ['reference_type'])['reference_type'] -# logging('l1on.be.invoice.bba').warning('partner_id %s' % partner_id) +# _logger.warning('partner_id %s' % partner_id) reference = False reference_type = 'none' if partner_id: diff --git a/addons/l10n_multilang/l10n_multilang.py b/addons/l10n_multilang/l10n_multilang.py index 03a3bd332e0..c4c6be74e4b 100644 --- a/addons/l10n_multilang/l10n_multilang.py +++ b/addons/l10n_multilang/l10n_multilang.py @@ -23,6 +23,7 @@ from osv import fields, osv import os from tools.translate import _ import logging +_logger = logging.getLogger(__name__) class wizard_multi_charts_accounts(osv.osv_memory): """ @@ -79,7 +80,7 @@ class wizard_multi_charts_accounts(osv.osv_memory): if context.get('lang') == lang: self.pool.get(out_obj._name).write(cr, uid, out_ids[j], {in_field: value[in_id]}) else: - logging.getLogger('l10n.multilang').info('Language: %s. Translation from template: there is no translation available for %s!' %(lang, src[in_id]))#out_obj._name)) + _logger.info('Language: %s. Translation from template: there is no translation available for %s!' %(lang, src[in_id]))#out_obj._name)) return True def execute(self, cr, uid, ids, context=None): diff --git a/addons/mail/mail_message.py b/addons/mail/mail_message.py index f86ae29c80f..e45d4f07807 100644 --- a/addons/mail/mail_message.py +++ b/addons/mail/mail_message.py @@ -36,7 +36,7 @@ from osv import fields from tools.translate import _ from openerp import SUPERUSER_ID -_logger = logging.getLogger('mail') +_logger = logging.getLogger(__name__) def format_date_tz(date, tz=None): if not date: diff --git a/addons/portal/wizard/portal_wizard.py b/addons/portal/wizard/portal_wizard.py index 1ec4cbb0e4b..881be3be05f 100644 --- a/addons/portal/wizard/portal_wizard.py +++ b/addons/portal/wizard/portal_wizard.py @@ -27,7 +27,7 @@ from tools.misc import email_re from tools.translate import _ from base.res.res_users import _lang_get - +_logger = logging.getLogger(__name__) # welcome email sent to new portal users (note that calling tools.translate._ @@ -174,7 +174,7 @@ class wizard(osv.osv_memory): body = _(WELCOME_EMAIL_BODY) % data res = mail_message_obj.schedule_with_attach(cr, uid, email_from , [email_to], subject, body, context=context) if not res: - logging.getLogger('res.portal.wizard').warning( + _logger.warning( 'Failed to send email from %s to %s', email_from, email_to) return {'type': 'ir.actions.act_window_close'} diff --git a/addons/report_webkit/webkit_report.py b/addons/report_webkit/webkit_report.py index 4d0bd6295c6..04980695f8f 100644 --- a/addons/report_webkit/webkit_report.py +++ b/addons/report_webkit/webkit_report.py @@ -51,7 +51,7 @@ import tools from tools.translate import _ from osv.osv import except_osv -logger = logging.getLogger('report_webkit') +_logger = logging.getLogger(__name__) def mako_template(text): """Build a Mako template. @@ -248,7 +248,7 @@ class WebKitParser(report_sxw): htmls.append(html) except Exception, e: msg = exceptions.text_error_template().render() - logger.error(msg) + _logger.error(msg) raise except_osv(_('Webkit render'), msg) else: try : @@ -259,7 +259,7 @@ class WebKitParser(report_sxw): htmls.append(html) except Exception, e: msg = exceptions.text_error_template().render() - logger.error(msg) + _logger.error(msg) raise except_osv(_('Webkit render'), msg) head_mako_tpl = mako_template(header) try : @@ -281,7 +281,7 @@ class WebKitParser(report_sxw): **self.parser_instance.localcontext) except: msg = exceptions.text_error_template().render() - logger.error(msg) + _logger.error(msg) raise except_osv(_('Webkit render'), msg) if report_xml.webkit_debug : try : @@ -292,7 +292,7 @@ class WebKitParser(report_sxw): **self.parser_instance.localcontext) except Exception, e: msg = exceptions.text_error_template().render() - logger.error(msg) + _logger.error(msg) raise except_osv(_('Webkit render'), msg) return (deb, 'html') bin = self.get_lib(cursor, uid) diff --git a/addons/share/wizard/share_wizard.py b/addons/share/wizard/share_wizard.py index 07004f333a8..336f56a5f97 100644 --- a/addons/share/wizard/share_wizard.py +++ b/addons/share/wizard/share_wizard.py @@ -32,6 +32,7 @@ from osv import expression from tools.translate import _ from tools.safe_eval import safe_eval import openerp +_logger = logging.getLogger(__name__) FULL_ACCESS = ('perm_read', 'perm_write', 'perm_create', 'perm_unlink') READ_WRITE_ACCESS = ('perm_read', 'perm_write') @@ -48,7 +49,6 @@ def generate_random_pass(): return ''.join(random.sample(RANDOM_PASS_CHARACTERS,10)) class share_wizard(osv.osv_memory): - _logger = logging.getLogger('share.wizard') _name = 'share.wizard' _description = 'Share Wizard' @@ -335,7 +335,7 @@ class share_wizard(osv.osv_memory): except Exception: # Note: must catch all exceptions, as UnquoteEvalContext may cause many # different exceptions, as it shadows builtins. - self._logger.debug("Failed to cleanup action context as it does not parse server-side", exc_info=True) + _logger.debug("Failed to cleanup action context as it does not parse server-side", exc_info=True) result = context_str return result @@ -496,8 +496,8 @@ class share_wizard(osv.osv_memory): [x.id for x in current_user.groups_id], target_model_ids, context=context) group_access_map = self._get_access_map_for_groups_and_models(cr, uid, [group_id], target_model_ids, context=context) - self._logger.debug("Current user access matrix: %r", current_user_access_map) - self._logger.debug("New group current access matrix: %r", group_access_map) + _logger.debug("Current user access matrix: %r", current_user_access_map) + _logger.debug("New group current access matrix: %r", group_access_map) # Create required rights if allowed by current user rights and not # already granted @@ -520,7 +520,7 @@ class share_wizard(osv.osv_memory): need_creation = True if need_creation: model_access_obj.create(cr, UID_ROOT, values) - self._logger.debug("Creating access right for model %s with values: %r", model.model, values) + _logger.debug("Creating access right for model %s with values: %r", model.model, values) def _link_or_copy_current_user_rules(self, cr, current_user, group_id, fields_relations, context=None): rule_obj = self.pool.get('ir.rule') @@ -542,13 +542,13 @@ class share_wizard(osv.osv_memory): 'groups': [(6,0,[group_id])], 'domain_force': rule.domain, # evaluated version! }) - self._logger.debug("Copying rule %s (%s) on model %s with domain: %s", rule.name, rule.id, model.model, rule.domain_force) + _logger.debug("Copying rule %s (%s) on model %s with domain: %s", rule.name, rule.id, model.model, rule.domain_force) else: # otherwise we can simply link the rule to keep it dynamic rule_obj.write(cr, 1, [rule.id], { 'groups': [(4,group_id)] }) - self._logger.debug("Linking rule %s (%s) on model %s with domain: %s", rule.name, rule.id, model.model, rule.domain_force) + _logger.debug("Linking rule %s (%s) on model %s with domain: %s", rule.name, rule.id, model.model, rule.domain_force) def _check_personal_rule_or_duplicate(self, cr, group_id, rule, context=None): """Verifies that the given rule only belongs to the given group_id, otherwise @@ -567,7 +567,7 @@ class share_wizard(osv.osv_memory): 'groups': [(6,0,[group_id])], 'domain_force': rule.domain_force, # non evaluated! }) - self._logger.debug("Duplicating rule %s (%s) (domain: %s) for modified access ", rule.name, rule.id, rule.domain_force) + _logger.debug("Duplicating rule %s (%s) (domain: %s) for modified access ", rule.name, rule.id, rule.domain_force) # then disconnect from group_id: rule.write({'groups':[(3,group_id)]}) # disconnects, does not delete! return rule_obj.browse(cr, UID_ROOT, new_id, context=context) @@ -602,7 +602,7 @@ class share_wizard(osv.osv_memory): if restrict: continue else: - self._logger.debug("Ignoring sharing rule on model %s with domain: %s the same rule exists already", model_id, domain) + _logger.debug("Ignoring sharing rule on model %s with domain: %s the same rule exists already", model_id, domain) return if restrict: # restricting existing rules is done by adding the clause @@ -614,7 +614,7 @@ class share_wizard(osv.osv_memory): new_clause = expression.normalize(eval(domain, eval_ctx)) combined_domain = expression.AND([new_clause, org_domain]) rule.write({'domain_force': combined_domain, 'name': rule.name + _('(Modified)')}) - self._logger.debug("Combining sharing rule %s on model %s with domain: %s", rule.id, model_id, domain) + _logger.debug("Combining sharing rule %s on model %s with domain: %s", rule.id, model_id, domain) if not rule_ids or not restrict: # Adding the new rule in the group is ok for normal cases, because rules # in the same group and for the same model will be combined with OR @@ -625,7 +625,7 @@ class share_wizard(osv.osv_memory): 'domain_force': domain, 'groups': [(4,group_id)] }) - self._logger.debug("Created sharing rule on model %s with domain: %s", model_id, domain) + _logger.debug("Created sharing rule on model %s with domain: %s", model_id, domain) def _create_indirect_sharing_rules(self, cr, current_user, wizard_data, group_id, fields_relations, context=None): rule_name = _('Indirect sharing filter created by user %s (%s) for group %s') % \ @@ -648,7 +648,7 @@ class share_wizard(osv.osv_memory): group_id, model_id=model.id, domain=str(related_domain), rule_name=rule_name, restrict=True, context=context) except Exception: - self._logger.exception('Failed to create share access') + _logger.exception('Failed to create share access') raise osv.except_osv(_('Sharing access could not be created'), _('Sorry, the current screen and filter you are trying to share are not supported at the moment.\nYou may want to try a simpler filter.')) @@ -852,7 +852,7 @@ class share_wizard(osv.osv_memory): notification_obj.create(cr, uid, {'user_id': result_line.user_id.id, 'message_id': msg_id}, context=context) def send_emails(self, cr, uid, wizard_data, context=None): - self._logger.info('Sending share notifications by email...') + _logger.info('Sending share notifications by email...') mail_message = self.pool.get('mail.message') user = self.pool.get('res.users').browse(cr, UID_ROOT, uid) if not user.user_email: @@ -885,7 +885,7 @@ class share_wizard(osv.osv_memory): msg_ids.append(mail_message.schedule_with_attach(cr, uid, user.user_email, [email_to], subject, body, model='share.wizard', context=context)) # force direct delivery, as users expect instant notification mail_message.send(cr, uid, msg_ids, context=context) - self._logger.info('%d share notification(s) sent.', len(msg_ids)) + _logger.info('%d share notification(s) sent.', len(msg_ids)) def onchange_embed_options(self, cr, uid, ids, opt_title, opt_search, context=None): wizard = self.browse(cr, uid, ids[0], context) diff --git a/addons/stock/stock.py b/addons/stock/stock.py index 87cf9ade130..a279b8bea6c 100644 --- a/addons/stock/stock.py +++ b/addons/stock/stock.py @@ -33,7 +33,7 @@ import tools from tools import float_compare import decimal_precision as dp import logging - +_logger = logging.getLogger(__name__) #---------------------------------------------------------- # Incoterms @@ -419,9 +419,8 @@ class stock_location(osv.osv): # so we ROLLBACK to the SAVEPOINT to restore the transaction to its earlier # state, we return False as if the products were not available, and log it: cr.execute("ROLLBACK TO stock_location_product_reserve") - logger = logging.getLogger('stock.location') - logger.warn("Failed attempt to reserve %s x product %s, likely due to another transaction already in progress. Next attempt is likely to work. Detailed error available at DEBUG level.", product_qty, product_id) - logger.debug("Trace of the failed product reservation attempt: ", exc_info=True) + _logger.warn("Failed attempt to reserve %s x product %s, likely due to another transaction already in progress. Next attempt is likely to work. Detailed error available at DEBUG level.", product_qty, product_id) + _logger.debug("Trace of the failed product reservation attempt: ", exc_info=True) return False # XXX TODO: rewrite this with one single query, possibly even the quantity conversion diff --git a/addons/stock_planning/stock_planning.py b/addons/stock_planning/stock_planning.py index 324aeb0dcd2..e6f3b8d4218 100644 --- a/addons/stock_planning/stock_planning.py +++ b/addons/stock_planning/stock_planning.py @@ -29,7 +29,7 @@ from tools.translate import _ import logging import decimal_precision as dp -_logger = logging.getLogger('mps') +_logger = logging.getLogger(__name__) def rounding(fl, round_value): diff --git a/addons/users_ldap/users_ldap.py b/addons/users_ldap/users_ldap.py index 1d0c1e3acb9..e4615907c79 100644 --- a/addons/users_ldap/users_ldap.py +++ b/addons/users_ldap/users_ldap.py @@ -27,6 +27,7 @@ import pooler import tools from osv import fields, osv from openerp import SUPERUSER_ID +_logger = logging.getLogger(__name__) class CompanyLDAP(osv.osv): _name = 'res.company.ldap' @@ -107,8 +108,7 @@ class CompanyLDAP(osv.osv): except ldap.INVALID_CREDENTIALS: return False except ldap.LDAPError, e: - logger = logging.getLogger('orm.ldap') - logger.error('An LDAP exception occurred: %s', e) + _logger.error('An LDAP exception occurred: %s', e) return entry def query(self, conf, filter, retrieve_attributes=None): @@ -135,7 +135,6 @@ class CompanyLDAP(osv.osv): """ results = [] - logger = logging.getLogger('orm.ldap') try: conn = self.connect(conf) conn.simple_bind_s(conf['ldap_binddn'] or '', @@ -144,9 +143,9 @@ class CompanyLDAP(osv.osv): filter, retrieve_attributes, timeout=60) conn.unbind() except ldap.INVALID_CREDENTIALS: - logger.error('LDAP bind failed.') + _logger.error('LDAP bind failed.') except ldap.LDAPError, e: - logger.error('An LDAP exception occurred: %s', e) + _logger.error('An LDAP exception occurred: %s', e) return results def map_ldap_attributes(self, cr, uid, conf, login, ldap_entry): @@ -188,8 +187,7 @@ class CompanyLDAP(osv.osv): if res[1]: user_id = res[0] elif conf['create_user']: - logger = logging.getLogger('orm.ldap') - logger.debug("Creating new OpenERP user \"%s\" from LDAP" % login) + _logger.debug("Creating new OpenERP user \"%s\" from LDAP" % login) user_obj = self.pool.get('res.users') values = self.map_ldap_attributes(cr, uid, conf, login, ldap_entry) if conf['user']: