logging cleanup

- fix incorrect error translation assigned to info log
- drop use of logging.warn alias which is not valid in py3

Change-Id: I48d80243c144bbbbbe2750e3077c88a15fa65f46
This commit is contained in:
gordon chung 2015-10-06 16:30:45 -04:00
parent 0f0b725935
commit f87edaa1e0
9 changed files with 48 additions and 49 deletions

View File

@ -103,8 +103,8 @@ class ThresholdEvaluator(evaluator.Evaluator):
"""
sufficient = len(statistics) >= alarm.rule['evaluation_periods']
if not sufficient and alarm.state != evaluator.UNKNOWN:
LOG.warn(_LW('Expecting %(expected)d datapoints but only get '
'%(actual)d') % {
LOG.warning(_LW('Expecting %(expected)d datapoints but only get '
'%(actual)d') % {
'expected': alarm.rule['evaluation_periods'],
'actual': len(statistics)})
# Reason is not same as log message because we want to keep

View File

@ -119,13 +119,13 @@ class V2Controller(object):
except exceptions.EndpointNotFound:
self._gnocchi_is_enabled = False
except exceptions.ClientException:
LOG.warn(_LW("Can't connect to keystone, assuming gnocchi "
"is disabled and retry later"))
LOG.warning(_LW("Can't connect to keystone, assuming "
"gnocchi is disabled and retry later"))
else:
self._gnocchi_is_enabled = True
LOG.warn(_LW("ceilometer-api started with gnocchi "
"enabled. The resources/meters/samples "
"URLs are disabled."))
LOG.warning(_LW("ceilometer-api started with gnocchi "
"enabled. The resources/meters/samples "
"URLs are disabled."))
return self._gnocchi_is_enabled
@property
@ -144,12 +144,12 @@ class V2Controller(object):
except exceptions.EndpointNotFound:
self._aodh_url = ""
except exceptions.ClientException:
LOG.warn(_LW("Can't connect to keystone, "
"assuming aodh is disabled and retry later."))
LOG.warning(_LW("Can't connect to keystone, assuming aodh "
"is disabled and retry later."))
else:
LOG.warn(_LW("ceilometer-api started with aodh enabled. "
"Alarms URLs will be redirected to aodh "
"endpoint."))
LOG.warning(_LW("ceilometer-api started with aodh "
"enabled. Alarms URLs will be redirected "
"to aodh endpoint."))
return self._aodh_url
@pecan.expose()

View File

@ -130,10 +130,10 @@ class _Base(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warn(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('%(inspector)s does not provide data for '
@ -708,10 +708,10 @@ class _DiskInfoPollsterBase(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warn(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('%(inspector)s does not provide data for '

View File

@ -48,15 +48,15 @@ class MemoryUsagePollster(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warn(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except virt_inspector.NoDataException as e:
LOG.warn(_LW('Cannot inspect data of %(pollster)s for '
'%(instance_id)s, non-fatal reason: %(exc)s'),
{'pollster': self.__class__.__name__,
'instance_id': instance.id, 'exc': e})
LOG.warning(_LW('Cannot inspect data of %(pollster)s for '
'%(instance_id)s, non-fatal reason: %(exc)s'),
{'pollster': self.__class__.__name__,
'instance_id': instance.id, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('Obtaining Memory Usage is not implemented for %s',
@ -91,15 +91,15 @@ class MemoryResidentPollster(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warn(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except virt_inspector.NoDataException as e:
LOG.warn(_LW('Cannot inspect data of %(pollster)s for '
'%(instance_id)s, non-fatal reason: %(exc)s'),
{'pollster': self.__class__.__name__,
'instance_id': instance.id, 'exc': e})
LOG.warning(_LW('Cannot inspect data of %(pollster)s for '
'%(instance_id)s, non-fatal reason: %(exc)s'),
{'pollster': self.__class__.__name__,
'instance_id': instance.id, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('Obtaining Resident Memory is not implemented'

View File

@ -96,10 +96,10 @@ class _Base(pollsters.BaseComputePollster):
# Instance was deleted while getting samples. Ignore it.
LOG.debug('Exception while getting samples %s', err)
except virt_inspector.InstanceShutOffException as e:
LOG.warn(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
LOG.warning(_LW('Instance %(instance_id)s was shut off while '
'getting samples of %(pollster)s: %(exc)s'),
{'instance_id': instance.id,
'pollster': self.__class__.__name__, 'exc': e})
except ceilometer.NotImplementedError:
# Selected inspector does not implement this pollster.
LOG.debug('%(inspector)s does not provide data for '

View File

@ -63,7 +63,7 @@ class MeterDefinition(object):
fname.endswith('_inspector'))):
setattr(self, fname, fval)
else:
LOG.warn(_LW("Ignore unrecognized field %s"), fname)
LOG.warning(_LW("Ignore unrecognized field %s"), fname)
for fname in self.required_fields:
if not getattr(self, fname, None):
raise MeterDefinitionException(

View File

@ -25,7 +25,7 @@ from oslo_log import log
import oslo_messaging
from ceilometer.agent import plugin_base
from ceilometer.i18n import _LE
from ceilometer.i18n import _LE, _LI
from ceilometer import sample
OPTS = [
@ -174,7 +174,7 @@ def setup_meters_config():
" Using default config."))
meters_config = {}
LOG.info(_LE("Meter Definitions: %s"), meters_config)
LOG.info(_LI("Meter Definitions: %s"), meters_config)
return meters_config

View File

@ -57,7 +57,7 @@ class TestMemoryPollster(base.TestPollsterBase):
set([s.name for s in samples]))
self.assertEqual(expected_memory_mb, samples[0].volume)
else:
self.assertEqual(1, mylog.warn.call_count)
self.assertEqual(1, mylog.warning.call_count)
self.assertEqual(0, mylog.exception.call_count)
_verify_memory_metering(1, 1.0)
@ -105,7 +105,7 @@ class TestResidentMemoryPollster(base.TestPollsterBase):
self.assertEqual(expected_resident_memory_mb,
samples[0].volume)
else:
self.assertEqual(1, mylog.warn.call_count)
self.assertEqual(1, mylog.warning.call_count)
self.assertEqual(0, mylog.exception.call_count)
_verify_resident_memory_metering(1, 1.0)

View File

@ -85,20 +85,19 @@ class DeltaTransformer(BaseConversionTransformer):
time_delta = timeutils.delta_seconds(prev_timestamp, timestamp)
# disallow violations of the arrow of time
if time_delta < 0:
LOG.warn(_LW('Dropping out of time order sample: %s'), (s,))
LOG.warning(_LW('Dropping out of time order sample: %s'), (s,))
# Reset the cache to the newer sample.
self.cache[key] = prev
return None
volume_delta = s.volume - prev_volume
if self.growth_only and volume_delta < 0:
LOG.warn(_LW('Negative delta detected, dropping value'))
LOG.warning(_LW('Negative delta detected, dropping value'))
s = None
else:
s = self._convert(s, volume_delta)
LOG.debug('Converted to: %s', s)
else:
LOG.warn(_LW('Dropping sample with no predecessor: %s'),
(s,))
LOG.warning(_LW('Dropping sample with no predecessor: %s'), (s,))
s = None
return s