Merge "logging cleanup"

This commit is contained in:
Jenkins 2015-10-08 22:20:56 +00:00 committed by Gerrit Code Review
commit 48709f2034
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'] sufficient = len(statistics) >= alarm.rule['evaluation_periods']
if not sufficient and alarm.state != evaluator.UNKNOWN: if not sufficient and alarm.state != evaluator.UNKNOWN:
LOG.warn(_LW('Expecting %(expected)d datapoints but only get ' LOG.warning(_LW('Expecting %(expected)d datapoints but only get '
'%(actual)d') % { '%(actual)d') % {
'expected': alarm.rule['evaluation_periods'], 'expected': alarm.rule['evaluation_periods'],
'actual': len(statistics)}) 'actual': len(statistics)})
# Reason is not same as log message because we want to keep # Reason is not same as log message because we want to keep

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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