diff --git a/include/transport/HTTPRequest.h b/include/transport/HTTPRequest.h index f655a626..c3b25b7b 100644 --- a/include/transport/HTTPRequest.h +++ b/include/transport/HTTPRequest.h @@ -39,6 +39,10 @@ class HTTPRequest : public Thread { void run(); void finalize(); + const std::string &getURL() { + return m_url; + } + boost::signal onRequestFinished; private: diff --git a/include/transport/HTTPRequestQueue.h b/include/transport/HTTPRequestQueue.h index 7d4ef741..5fbf8fab 100644 --- a/include/transport/HTTPRequestQueue.h +++ b/include/transport/HTTPRequestQueue.h @@ -18,7 +18,7 @@ class Component; class HTTPRequestQueue { public: - HTTPRequestQueue(Component *component, int delayBetweenRequests = 1); + HTTPRequestQueue(Component *component, const std::string &user, int delayBetweenRequests = 1); virtual ~HTTPRequestQueue(); @@ -34,6 +34,7 @@ class HTTPRequestQueue { std::queue m_queue; HTTPRequest *m_req; Swift::Timer::ref m_queueTimer; + std::string m_user; }; } diff --git a/libtransport/HTTPRequestQueue.cpp b/libtransport/HTTPRequestQueue.cpp index 11f39b4a..76ad33ba 100644 --- a/libtransport/HTTPRequestQueue.cpp +++ b/libtransport/HTTPRequestQueue.cpp @@ -6,9 +6,10 @@ namespace Transport { DEFINE_LOGGER(logger, "HTTPRequestQueue") -HTTPRequestQueue::HTTPRequestQueue(Component *component, int delay) { +HTTPRequestQueue::HTTPRequestQueue(Component *component, const std::string &user, int delay) { m_delay = delay; m_req = NULL; + m_user = user; m_queueTimer = component->getNetworkFactories()->getTimerFactory()->createTimer(500); m_queueTimer->onTick.connect(boost::bind(&HTTPRequestQueue::sendNextRequest, this)); @@ -29,20 +30,21 @@ void HTTPRequestQueue::handleRequestFinished() { void HTTPRequestQueue::sendNextRequest() { if (m_queue.empty()) { - LOG4CXX_INFO(logger, "queue is empty"); + LOG4CXX_INFO(logger, m_user << ": Queue is empty."); m_req = NULL; m_queueTimer->stop(); return; } if (m_req) { - LOG4CXX_INFO(logger, "we are handling the request"); + LOG4CXX_INFO(logger, m_user << ": There is already a request being handled."); return; } - LOG4CXX_INFO(logger, "Starting new request"); m_req = m_queue.front(); m_queue.pop(); + + LOG4CXX_INFO(logger, m_user << ": Starting request '" << m_req->getURL() << "'."); m_req->onRequestFinished.connect(boost::bind(&HTTPRequestQueue::handleRequestFinished, this)); m_req->execute(); } @@ -50,10 +52,12 @@ void HTTPRequestQueue::sendNextRequest() { void HTTPRequestQueue::queueRequest(HTTPRequest *req) { m_queue.push(req); - LOG4CXX_INFO(logger, "request queued"); if (!m_req) { sendNextRequest(); } + else { + LOG4CXX_INFO(logger, m_user << ": Request '" << req->getURL() << "' queued."); + } } diff --git a/spectrum/src/frontends/slack/SlackAPI.cpp b/spectrum/src/frontends/slack/SlackAPI.cpp index a99b7046..74a37784 100644 --- a/spectrum/src/frontends/slack/SlackAPI.cpp +++ b/spectrum/src/frontends/slack/SlackAPI.cpp @@ -71,7 +71,7 @@ DEFINE_LOGGER(logger, "SlackAPI"); NAME = NAME##_tmp.GetString(); \ } -SlackAPI::SlackAPI(Component *component, SlackIdManager *idManager, const std::string &token, const std::string &domain) : HTTPRequestQueue(component) { +SlackAPI::SlackAPI(Component *component, SlackIdManager *idManager, const std::string &token, const std::string &domain) : HTTPRequestQueue(component, domain) { m_component = component; m_token = token; m_idManager = idManager;