Created
July 26, 2011 11:45
-
-
Save RJ/1106554 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys, os, pgq, skytools, json | |
class IRCLogger(pgq.Consumer): | |
def logIrcEvent(self, row): | |
"""log to disk""" | |
obj = json.loads(row['json']) | |
self.log.info("LOGGED EVENT JSON: %s", obj['msg']) | |
return True | |
def process_batch(self, src_db, batch_id, ev_list): | |
for ev in ev_list: | |
d = skytools.db_urldecode(ev.data) | |
self.log.debug ("event : %s | type : %s | inserted by : %s" % (d, ev.type, ev.extra1)) | |
if not self.logIrcEvent(d): | |
sys.exit(1) | |
ev.tag_done() | |
if __name__ == '__main__': | |
script = IRCLogger("irclog_logger","src_db",sys.argv[1:]) | |
script.start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment