Inspired by some discussions on the mailing list, I came up with this solution for
a MochiKit lo
'== ==
== =='
gging console. The basic idea is to have a python http server that just displays any request path.
The initial idea was to use the the MochiKit.Async.doSimpleXMLHttpRequest for the server communication. It looked like my browser (Firefox on Linux) wouldn't allow this. The only way to send a request to a foreign server was to set the 'src' attribute of an Image instance. (Please feel free to change that to a less shitty way of contact if there is any).
Usage:
var mylogger = new serverLogger(' http://localhost:8000')
here is the JavaScript Code:
serverLogger = function (baseurl) {
this.img = new Image();
this.baseurl = baseurl;
this.init()
}
update(serverLogger.prototype, {
'init': function () {
logger.addListener('weblog',null,this.logger());
},
'logger': function () {
var self = this;
return function (msg) {
self.img.src = self.baseurl+'?'+urlEncode(msg);
}
}
});
And here is the Python JavaScript Logging server:
import BaseHTTPServer
import urllib
class LogHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
def do_GET(self):
if len(self.path) > 2:
print urllib.unquote(self.path[2:])
else:
print self.path
if __name__ == '__main__':
BaseHTTPServer.test(HandlerClass=LogHTTPRequestHandler,ServerClass=BaseHTTPServer.HTTPServer)
