add logging function

This commit is contained in:
Seth Schoen 2012-11-18 20:31:58 -08:00
parent 99a679209c
commit ef8d3b661e

View file

@ -2,9 +2,6 @@
# functions common to the various kinds of daemon
# TODO: define a log function that sends a pubsub message to the
# logger daemon
import time, binascii
from Crypto import Random
@ -27,3 +24,9 @@ def random():
def random_raw():
"""Return 32 random bytes."""
return Random.get_random_bytes(32)
def log(msg, session = None):
if session:
r.publish("logs", "%s: %s" % (short(session), msg))
else:
r.publish("logs", "%s" % session)