]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
use 'exc_info=1' instead of import traceback
authorKun Huang <gareth@unitedstack.com>
Sun, 21 Jul 2013 16:19:08 +0000 (00:19 +0800)
committerKun Huang <gareth@unitedstack.com>
Mon, 22 Jul 2013 15:27:49 +0000 (23:27 +0800)
We need store traceback message in log sometime. Python logging module
already provide a argument to do that. For example, we could:

logger.error('msg', exc_info=1)
logger.debug(e, exc_info=(type_,value_,tb))
logger.exception('msg') # exception add exc_info automaticly

Change-Id: Iaf541e4f4ea139d9315ac1990f0e6079c8f8a20d

cinder/volume/manager.py

index 6b0fb3e2225383441871279ca61cf7e96a2c77c2..8d831ff46ca1109cde5a33f66393990526635fe9 100644 (file)
@@ -296,8 +296,7 @@ class VolumeManager(manager.SchedulerDependentManager):
                                                             filter_properties)
 
                 if rescheduled:
-                    # log the original build error
-                    self._log_original_error(exc_info)
+                    LOG.error(_('Unexpected Error: '), exc_info=exc_info)
                     msg = (_('Creating %(volume_id)s %(snapshot_id)s '
                              '%(image_id)s was rescheduled due to '
                              '%(reason)s')
@@ -378,11 +377,6 @@ class VolumeManager(manager.SchedulerDependentManager):
         self._notify_about_volume_usage(context, volume_ref, "create.end")
         return volume_ref['id']
 
-    def _log_original_error(self, exc_info):
-        type_, value, tb = exc_info
-        LOG.error(_('Error: %s') %
-                  traceback.format_exception(type_, value, tb))
-
     def _reschedule_or_error(self, context, volume_id, exc_info,
                              snapshot_id, image_id, request_spec,
                              filter_properties):