forked from edx/insights
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplayback.py
More file actions
51 lines (38 loc) · 1.26 KB
/
playback.py
File metadata and controls
51 lines (38 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import logging, logging.handlers
import sys
logging.handlers.HTTPHandler('','',method='GET')
logger = logging.getLogger('simple_example')
http_handler = logging.handlers.HTTPHandler('127.0.0.1:9022', '/event', method='GET')
logger.addHandler(http_handler)
#logger.setLevel(logging.DEBUG)
f=open(sys.argv[1])
for i in range(10):
line = f.readline()
print line
logger.critical(line)
## For reference, the exert of the relevant Python logger
# import errno, logging, socket, os, pickle, struct, time, re
# from codecs import BOM_UTF8
# from stat import ST_DEV, ST_INO, ST_MTIME
# import queue
# try:
# import threading
# except ImportError: #pragma: no cover
# threading = None
# import http.client, urllib.parse
# port = 9022
# method = "GET"
# host = "127.0.0.1"
# url = "/"
# h = http.client.HTTPConnection(host)
# url = url + "?%s" % (sep, data)
# for item in lines:
# data = urllib.parse.urlencode(record)
# h.putrequest(method, url)
# h.putheader("Host", host)
# if method == "POST":
# h.putheader("Content-type",
# "application/x-www-form-urlencoded")
# h.putheader("Content-length", str(len(data)))
# h.send(data.encode('utf-8'))
# h.getresponse() #can't do anything with the result