from mod_python import apache, util
import osrf.system, osrf.cache, osrf.json, osrf.conf, osrf.net, osrf.log
from osrf.const import OSRF_MESSAGE_TYPE_DISCONNECT, OSRF_MESSAGE_TYPE_CONNECT, \
- OSRF_STATUS_CONTINUE, OSRF_STATUS_TIMEOUT, OSRF_MESSAGE_TYPE_STATUS
+ OSRF_STATUS_CONTINUE, OSRF_STATUS_TIMEOUT, OSRF_MESSAGE_TYPE_STATUS, OSRF_MESSAGE_TYPE_REQUEST
'''
elif osrf_msgs[0].type() == OSRF_MESSAGE_TYPE_DISCONNECT:
self.disconnect_only = True
+ '''
+ [76.202.6.250] [] open-ils.search open-ils.search.biblio.metarecord_to_records 0, {"format":null,"org":1,"depth":"0"}
+ '''
+ for msg in osrf_msgs:
+ if msg.type() == OSRF_MESSAGE_TYPE_REQUEST:
+ method = msg.payload()
+ params = osrf.json.to_json(method.params())
+ if len(params) == 2:
+ params = ''
+ else:
+ params = params[1:len(params)-1]
+
+ osrf.log.log_activity("[%s] [%s] %s %s %s" % (
+ self.remote_host,
+ '', # XXX auth token?
+ self.service,
+ method.method(),
+ params
+ ))
+
+
return True
obj = self.cache.get(self.thread)
if obj and obj['ip'] == self.remote_host and \
obj['jid'] == self.recipient:
+ self.service = obj['service']
return True
osrf.log.log_warn("client [%s] attempted to send directly "
"[%s] without a session" % (self.remote_host, self.recipient))
else:
self.apreq.content_type = JSON_CONTENT_TYPE
self.cache.put(self.thread, \
- {'ip':self.remote_host, 'jid': net_msg.sender}, CACHE_TIME)
+ {'ip':self.remote_host, 'jid': net_msg.sender, 'service':self.service}, CACHE_TIME)
osrf.log.log_debug("caching session [%s] for host [%s] and server "
" drone [%s]" % (self.thread, self.remote_host, net_msg.sender))
import traceback, sys, os, re, threading, time
from osrf.const import OSRF_LOG_DEBUG, OSRF_LOG_ERR, OSRF_LOG_INFO, \
OSRF_LOG_INTERNAL, OSRF_LOG_TYPE_FILE, OSRF_LOG_TYPE_STDERR, \
- OSRF_LOG_TYPE_SYSLOG, OSRF_LOG_WARN
+ OSRF_LOG_TYPE_SYSLOG, OSRF_LOG_WARN, OSRF_LOG_ACT
LOG_SEMAPHORE = threading.BoundedSemaphore(value=1)
__log(OSRF_LOG_WARN, debug_str)
def log_error(debug_str):
__log(OSRF_LOG_ERR, debug_str)
+def log_activity(debug_str):
+ __log(OSRF_LOG_ACT, debug_str)
def __log(level, msg):
"""Builds the log message and passes the message off to the logger."""
lvl = 'WARN'
if level == OSRF_LOG_ERR:
lvl = 'ERR '
+ if level == OSRF_LOG_ACT:
+ lvl = 'ACT '
filename = FRGX.sub('', tb[0])
msg = '[%s:%d:%s:%s:%s:%s] %s' % (lvl, os.getpid(), filename, tb[1], threading.currentThread().getName(), _xid, msg)
slvl = syslog.LOG_DEBUG
if level == OSRF_LOG_INTERNAL:
slvl = syslog.LOG_DEBUG
- if level == OSRF_LOG_INFO:
+ if level == OSRF_LOG_INFO or level == OSRF_LOG_ACT:
slvl = syslog.LOG_INFO
if level == OSRF_LOG_WARN:
slvl = syslog.LOG_WARNING