From bdb71ac8cab25916e0e1321b31e77cce83560157 Mon Sep 17 00:00:00 2001 From: Jack O'Sullivan Date: Fri, 23 Aug 2019 22:21:43 +0100 Subject: [PATCH] Use logging formatter --- net-dhcp/__init__.py | 2 +- net-dhcp/network.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/net-dhcp/__init__.py b/net-dhcp/__init__.py index 6638d31..dbee061 100644 --- a/net-dhcp/__init__.py +++ b/net-dhcp/__init__.py @@ -14,7 +14,7 @@ from . import network logger = logging.getLogger('gunicorn.error') @app.errorhandler(404) -def err_not_found(e): +def err_not_found(_e): return jsonify({'Err': 'API not found'}), 404 @app.errorhandler(Exception) diff --git a/net-dhcp/network.py b/net-dhcp/network.py index 070c623..6d91bc2 100644 --- a/net-dhcp/network.py +++ b/net-dhcp/network.py @@ -66,7 +66,7 @@ def create_net(): if request.json['IPv6Data']: return jsonify({'Err': 'IPv6 is currently unsupported'}), 400 - logger.info(f'Creating network "{req["NetworkID"]}" (using bridge "{desired}")') + logger.info('Creating network "%s" (using bridge "%s")', req['NetworkID'], desired) return jsonify({}) @app.route('/NetworkDriver.DeleteNetwork', methods=['POST']) @@ -82,7 +82,7 @@ def create_endpoint(): bridge_addrs = iface_addrs(bridge) if_host, if_container = veth_pair(req['EndpointID']) - logger.info(f'creating veth pair {if_host} <=> {if_container}') + logger.info('creating veth pair %s <=> %s', if_host, if_container) if_host = (ndb.interfaces.create(ifname=if_host, kind='veth', peer=if_container) .set('state', 'up') .commit()) @@ -118,7 +118,7 @@ def create_endpoint(): raise NetDhcpError(400, f'No suitable network found for {type_} address {a} on bridge {bridge["ifname"]}') to_add = f'{a}/{net.prefixlen}' - logger.info(f'Adding address {to_add} to {if_container["ifname"]}') + logger.info('Adding address %s to %s', to_add, if_container['ifname']) (if_container .add_ip(to_add) .commit())