Foram Katharotiya (OpenERP) has proposed merging 
lp:~openerp-commiter/openobject-addons/trunk-fix-server-log-warning-fka into 
lp:~openerp-dev/openobject-addons/trunk-fix-server-log.

Requested reviews:
  Bhumika (OpenERP) (sbh-openerp)

For more details, see:
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-fix-server-log-warning-fka/+merge/111799

hello,
Add _logger, instead of _loggerdoc or _log.
Add .warning() instead of .debug() in Account.
-- 
https://code.launchpad.net/~openerp-commiter/openobject-addons/trunk-fix-server-log-warning-fka/+merge/111799
Your team OpenERP R&D Team is subscribed to branch 
lp:~openerp-dev/openobject-addons/trunk-fix-server-log.
=== modified file 'account/account.py'
--- account/account.py	2012-06-22 06:48:54 +0000
+++ account/account.py	2012-06-25 09:15:31 +0000
@@ -2095,7 +2095,7 @@
         }
 
     def compute(self, cr, uid, taxes, price_unit, quantity,  product=None, partner=None):
-        _logger.debug("Deprecated, use compute_all(...)['taxes'] instead of compute(...) to manage prices with tax included")
+        _logger.warning("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):

=== modified file 'document/document.py'
--- document/document.py	2012-06-22 07:25:45 +0000
+++ document/document.py	2012-06-25 09:15:31 +0000
@@ -30,7 +30,7 @@
 import nodes
 import logging
 
-_loggerdoc = logging.getLogger(__name__)
+_logger = logging.getLogger(__name__)
 
 DMS_ROOT_PATH = tools.config.get('document_path', os.path.join(tools.config['root_path'], 'filestore'))
 
@@ -57,7 +57,7 @@
 
         parent_id = self.pool.get('document.directory')._get_root_directory(cr,uid)
         if not parent_id:
-            _loggerdoc.warning("at _attach_parent_id(), still not able to set the parent!")
+            _logger.warning("at _attach_parent_id(), still not able to set the parent!")
             return False
 
         if ids is not None:

=== modified file 'document/document_directory.py'
--- document/document_directory.py	2012-06-22 06:48:39 +0000
+++ document/document_directory.py	2012-06-25 09:15:31 +0000
@@ -25,7 +25,7 @@
 import logging
 import nodes
 from tools.translate import _
-_loggerdir = logging.getLogger(__name__)
+_logger = logging.getLogger(__name__)
 class document_directory(osv.osv):
     _name = 'document.directory'
     _description = 'Directory'
@@ -79,7 +79,7 @@
             return root_id
         except Exception, e:
             
-            _loggerdir.warning('Cannot set directory root:'+ str(e))
+            _logger.warning('Cannot set directory root:'+ str(e))
             return False
         return objid.browse(cr, uid, mid, context=context).res_id
 

=== modified file 'document/document_storage.py'
--- document/document_storage.py	2012-06-22 07:25:45 +0000
+++ document/document_storage.py	2012-06-25 09:15:31 +0000
@@ -37,7 +37,7 @@
 import pooler
 import nodes
 from content_index import cntIndex
-_doclog = logging.getLogger(__name__)
+_logger = logging.getLogger(__name__)
 DMS_ROOT_PATH = tools.config.get('document_path', os.path.join(tools.config.get('root_path'), 'filestore'))
 
 
@@ -127,7 +127,7 @@
                 mime, icont = cntIndex.doIndex(None, filename=filename,
                         content_type=None, realfname=fname)
             except Exception:
-                _doclog.debug('Cannot index file:', exc_info=True)
+                _logger.debug('Cannot index file:', exc_info=True)
                 pass
 
             try:
@@ -147,7 +147,7 @@
                 cr.commit()
                 cr.close()
             except Exception:
-                _doclog.warning('Cannot save file indexed content:', exc_info=True)
+                _logger.warning('Cannot save file indexed content:', exc_info=True)
 
         elif self.mode in ('a', 'a+' ):
             try:
@@ -161,7 +161,7 @@
                 cr.commit()
                 cr.close()
             except Exception:
-                _doclog.warning('Cannot save file appended content:', exc_info=True)
+                _logger.warning('Cannot save file appended content:', exc_info=True)
 
 
 
@@ -188,7 +188,7 @@
         elif mode == 'a':
             StringIO.__init__(self, None)
         else:
-            _doclog.error("Incorrect mode %s specified", mode)
+            _logger.error("Incorrect mode %s specified", mode)
             raise IOError(errno.EINVAL, "Invalid file mode")
         self.mode = mode
 
@@ -214,7 +214,7 @@
                     mime, icont = cntIndex.doIndex(data, filename=filename,
                             content_type=None, realfname=None)
                 except Exception:
-                    _doclog.debug('Cannot index file:', exc_info=True)
+                    _logger.debug('Cannot index file:', exc_info=True)
                     pass
 
                 try:
@@ -238,7 +238,7 @@
                     (out, len(data), par.file_id))
             cr.commit()
         except Exception:
-            _doclog.exception('Cannot update db file #%d for close:', par.file_id)
+            _logger.exception('Cannot update db file #%d for close:', par.file_id)
             raise
         finally:
             cr.close()
@@ -268,7 +268,7 @@
         elif mode == 'a':
             StringIO.__init__(self, None)
         else:
-            _doclog.error("Incorrect mode %s specified", mode)
+            _logger.error("Incorrect mode %s specified", mode)
             raise IOError(errno.EINVAL, "Invalid file mode")
         self.mode = mode
 
@@ -317,7 +317,7 @@
                     (base64.encodestring(data), len(data), par.file_id))
             cr.commit()
         except Exception:
-            _doclog.exception('Cannot update db file #%d for close:', par.file_id)
+            _logger.exception('Cannot update db file #%d for close:', par.file_id)
             raise
         finally:
             cr.close()
@@ -398,7 +398,7 @@
         npath = filter(lambda x: x is not None, npath)
 
         # if self._debug:
-        #     self._doclog.debug('Npath: %s', npath)
+        #     self._logger.debug('Npath: %s', npath)
         for n in npath:
             if n == '..':
                 raise ValueError("Invalid '..' element in path")
@@ -409,7 +409,7 @@
         dpath += npath[:-1]
         path = os.path.join(*dpath)
         if not os.path.isdir(path):
-            _doclog.debug("Create dirs: %s", path)
+            _logger.debug("Create dirs: %s", path)
             os.makedirs(path)
         return path, npath
 
@@ -447,7 +447,7 @@
                 # try to fix their directory.
                 if mode in ('r','r+'):
                     if ira.file_size:
-                        _doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
+                        _logger.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
                     raise IOError(errno.ENOENT, 'No file can be located')
                 else:
                     store_fname = self.__get_random_fname(boo.path)
@@ -489,7 +489,7 @@
                 # On a migrated db, some files may have the wrong storage type
                 # try to fix their directory.
                 if ira.file_size:
-                    _doclog.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
+                    _logger.warning( "ir.attachment #%d does not have a filename, but is at filestore, fix it!" % ira.id)
                 return None
             fpath = os.path.join(boo.path, ira.store_fname)
             return file(fpath, 'rb').read()
@@ -513,7 +513,7 @@
                 # On a migrated db, some files may have the wrong storage type
                 # try to fix their directory.
                 if ira.file_size:
-                    _doclog.warning("ir.attachment #%d does not have a filename, trying the name." %ira.id)
+                    _logger.warning("ir.attachment #%d does not have a filename, trying the name." %ira.id)
                 # sfname = ira.name
             fpath = os.path.join(boo.path,ira.store_fname or ira.name)
             if os.path.exists(fpath):
@@ -546,7 +546,7 @@
         if boo.readonly:
             raise IOError(errno.EPERM, "Readonly medium")
 
-        _doclog.debug( "Store data for ir.attachment #%d" % ira.id)
+        _logger.debug( "Store data for ir.attachment #%d" % ira.id)
         store_fname = None
         fname = None
         if boo.type == 'filestore':
@@ -559,13 +559,13 @@
                     fp.write(data)
                 finally:    
                     fp.close()
-                _doclog.debug( "Saved data to %s" % fname)
+                _logger.debug( "Saved data to %s" % fname)
                 filesize = len(data) # os.stat(fname).st_size
                 
                 # TODO Here, an old file would be left hanging.
 
             except Exception, e:
-                _doclog.warning( "Couldn't save data to %s", path, exc_info=True)
+                _logger.warning( "Couldn't save data to %s", path, exc_info=True)
                 raise except_orm(_('Error!'), str(e))
         elif boo.type == 'db':
             filesize = len(data)
@@ -588,12 +588,12 @@
                     fp.write(data)
                 finally:    
                     fp.close()
-                _doclog.debug("Saved data to %s", fname)
+                _logger.debug("Saved data to %s", fname)
                 filesize = len(data) # os.stat(fname).st_size
                 store_fname = os.path.join(*npath)
                 # TODO Here, an old file would be left hanging.
             except Exception,e :
-                _doclog.warning("Couldn't save data:", exc_info=True)
+                _logger.warning("Couldn't save data:", exc_info=True)
                 raise except_orm(_('Error!'), str(e))
 
         elif boo.type == 'virtual':
@@ -612,7 +612,7 @@
                 mime, icont = cntIndex.doIndex(data, ira.datas_fname,
                 ira.file_type or None, fname)
             except Exception:
-                _doclog.debug('Cannot index file:', exc_info=True)
+                _logger.debug('Cannot index file:', exc_info=True)
                 pass
 
             try:
@@ -629,7 +629,7 @@
             file_node.content_type = mime
             return True
         except Exception, e :
-            self._doclog.warning("Couldn't save data:", exc_info=True)
+            self._logger.warning("Couldn't save data:", exc_info=True)
             # should we really rollback once we have written the actual data?
             # at the db case (only), that rollback would be safe
             raise except_orm(_('Error at doc write!'), str(e))
@@ -667,9 +667,9 @@
                 try:
                     os.unlink(fname)
                 except Exception:
-                    _doclog.warning("Could not remove file %s, please remove manually.", fname, exc_info=True)
+                    _logger.warning("Could not remove file %s, please remove manually.", fname, exc_info=True)
             else:
-                _doclog.warning("Unknown unlink key %s" % ktype)
+                _logger.warning("Unknown unlink key %s" % ktype)
 
         return True
 
@@ -699,9 +699,9 @@
             fname = ira.store_fname
 
             if not fname:
-                _doclog.warning("Trying to rename a non-stored file")
+                _logger.warning("Trying to rename a non-stored file")
             if fname != os.path.join(*npath):
-                _doclog.warning("inconsistency in realstore: %s != %s" , fname, repr(npath))
+                _logger.warning("inconsistency in realstore: %s != %s" , fname, repr(npath))
 
             oldpath = os.path.join(path, npath[-1])
             newpath = os.path.join(path, new_name)
@@ -739,7 +739,7 @@
                 break
             par = par.parent_id
         if file_node.storage_id != psto:
-            _doclog.debug('Cannot move file %r from %r to %r', file_node, file_node.parent, ndir_bro.name)
+            _logger.debug('Cannot move file %r from %r to %r', file_node, file_node.parent, ndir_bro.name)
             raise NotImplementedError('Cannot move files between storage media')
 
         if sbro.type in ('filestore', 'db', 'db64'):
@@ -752,9 +752,9 @@
             fname = ira.store_fname
 
             if not fname:
-                _doclog.warning("Trying to rename a non-stored file")
+                _logger.warning("Trying to rename a non-stored file")
             if fname != os.path.join(*opath):
-                _doclog.warning("inconsistency in realstore: %s != %s" , fname, repr(opath))
+                _logger.warning("inconsistency in realstore: %s != %s" , fname, repr(opath))
 
             oldpath = os.path.join(path, opath[-1])
             
@@ -762,12 +762,12 @@
             npath = filter(lambda x: x is not None, npath)
             newdir = os.path.join(*npath)
             if not os.path.isdir(newdir):
-                _doclog.debug("Must create dir %s", newdir)
+                _logger.debug("Must create dir %s", newdir)
                 os.makedirs(newdir)
             npath.append(opath[-1])
             newpath = os.path.join(*npath)
             
-            _doclog.debug("Going to move %s from %s to %s", opath[-1], oldpath, newpath)
+            _logger.debug("Going to move %s from %s to %s", opath[-1], oldpath, newpath)
             shutil.move(oldpath, newpath)
             
             store_path = npath[1:] + [opath[-1],]

=== modified file 'document_webdav/test_davclient.py'
--- document_webdav/test_davclient.py	2012-06-22 06:48:39 +0000
+++ document_webdav/test_davclient.py	2012-06-25 09:15:31 +0000
@@ -43,7 +43,7 @@
 import StringIO
 import base64
 
-_log = logging.getLogger(__name__)
+_logger = logging.getLogger(__name__)
 
 class HTTP11(httplib.HTTP):
         _http_vsn = 11
@@ -62,7 +62,7 @@
         if not self._http.has_key(host):
                 host, extra_headers, x509 = self.get_host_info(host)
                 self._http[host] = HTTP11(host)
-                _log.debug("New connection to %s", host)
+                _logger.debug("New connection to %s", host)
         return self._http[host]
 
     def get_host_info(self, host):
@@ -170,7 +170,7 @@
         if not self._http.has_key(host):
                 host, extra_headers, x509 = self.get_host_info(host)
                 self._http[host] = httplib.HTTPS(host, None, **(x509 or {}))
-                _log.debug("New connection to %s", host)
+                _logger.debug("New connection to %s", host)
         return self._http[host]
 
 class AuthClient(object):
@@ -191,8 +191,8 @@
             return super(BasicAuthClient,self).getAuth(atype, realm)
 
         if not self._realm_dict.has_key(realm):
-            _log.debug("realm dict: %r", self._realm_dict)
-            _log.debug("missing key: \"%s\"" % realm)
+            _logger.debug("realm dict: %r", self._realm_dict)
+            _logger.debug("missing key: \"%s\"" % realm)
             self.resolveFailedRealm(realm)
         return 'Basic '+ self._realm_dict[realm]
         
@@ -239,7 +239,7 @@
                 # This line will bork if self.setAuthClient has not
                 # been issued. That is a programming error, fix your code!
                 auths = self._auth_client.getAuth(atype, realm)
-                _log.debug("sending authorization: %s", auths)
+                _logger.debug("sending authorization: %s", auths)
                 h.putheader('Authorization', auths)
             self.send_content(h, request_body)
 
@@ -255,8 +255,8 @@
                         log.warning("Why have data on a 401 auth. message?")
                     if realm.startswith('realm="') and realm.endswith('"'):
                         realm = realm[7:-1]
-                    _log.debug("Resp: %r %r", resp.version,resp.isclosed(), resp.will_close)
-                    _log.debug("Want to do auth %s for realm %s", atype, realm)
+                    _logger.debug("Resp: %r %r", resp.version,resp.isclosed(), resp.will_close)
+                    _logger.debug("Want to do auth %s for realm %s", atype, realm)
                     if atype != 'Basic':
                         raise ProtocolError(host+handler, 403, 
                                         "Unknown authentication method: %s" % atype, resp.msg)
@@ -315,7 +315,7 @@
                         lf = (len(ssl.PEM_FOOTER)+1)
                         if cert[0-lf] != '\n':
                                 cert = cert[:0-lf]+'\n'+cert[0-lf:]
-                        _log.debug("len-footer: %s cert: %r", lf, cert[0-lf])
+                        _logger.debug("len-footer: %s cert: %r", lf, cert[0-lf])
                 
                 return cert
 
@@ -390,7 +390,7 @@
         import base64
         dbg = self.dbg
         hdrs.update(self.hdrs)
-        _log.debug("Getting %s http://%s:%d/%s";, method, self.host, self.port, path)
+        _logger.debug("Getting %s http://%s:%d/%s";, method, self.host, self.port, path)
         conn = httplib.HTTPConnection(self.host, port=self.port, timeout=self.timeout)
         conn.set_debuglevel(dbg)
         if not path:
@@ -409,8 +409,8 @@
                         data1 = r1.read()
                         if not self.user:
                                 raise Exception('Must auth, have no user/pass!')
-                        _log.debug("Ver: %s, closed: %s, will close: %s", r1.version,r1.isclosed(), r1.will_close)
-                        _log.debug("Want to do auth %s for realm %s", atype, realm)
+                        _logger.debug("Ver: %s, closed: %s, will close: %s", r1.version,r1.isclosed(), r1.will_close)
+                        _logger.debug("Want to do auth %s for realm %s", atype, realm)
                         if atype == 'Basic' :
                                 auths = base64.encodestring(self.user + ':' + self.passwd)
                                 if auths[-1] == "\n":
@@ -422,22 +422,22 @@
                         else:
                                 raise Exception("Unknown auth type %s" %atype)
                 else:
-                        _log.warning("Got 401, cannot auth")
+                        _logger.warning("Got 401, cannot auth")
                         raise Exception('No auth')
 
-        _log.debug("Reponse: %s %s",r1.status, r1.reason)
+        _logger.debug("Reponse: %s %s",r1.status, r1.reason)
         data1 = r1.read()
         if method != 'GET':
-            _log.debug("Body:\n%s\nEnd of body", data1)
+            _logger.debug("Body:\n%s\nEnd of body", data1)
             try:
                 ctype = r1.msg.getheader('content-type')
                 if ctype and ';' in ctype:
                     ctype, encoding = ctype.split(';',1)
                 if ctype == 'text/xml':
                     doc = xml.dom.minidom.parseString(data1)
-                    _log.debug("XML Body:\n %s", doc.toprettyxml(indent="\t"))
+                    _logger.debug("XML Body:\n %s", doc.toprettyxml(indent="\t"))
             except Exception:
-                _log.warning("could not print xml", exc_info=True)
+                _logger.warning("could not print xml", exc_info=True)
                 pass
         conn.close()
         return r1.status, r1.msg, data1
@@ -474,7 +474,7 @@
         s, m, d = self._http_request(path, method='OPTIONS', hdrs=hdrs)
         assert s == 200, "Status: %r" % s
         assert 'OPTIONS' in m.getheader('Allow')
-        _log.debug('Options: %r', m.getheader('Allow'))
+        _logger.debug('Options: %r', m.getheader('Allow'))
         
         if expect:
             self._assert_headers(expect, m)
@@ -493,10 +493,10 @@
             for cnod in node.childNodes:
                 if cnod.nodeType != node.ELEMENT_NODE:
                     if strict:
-                        _log.debug("Found %r inside <%s>", cnod, node.tagName)
+                        _logger.debug("Found %r inside <%s>", cnod, node.tagName)
                     continue
                 if namespaces and (cnod.namespaceURI not in namespaces):
-                    _log.debug("Ignoring <%s> in <%s>", cnod.tagName, node.localName)
+                    _logger.debug("Ignoring <%s> in <%s>", cnod.tagName, node.localName)
                     continue
                 yield cnod
 
@@ -533,10 +533,10 @@
                             assert htver == 'HTTP/1.1'
                             rstatus = int(sta)
                         else:
-                            _log.debug("What is <%s> inside a <propstat>?", pno.tagName)
+                            _logger.debug("What is <%s> inside a <propstat>?", pno.tagName)
                     
                 else:
-                    _log.debug("Unknown node: %s", cno.tagName)
+                    _logger.debug("Unknown node: %s", cno.tagName)
                 
             res.setdefault(href,[]).append((status, res_nss))
 
@@ -637,7 +637,7 @@
                         if lsp[1] in davprops:
                             lsline[lsp[0]] = lsp[2]
                 else:
-                    _log.debug("Strange status: %s", st)
+                    _logger.debug("Strange status: %s", st)
             
             res.append(lsline)
             

_______________________________________________
Mailing list: https://launchpad.net/~openerp-dev-gtk
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~openerp-dev-gtk
More help   : https://help.launchpad.net/ListHelp

Reply via email to