Emit a record. Send the record to the web server as a percent-encoded dictionary
(self, record)
| 1293 | return connection |
| 1294 | |
| 1295 | def emit(self, record): |
| 1296 | """ |
| 1297 | Emit a record. |
| 1298 | |
| 1299 | Send the record to the web server as a percent-encoded dictionary |
| 1300 | """ |
| 1301 | try: |
| 1302 | import urllib.parse |
| 1303 | host = self.host |
| 1304 | h = self.getConnection(host, self.secure) |
| 1305 | url = self.url |
| 1306 | data = urllib.parse.urlencode(self.mapLogRecord(record)) |
| 1307 | if self.method == "GET": |
| 1308 | if (url.find('?') >= 0): |
| 1309 | sep = '&' |
| 1310 | else: |
| 1311 | sep = '?' |
| 1312 | url = url + "%c%s" % (sep, data) |
| 1313 | h.putrequest(self.method, url) |
| 1314 | # support multiple hosts on one IP address... |
| 1315 | # need to strip optional :port from host, if present |
| 1316 | i = host.find(":") |
| 1317 | if i >= 0: |
| 1318 | host = host[:i] |
| 1319 | # See issue #30904: putrequest call above already adds this header |
| 1320 | # on Python 3.x. |
| 1321 | # h.putheader("Host", host) |
| 1322 | if self.method == "POST": |
| 1323 | h.putheader("Content-type", |
| 1324 | "application/x-www-form-urlencoded") |
| 1325 | h.putheader("Content-length", str(len(data))) |
| 1326 | if self.credentials: |
| 1327 | import base64 |
| 1328 | s = ('%s:%s' % self.credentials).encode('utf-8') |
| 1329 | s = 'Basic ' + base64.b64encode(s).strip().decode('ascii') |
| 1330 | h.putheader('Authorization', s) |
| 1331 | h.endheaders() |
| 1332 | if self.method == "POST": |
| 1333 | h.send(data.encode('utf-8')) |
| 1334 | h.getresponse() #can't do anything with the result |
| 1335 | except Exception: |
| 1336 | self.handleError(record) |
| 1337 | |
| 1338 | class BufferingHandler(logging.Handler): |
| 1339 | """ |
nothing calls this directly
no test coverage detected