Improving info level log messages
String interpolation should be delayed to be handled by the logging code, rather than being done at the point of the logging call. So we should use- LOG.info(_LI('some message: variable=%s'), variable) instead of LOG.info(_LI('some message: variable=%s') % variable) Change-Id: I6b3e578f2a0b66f253d49fe44766b6a31196a7c4 link: http://docs.openstack.org/developer/oslo.i18n/guidelines.html
This commit is contained in:
parent
bb9de39180
commit
f20ca36d15
|
@ -119,7 +119,7 @@ class AgentPoolBackend(base.Backend):
|
|||
response = None
|
||||
|
||||
LOG.info(_LI("Sending '%(msg)s' for '%(zone)s' to '%(server)s:"
|
||||
"%(port)d'.") %
|
||||
"%(port)d'."),
|
||||
{'msg': str(opcode),
|
||||
'zone': zone_name, 'server': dest_ip,
|
||||
'port': dest_port})
|
||||
|
|
|
@ -345,7 +345,7 @@ class DynECTBackend(base.Backend):
|
|||
timings=CONF[CFG_GROUP].timings)
|
||||
|
||||
def create_zone(self, context, zone):
|
||||
LOG.info(_LI('Creating zone %(d_id)s / %(d_name)s') %
|
||||
LOG.info(_LI('Creating zone %(d_id)s / %(d_name)s'),
|
||||
{'d_id': zone['id'], 'd_name': zone['name']})
|
||||
|
||||
url = '/Secondary/%s' % zone['name'].rstrip('.')
|
||||
|
@ -368,7 +368,7 @@ class DynECTBackend(base.Backend):
|
|||
if emsg['ERR_CD'] == 'TARGET_EXISTS':
|
||||
msg = _LI("Zone already exists, updating existing "
|
||||
"zone instead %s")
|
||||
LOG.info(msg % zone['name'])
|
||||
LOG.info(msg, zone['name'])
|
||||
client.put(url, data=data)
|
||||
break
|
||||
else:
|
||||
|
@ -378,7 +378,7 @@ class DynECTBackend(base.Backend):
|
|||
client.logout()
|
||||
|
||||
def delete_zone(self, context, zone):
|
||||
LOG.info(_LI('Deleting zone %(d_id)s / %(d_name)s') %
|
||||
LOG.info(_LI('Deleting zone %(d_id)s / %(d_name)s'),
|
||||
{'d_id': zone['id'], 'd_name': zone['name']})
|
||||
url = '/Zone/%s' % zone['name'].rstrip('.')
|
||||
client = self.get_client()
|
||||
|
|
|
@ -26,7 +26,7 @@ class FakeBackend(base.Backend):
|
|||
__plugin_name__ = 'fake'
|
||||
|
||||
def create_zone(self, context, zone):
|
||||
LOG.info(_LI('Create Zone %r') % zone)
|
||||
LOG.info(_LI('Create Zone %r'), zone)
|
||||
|
||||
def delete_zone(self, context, zone):
|
||||
LOG.info(_LI('Delete Zone %r') % zone)
|
||||
LOG.info(_LI('Delete Zone %r'), zone)
|
||||
|
|
|
@ -43,7 +43,7 @@ class InfobloxBackend(base.Backend):
|
|||
"Infoblox only supports mDNS instances on port 53")
|
||||
|
||||
def create_zone(self, context, zone):
|
||||
LOG.info(_LI('Create Zone %r') % zone)
|
||||
LOG.info(_LI('Create Zone %r'), zone)
|
||||
|
||||
dns_net_view = self.infoblox.get_dns_view(context.tenant)
|
||||
self.infoblox.create_zone_auth(
|
||||
|
@ -52,7 +52,7 @@ class InfobloxBackend(base.Backend):
|
|||
)
|
||||
|
||||
def delete_zone(self, context, zone):
|
||||
LOG.info(_LI('Delete Zone %r') % zone)
|
||||
LOG.info(_LI('Delete Zone %r'), zone)
|
||||
self.infoblox.delete_zone_auth(zone['name'][0:-1])
|
||||
|
||||
def ping(self, context):
|
||||
|
|
|
@ -411,7 +411,7 @@ class CentralAPI(object):
|
|||
# Pool Manager Integration Methods
|
||||
def update_status(self, context, zone_id, status, serial):
|
||||
LOG.info(_LI("update_status: Calling central's update_status "
|
||||
"for %(zone_id)s : %(status)s : %(serial)s") %
|
||||
"for %(zone_id)s : %(status)s : %(serial)s"),
|
||||
{'zone_id': zone_id, 'status': status, 'serial': serial})
|
||||
self.client.cast(context, 'update_status', zone_id=zone_id,
|
||||
status=status, serial=serial)
|
||||
|
|
|
@ -1091,7 +1091,7 @@ class Service(service.RPCService, service.Service):
|
|||
'before deleting this zone')
|
||||
|
||||
if hasattr(context, 'abandon') and context.abandon:
|
||||
LOG.info(_LW("Abandoning zone '%(zone)s'") % {'zone': zone.name})
|
||||
LOG.info(_LW("Abandoning zone '%(zone)s'"), {'zone': zone.name})
|
||||
zone = self.storage.delete_zone(context, zone.id)
|
||||
else:
|
||||
zone = self._delete_zone_in_storage(context, zone)
|
||||
|
@ -1151,7 +1151,7 @@ class Service(service.RPCService, service.Service):
|
|||
"Serial %(srv_serial)d is not equal to zone's %(serial)d,"
|
||||
" performing AXFR")
|
||||
LOG.info(
|
||||
msg % {"srv_serial": serial, "serial": zone.serial})
|
||||
msg, {"srv_serial": serial, "serial": zone.serial})
|
||||
self.mdns_api.perform_zone_xfr(context, zone)
|
||||
|
||||
def count_zones(self, context, criterion=None):
|
||||
|
@ -1977,7 +1977,7 @@ class Service(service.RPCService, service.Service):
|
|||
except exceptions.ZoneNotFound:
|
||||
msg = _LI(
|
||||
'Creating zone for %(fip_id)s:%(region)s - '
|
||||
'%(fip_addr)s zone %(zonename)s') % \
|
||||
'%(fip_addr)s zone %(zonename)s'), \
|
||||
{'fip_id': floatingip_id, 'region': region,
|
||||
'fip_addr': fip['address'], 'zonename': zone_name}
|
||||
LOG.info(msg)
|
||||
|
|
|
@ -124,8 +124,8 @@ class DesignateContext(context.RequestContext):
|
|||
|
||||
policy.check('use_sudo', self)
|
||||
|
||||
LOG.info(_LI('Accepted sudo from user %(user)s to tenant %(tenant)s')
|
||||
% {'user': self.user, 'tenant': tenant})
|
||||
LOG.info(_LI('Accepted sudo from user %(user)s to tenant %(tenant)s'),
|
||||
{'user': self.user, 'tenant': tenant})
|
||||
self.original_tenant = self.tenant
|
||||
self.tenant = tenant
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ class AkamaiCommands(base.Commands):
|
|||
client = impl_akamai.EnhancedDNSClient(
|
||||
target.options.get("username"), target.options.get("password"))
|
||||
|
||||
LOG.info(_LI("Doing batches of %i") % batch_size)
|
||||
LOG.info(_LI("Doing batches of %i"), batch_size)
|
||||
|
||||
criterion = {"pool_id": pool_id}
|
||||
marker = None
|
||||
|
@ -103,6 +103,6 @@ class AkamaiCommands(base.Commands):
|
|||
z = impl_akamai.build_zone(client, target, zone)
|
||||
update.append(z)
|
||||
|
||||
LOG.info(_LI('Uploading %d Zones') % len(update))
|
||||
LOG.info(_LI('Uploading %d Zones'), len(update))
|
||||
|
||||
client.setZones(update)
|
||||
|
|
|
@ -113,7 +113,7 @@ class TLDCommands(base.Commands):
|
|||
if not os.path.exists(input_file):
|
||||
raise Exception('TLD Input file Not Found')
|
||||
|
||||
LOG.info(_LI("Importing TLDs from %s") % input_file)
|
||||
LOG.info(_LI("Importing TLDs from %s"), input_file)
|
||||
|
||||
error_lines = []
|
||||
tlds_added = 0
|
||||
|
@ -133,7 +133,7 @@ class TLDCommands(base.Commands):
|
|||
tlds_added += self._validate_and_create_tld(line,
|
||||
error_lines)
|
||||
|
||||
LOG.info(_LI("Number of tlds added: %d") % tlds_added)
|
||||
LOG.info(_LI("Number of tlds added: %d"), tlds_added)
|
||||
|
||||
errors = len(error_lines)
|
||||
if errors > 0:
|
||||
|
|
|
@ -145,11 +145,11 @@ class RequestHandler(xfr.XFRMixin):
|
|||
if soa_serial == zone.serial:
|
||||
msg = _LI("Serial %(serial)s is the same for master and us for "
|
||||
"%(zone_id)s")
|
||||
LOG.info(msg % {"serial": soa_serial, "zone_id": zone.id})
|
||||
LOG.info(msg, {"serial": soa_serial, "zone_id": zone.id})
|
||||
else:
|
||||
msg = _LI("Scheduling AXFR for %(zone_id)s from %(master_addr)s")
|
||||
info = {"zone_id": zone.id, "master_addr": master_addr}
|
||||
LOG.info(msg % info)
|
||||
LOG.info(msg, info)
|
||||
self.tg.add_thread(self.zone_sync, context, zone,
|
||||
[master_addr])
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ class NotifyEndpoint(base.BaseEndpoint):
|
|||
while retry < max_retries:
|
||||
retry = retry + 1
|
||||
LOG.info(_LI("Sending '%(msg)s' for '%(zone)s' to '%(server)s:"
|
||||
"%(port)d'.") %
|
||||
"%(port)d'."),
|
||||
{'msg': 'NOTIFY' if notify else 'SOA',
|
||||
'zone': zone.name, 'server': host,
|
||||
'port': port})
|
||||
|
@ -209,7 +209,7 @@ class NotifyEndpoint(base.BaseEndpoint):
|
|||
# authoritative answer
|
||||
elif response.rcode() in (dns.rcode.NXDOMAIN, dns.rcode.REFUSED,
|
||||
dns.rcode.SERVFAIL):
|
||||
LOG.info(_LI("%(zone)s not found on %(server)s:%(port)d") %
|
||||
LOG.info(_LI("%(zone)s not found on %(server)s:%(port)d"),
|
||||
{'zone': zone.name, 'server': host,
|
||||
'port': port})
|
||||
break
|
||||
|
|
|
@ -72,7 +72,7 @@ class MdnsAPI(object):
|
|||
def notify_zone_changed(self, context, zone, host, port, timeout,
|
||||
retry_interval, max_retries, delay):
|
||||
LOG.info(_LI("notify_zone_changed: Calling mdns for zone '%(zone)s', "
|
||||
"serial '%(serial)s' to nameserver '%(host)s:%(port)s'") %
|
||||
"serial '%(serial)s' to nameserver '%(host)s:%(port)s'"),
|
||||
{'zone': zone.name, 'serial': zone.serial,
|
||||
'host': host, 'port': port})
|
||||
# The notify_zone_changed method is a cast rather than a call since the
|
||||
|
@ -87,7 +87,7 @@ class MdnsAPI(object):
|
|||
retry_interval, max_retries, delay):
|
||||
LOG.info(
|
||||
_LI("poll_for_serial_number: Calling mdns for zone '%(zone)s', "
|
||||
"serial '%(serial)s' on nameserver '%(host)s:%(port)s'") %
|
||||
"serial '%(serial)s' on nameserver '%(host)s:%(port)s'"),
|
||||
{'zone': zone.name, 'serial': zone.serial,
|
||||
'host': nameserver.host, 'port': nameserver.port})
|
||||
# The poll_for_serial_number method is a cast rather than a call since
|
||||
|
@ -103,7 +103,7 @@ class MdnsAPI(object):
|
|||
retry_interval, max_retries, delay):
|
||||
LOG.info(
|
||||
_LI("get_serial_number: Calling mdns for zone '%(zone)s', serial "
|
||||
"%(serial)s' on nameserver '%(host)s:%(port)s'") %
|
||||
"%(serial)s' on nameserver '%(host)s:%(port)s'"),
|
||||
{'zone': zone.name, 'serial': zone.serial,
|
||||
'host': host, 'port': port})
|
||||
cctxt = self.notify_client.prepare()
|
||||
|
@ -114,6 +114,6 @@ class MdnsAPI(object):
|
|||
delay=delay)
|
||||
|
||||
def perform_zone_xfr(self, context, zone):
|
||||
LOG.info(_LI("perform_zone_xfr: Calling mdns for zone %(zone)s") %
|
||||
LOG.info(_LI("perform_zone_xfr: Calling mdns for zone %(zone)s"),
|
||||
{"zone": zone.name})
|
||||
return self.xfr_client.cast(context, 'perform_zone_xfr', zone=zone)
|
||||
|
|
|
@ -453,7 +453,7 @@ def get_paging_params(params, sort_keys):
|
|||
|
||||
def bind_tcp(host, port, tcp_backlog, tcp_keepidle=None):
|
||||
# Bind to the TCP port
|
||||
LOG.info(_LI('Opening TCP Listening Socket on %(host)s:%(port)d') %
|
||||
LOG.info(_LI('Opening TCP Listening Socket on %(host)s:%(port)d'),
|
||||
{'host': host, 'port': port})
|
||||
sock_tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
sock_tcp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
|
@ -480,7 +480,7 @@ def bind_tcp(host, port, tcp_backlog, tcp_keepidle=None):
|
|||
|
||||
def bind_udp(host, port):
|
||||
# Bind to the UDP port
|
||||
LOG.info(_LI('Opening UDP Listening Socket on %(host)s:%(port)d') %
|
||||
LOG.info(_LI('Opening UDP Listening Socket on %(host)s:%(port)d'),
|
||||
{'host': host, 'port': port})
|
||||
sock_udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
sock_udp.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
|
|
Loading…
Reference in New Issue