Browse Source

Handle log message interpolation by the logger

According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages
Closes-Bug: #1596829

Change-Id: I0c4a2a1cce98dbf78dd30850951466cd01491cfc
tags/1.15.0
Gábor Antal 2 years ago
parent
commit
8d67ca5cf4
2 changed files with 6 additions and 6 deletions
  1. 2
    2
      manilaclient/common/apiclient/client.py
  2. 4
    4
      manilaclient/common/httpclient.py

+ 2
- 2
manilaclient/common/apiclient/client.py View File

@@ -113,9 +113,9 @@ class HTTPClient(object):
113 113
             header = "-H '%s: %s'" % (element, kwargs['headers'][element])
114 114
             string_parts.append(header)
115 115
 
116
-        _logger.debug("REQ: %s" % " ".join(string_parts))
116
+        _logger.debug("REQ: %s", " ".join(string_parts))
117 117
         if 'data' in kwargs:
118
-            _logger.debug("REQ BODY: %s\n" % (kwargs['data']))
118
+            _logger.debug("REQ BODY: %s\n", (kwargs['data']))
119 119
 
120 120
     def _http_log_resp(self, resp):
121 121
         if not self.debug:

+ 4
- 4
manilaclient/common/httpclient.py View File

@@ -148,11 +148,11 @@ class HTTPClient(object):
148 148
                 if attempts > self.retries:
149 149
                     raise
150 150
 
151
-                self._logger.debug("Request error: %s" % six.text_type(e))
151
+                self._logger.debug("Request error: %s", six.text_type(e))
152 152
 
153 153
             self._logger.debug(
154 154
                 "Failed attempt(%(current)s of %(total)s), "
155
-                " retrying in %(sec)s seconds" % {
155
+                " retrying in %(sec)s seconds", {
156 156
                     'current': attempts,
157 157
                     'total': self.retries,
158 158
                     'sec': timeout
@@ -189,13 +189,13 @@ class HTTPClient(object):
189 189
             if "password" in data:
190 190
                 data = strutils.mask_password(data)
191 191
             string_parts.append(" -d '%s'" % data)
192
-        self._logger.debug("\nREQ: %s\n" % "".join(string_parts))
192
+        self._logger.debug("\nREQ: %s\n", "".join(string_parts))
193 193
 
194 194
     def log_response(self, resp):
195 195
         if not self.http_log_debug:
196 196
             return
197 197
         self._logger.debug(
198
-            "RESP: [%(code)s] %(headers)s\nRESP BODY: %(body)s\n" % {
198
+            "RESP: [%(code)s] %(headers)s\nRESP BODY: %(body)s\n", {
199 199
                 'code': resp.status_code,
200 200
                 'headers': resp.headers,
201 201
                 'body': resp.text

Loading…
Cancel
Save