MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / emit

Method emit

tools/python-3.11.9-amd64/Lib/logging/handlers.py:1247–1288  ·  view source on GitHub ↗

Emit a record. Send the record to the web server as a percent-encoded dictionary

(self, record)

Source from the content-addressed store, hash-verified

1245 return connection
1246
1247 def emit(self, record):
1248 """
1249 Emit a record.
1250
1251 Send the record to the web server as a percent-encoded dictionary
1252 """
1253 try:
1254 import urllib.parse
1255 host = self.host
1256 h = self.getConnection(host, self.secure)
1257 url = self.url
1258 data = urllib.parse.urlencode(self.mapLogRecord(record))
1259 if self.method == "GET":
1260 if (url.find('?') >= 0):
1261 sep = '&'
1262 else:
1263 sep = '?'
1264 url = url + "%c%s" % (sep, data)
1265 h.putrequest(self.method, url)
1266 # support multiple hosts on one IP address...
1267 # need to strip optional :port from host, if present
1268 i = host.find(":")
1269 if i >= 0:
1270 host = host[:i]
1271 # See issue #30904: putrequest call above already adds this header
1272 # on Python 3.x.
1273 # h.putheader("Host", host)
1274 if self.method == "POST":
1275 h.putheader("Content-type",
1276 "application/x-www-form-urlencoded")
1277 h.putheader("Content-length", str(len(data)))
1278 if self.credentials:
1279 import base64
1280 s = ('%s:%s' % self.credentials).encode('utf-8')
1281 s = 'Basic ' + base64.b64encode(s).strip().decode('ascii')
1282 h.putheader('Authorization', s)
1283 h.endheaders()
1284 if self.method == "POST":
1285 h.send(data.encode('utf-8'))
1286 h.getresponse() #can't do anything with the result
1287 except Exception:
1288 self.handleError(record)
1289
1290class BufferingHandler(logging.Handler):
1291 """

Callers

nothing calls this directly

Calls 13

getConnectionMethod · 0.95
mapLogRecordMethod · 0.95
strFunction · 0.85
stripMethod · 0.80
endheadersMethod · 0.80
findMethod · 0.45
putrequestMethod · 0.45
putheaderMethod · 0.45
encodeMethod · 0.45
decodeMethod · 0.45
sendMethod · 0.45
getresponseMethod · 0.45

Tested by

no test coverage detected