[Opensrf-commits] r1172 - trunk/src/python/osrf
svn at svn.open-ils.org
svn at svn.open-ils.org
Sun Dec 16 11:58:28 EST 2007
Author: dbs
Date: 2007-12-16 11:37:11 -0500 (Sun, 16 Dec 2007)
New Revision: 1172
Modified:
trunk/src/python/osrf/cache.py
trunk/src/python/osrf/http_translator.py
trunk/src/python/osrf/log.py
trunk/src/python/osrf/net.py
trunk/src/python/osrf/ses.py
trunk/src/python/osrf/stack.py
Log:
Further pedanticize logging method names.
Modified: trunk/src/python/osrf/cache.py
===================================================================
--- trunk/src/python/osrf/cache.py 2007-12-16 16:20:41 UTC (rev 1171)
+++ trunk/src/python/osrf/cache.py 2007-12-16 16:37:11 UTC (rev 1172)
@@ -38,16 +38,16 @@
if timeout is None:
timeout = defaultTimeout
json = to_json(val)
- osrf.log.osrfLogInternal("cache: %s => %s" % (str(key), json))
+ osrf.log.log_internal("cache: %s => %s" % (str(key), json))
return self.client.set(str(key), json, timeout)
def get(self, key):
obj = self.client.get(str(key))
- osrf.log.osrfLogInternal("cache: fetching %s => %s" % (str(key), obj))
+ osrf.log.log_internal("cache: fetching %s => %s" % (str(key), obj))
return to_object(obj or "null")
def delete(self, key):
- osrf.log.osrfLogInternal("cache: deleting %s" % str(key))
+ osrf.log.log_internal("cache: deleting %s" % str(key))
self.client.delete(str(key))
@staticmethod
Modified: trunk/src/python/osrf/http_translator.py
===================================================================
--- trunk/src/python/osrf/http_translator.py 2007-12-16 16:20:41 UTC (rev 1171)
+++ trunk/src/python/osrf/http_translator.py 2007-12-16 16:37:11 UTC (rev 1172)
@@ -200,7 +200,7 @@
'''
if self.service:
if self.recipient:
- osrf.log.osrfLogWarn("specifying both SERVICE and TO is not allowed")
+ osrf.log.log_warn("specifying both SERVICE and TO is not allowed")
return False
self.recipient = "%s@%s/%s" % \
(ROUTER_NAME, OSRF_DOMAIN, self.service)
@@ -213,7 +213,7 @@
if obj and obj['ip'] == self.remote_host and \
obj['jid'] == self.recipient:
return True
- osrf.log.osrfLogWarn("client [%s] attempted to send directly "
+ osrf.log.log_warn("client [%s] attempted to send directly "
"[%s] without a session" % (self.remote_host, self.recipient))
return False
Modified: trunk/src/python/osrf/log.py
===================================================================
--- trunk/src/python/osrf/log.py 2007-12-16 16:20:41 UTC (rev 1171)
+++ trunk/src/python/osrf/log.py 2007-12-16 16:37:11 UTC (rev 1172)
@@ -49,18 +49,18 @@
# -----------------------------------------------------------------------
# Define wrapper functions for the log levels
# -----------------------------------------------------------------------
-def osrfLogInternal(s):
- __osrfLog(OSRF_LOG_INTERNAL, s)
+def log_internal(s):
+ __log(OSRF_LOG_INTERNAL, s)
def logDebug(s):
- __osrfLog(OSRF_LOG_DEBUG, s)
-def osrfLogInfo(s):
- __osrfLog(OSRF_LOG_INFO, s)
-def osrfLogWarn(s):
- __osrfLog(OSRF_LOG_WARN, s)
+ __log(OSRF_LOG_DEBUG, s)
+def log_info(s):
+ __log(OSRF_LOG_INFO, s)
+def log_warn(s):
+ __log(OSRF_LOG_WARN, s)
def logError(s):
- __osrfLog(OSRF_LOG_ERR, s)
+ __log(OSRF_LOG_ERR, s)
-def __osrfLog(level, msg):
+def __log(level, msg):
"""Builds the log message and passes the message off to the logger."""
global LOG_LEVEL, LOG_TYPE
Modified: trunk/src/python/osrf/net.py
===================================================================
--- trunk/src/python/osrf/net.py 2007-12-16 16:20:41 UTC (rev 1171)
+++ trunk/src/python/osrf/net.py 2007-12-16 16:37:11 UTC (rev 1172)
@@ -111,14 +111,14 @@
self.receive_callback = func
def session_started(self):
- osrf.log.osrfLogInfo("Successfully connected to the opensrf network")
+ osrf.log.log_info("Successfully connected to the opensrf network")
self.authenticated()
self.stream.set_message_handler("normal", self.message_received)
self.isconnected = True
def send(self, message):
"""Sends the provided network message."""
- osrf.log.osrfLogInternal("jabber sending to %s: %s" % \
+ osrf.log.log_internal("jabber sending to %s: %s" % \
(message.recipient, message.body))
msg = Message(None, None, message.recipient, None, None, None, \
message.body, message.thread)
@@ -129,7 +129,7 @@
if stanza.get_type()=="headline":
return True
# check for errors
- osrf.log.osrfLogInternal("jabber received message from %s : %s"
+ osrf.log.log_internal("jabber received message from %s : %s"
% (stanza.get_from().as_utf8(), stanza.get_body()))
self.queue.append(NetworkMessage(stanza))
return True
@@ -149,7 +149,7 @@
act = self.get_stream().loop_iter(timeout)
endtime = time.time() - starttime
timeout -= endtime
- osrf.log.osrfLogInternal("exiting stream loop after %s seconds. "
+ osrf.log.log_internal("exiting stream loop after %s seconds. "
"act=%s, queue size=%d" % (str(endtime), act, len(self.queue)))
if not act:
self.idle()
Modified: trunk/src/python/osrf/ses.py
===================================================================
--- trunk/src/python/osrf/ses.py 2007-12-16 16:20:41 UTC (rev 1171)
+++ trunk/src/python/osrf/ses.py 2007-12-16 16:37:11 UTC (rev 1172)
@@ -53,7 +53,7 @@
def wait(self, timeout=120):
"""Wait up to <timeout> seconds for data to arrive on the network"""
- osrf.log.osrfLogInternal("Session.wait(%d)" % timeout)
+ osrf.log.log_internal("Session.wait(%d)" % timeout)
handle = osrf.net.get_network_handle()
handle.recv(timeout)
@@ -174,12 +174,12 @@
def set_remote_id(self, remoteid):
self.remote_id = remoteid
- osrf.log.osrfLogInternal("Setting request remote ID to %s" % self.remote_id)
+ osrf.log.log_internal("Setting request remote ID to %s" % self.remote_id)
def reset_remote_id(self):
"""Recovers the original remote id"""
self.remote_id = self.orig_remote_id
- osrf.log.osrfLogInternal("Resetting remote ID to %s" % self.remote_id)
+ osrf.log.log_internal("Resetting remote ID to %s" % self.remote_id)
def push_response_queue(self, message):
"""Pushes the message payload onto the response queue
@@ -188,7 +188,7 @@
try:
self.find_request(message.threadTrace()).pushResponse(message.payload())
except Exception, e:
- osrf.log.osrfLogWarn("pushing respond to non-existent request %s : %s" % (message.threadTrace(), e))
+ osrf.log.log_warn("pushing respond to non-existent request %s : %s" % (message.threadTrace(), e))
def find_request(self, rid):
"""Returns the original request matching this message's threadTrace."""
Modified: trunk/src/python/osrf/stack.py
===================================================================
--- trunk/src/python/osrf/stack.py 2007-12-16 16:20:41 UTC (rev 1171)
+++ trunk/src/python/osrf/stack.py 2007-12-16 16:37:11 UTC (rev 1172)
@@ -35,7 +35,7 @@
omessages = osrf.json.to_object(net_msg.body)
- osrf.log.osrfLogInternal("push(): received %d messages" \
+ osrf.log.log_internal("push(): received %d messages" \
% len(omessages))
# Pass each bundled opensrf message to the message handler
@@ -45,11 +45,11 @@
duration = time.time() - start
if isinstance(ses, osrf.ses.ServerSession):
- osrf.log.osrfLogInfo("Message processing duration %f" % duration)
+ osrf.log.log_info("Message processing duration %f" % duration)
def handle_message(session, message):
- osrf.log.osrfLogInternal("handle_message(): processing message of "
+ osrf.log.log_internal("handle_message(): processing message of "
"type %s" % message.type())
if isinstance(session, osrf.ses.ClientSession):
@@ -62,14 +62,14 @@
status_code = int(message.payload().statusCode())
status_text = message.payload().status()
- osrf.log.osrfLogInternal("handle_message(): processing STATUS, "
+ osrf.log.log_internal("handle_message(): processing STATUS, "
"status_code = %d" % status_code)
if status_code == OSRF_STATUS_COMPLETE:
# The server has informed us that this request is complete
req = session.find_request(message.threadTrace())
if req:
- osrf.log.osrfLogInternal("marking request as complete: %d" % req.rid)
+ osrf.log.log_internal("marking request as complete: %d" % req.rid)
req.set_complete()
return
More information about the opensrf-commits
mailing list