From ef8d3b661e905fe12a5677e79123455c495d8c17 Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Sun, 18 Nov 2012 20:31:58 -0800 Subject: [PATCH] add logging function --- server-ca/daemon_common.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server-ca/daemon_common.py b/server-ca/daemon_common.py index 42c1f8e1d..80a0cb146 100644 --- a/server-ca/daemon_common.py +++ b/server-ca/daemon_common.py @@ -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)