From: dbs Date: Sun, 16 Dec 2007 16:37:11 +0000 (+0000) Subject: Further pedanticize logging method names. X-Git-Tag: osrf_rel_2_0_1~795 X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=188f3e121c5bf175b311a0ace9f7f54f0d8c3d58;p=OpenSRF.git Further pedanticize logging method names. git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1172 9efc2488-bf62-4759-914b-345cdb29e865 --- diff --git a/src/python/osrf/cache.py b/src/python/osrf/cache.py index 01e4dbf..754a4fd 100644 --- a/src/python/osrf/cache.py +++ b/src/python/osrf/cache.py @@ -38,16 +38,16 @@ class CacheClient(object): 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 diff --git a/src/python/osrf/http_translator.py b/src/python/osrf/http_translator.py index b532f3f..012a596 100644 --- a/src/python/osrf/http_translator.py +++ b/src/python/osrf/http_translator.py @@ -200,7 +200,7 @@ class HTTPTranslator(object): ''' 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 @@ class HTTPTranslator(object): 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 diff --git a/src/python/osrf/log.py b/src/python/osrf/log.py index 6d6df3c..5a3a626 100644 --- a/src/python/osrf/log.py +++ b/src/python/osrf/log.py @@ -49,18 +49,18 @@ def initialize(level, facility=None, logfile=None): # ----------------------------------------------------------------------- # 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 diff --git a/src/python/osrf/net.py b/src/python/osrf/net.py index 78fc90a..c1db6a8 100644 --- a/src/python/osrf/net.py +++ b/src/python/osrf/net.py @@ -111,14 +111,14 @@ class Network(JabberClient): 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 @@ class Network(JabberClient): 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 @@ class Network(JabberClient): 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() diff --git a/src/python/osrf/ses.py b/src/python/osrf/ses.py index 452813c..d2e9a4e 100644 --- a/src/python/osrf/ses.py +++ b/src/python/osrf/ses.py @@ -53,7 +53,7 @@ class Session(object): def wait(self, timeout=120): """Wait up to 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 @@ class ClientSession(Session): 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 @@ class ClientSession(Session): 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.""" diff --git a/src/python/osrf/stack.py b/src/python/osrf/stack.py index 976396f..23fbf7e 100644 --- a/src/python/osrf/stack.py +++ b/src/python/osrf/stack.py @@ -35,7 +35,7 @@ def push(net_msg): 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 @@ def push(net_msg): 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 @@ def handle_message(session, message): 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