if isinstance(msg, Exception):
msg = tools.exception_to_unicode(msg)
- msg = tools.ustr(msg).strip()
-
- if level in (LOG_ERROR,LOG_CRITICAL):
- msg = common().get_server_environment() + msg
-
- result = msg.split('\n')
- if len(result)>1:
- for idx, s in enumerate(result):
- level_method('[%02d]: %s' % (idx+1, s,))
- elif result:
- level_method(result[0])
+ try:
++ msg = tools.ustr(msg).strip()
+ if level in (LOG_ERROR,LOG_CRITICAL) and tools.config.get_misc('debug','env_info',True):
+ msg = common().get_server_environment() + msg
+
- result = tools.ustr(msg).strip().split('\n')
++ result = msg.split('\n')
+ except UnicodeDecodeError:
+ result = msg.strip().split('\n')
+ try:
+ if len(result)>1:
+ for idx, s in enumerate(result):
+ level_method('[%02d]: %s' % (idx+1, s,))
+ elif result:
+ level_method(result[0])
+ except IOError,e:
+ # TODO: perhaps reset the logger streams?
+ #if logrotate closes our files, we end up here..
+ pass
+ except:
+ # better ignore the exception and carry on..
+ pass
+
+ def set_loglevel(self, level):
+ log = logging.getLogger()
+ log.setLevel(logging.INFO) # make sure next msg is printed
+ log.info("Log level changed to %s" % logging.getLevelName(level))
+ log.setLevel(level)
def shutdown(self):
logging.shutdown()
else:
logger = netsvc.Logger()
logger.notifyChannel('orm', netsvc.LOG_ERROR, "Programming error: field '%s' does not exist in object '%s' !" % (name, self._table._name))
- return False
+ return None
# if the field is a classic one or a many2one, we'll fetch all classic and many2one fields
- if col._classic_write:
+ if col._prefetch:
# gen the list of "local" (ie not inherited) fields which are classic or many2one
ffields = filter(lambda x: x[1]._classic_write, self._table._columns.items())
# gen the list of inherited fields