summaryrefslogtreecommitdiffstats
path: root/src/client/HTTPClientReceiver.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2010-01-06 23:49:17 +0000
committerDavid Robillard <d@drobilla.net>2010-01-06 23:49:17 +0000
commitcb5e934666e128e27faa95587fbdecf01f0e324d (patch)
tree1e694e2812381efbb3eb4b5ace2cdecc118b29f6 /src/client/HTTPClientReceiver.cpp
parent092eb35edb999a9dd809e197d7dd9a4ebb0d6bd5 (diff)
downloadingen-cb5e934666e128e27faa95587fbdecf01f0e324d.tar.gz
ingen-cb5e934666e128e27faa95587fbdecf01f0e324d.tar.bz2
ingen-cb5e934666e128e27faa95587fbdecf01f0e324d.zip
Do all logging output via Raul streams.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2349 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/client/HTTPClientReceiver.cpp')
-rw-r--r--src/client/HTTPClientReceiver.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/client/HTTPClientReceiver.cpp b/src/client/HTTPClientReceiver.cpp
index 879d648a..9545bbe6 100644
--- a/src/client/HTTPClientReceiver.cpp
+++ b/src/client/HTTPClientReceiver.cpp
@@ -18,14 +18,16 @@
#include <list>
#include <cassert>
#include <cstring>
-#include <iostream>
#include <sstream>
#include <sys/socket.h>
#include <errno.h>
+#include "raul/log.hpp"
#include "raul/Atom.hpp"
#include "module/Module.hpp"
#include "HTTPClientReceiver.hpp"
+#define LOG(s) s << "[HTTPClientReceiver] "
+
using namespace std;
using namespace Raul;
@@ -71,7 +73,7 @@ HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::
string port_str = uri.substr(uri.find_last_of(":")+1);
int port = atoi(port_str.c_str());
- cout << "Client HTTP listen: " << uri << " (port " << port << ")" << endl;
+ LOG(info) << "Client HTTP listen: " << uri << " (port " << port << ")" << endl;
struct sockaddr_in servaddr;
@@ -82,21 +84,21 @@ HTTPClientReceiver::Listener::Listener(HTTPClientReceiver* receiver, const std::
// Create listen socket
if ((_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- cerr << "Error creating listening socket: %s" << strerror(errno) << endl;
+ LOG(error) << "Error creating listening socket: %s" << strerror(errno) << endl;
_sock = -1;
return;
}
// Set remote address (FIXME: always localhost)
if (inet_aton("127.0.0.1", &servaddr.sin_addr) <= 0) {
- cerr << "Invalid remote IP address" << endl;
+ LOG(error) << "Invalid remote IP address" << endl;
_sock = -1;
return;
}
// Connect to server
if (connect(_sock, (struct sockaddr*)&servaddr, sizeof(servaddr)) < 0) {
- cerr << "Error calling connect: " << strerror(errno) << endl;
+ LOG(error) << "Error calling connect: " << strerror(errno) << endl;
_sock = -1;
return;
}
@@ -127,7 +129,7 @@ HTTPClientReceiver::close_session()
void
HTTPClientReceiver::update(const std::string& str)
{
- cout << _world->parser->parse_update(_world, _target.get(), str, _url);
+ LOG(info) << _world->parser->parse_update(_world, _target.get(), str, _url);
}
void
@@ -155,7 +157,7 @@ HTTPClientReceiver::Listener::_run()
}
}
- cout << "HTTP listener finished" << endl;
+ LOG(info) << "HTTP listener finished" << endl;
}
@@ -168,11 +170,11 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
HTTPClientReceiver* me = (HTTPClientReceiver*)ptr;
const string path = soup_message_get_uri(msg)->path;
- /*cerr << "HTTP MESSAGE " << path << endl;
- cerr << msg->response_body->data << endl;*/
+ /*LOG(debug) << path << endl
+ << msg->response_body->data << endl;*/
if (msg->response_body->data == NULL) {
- cerr << "EMPTY CLIENT MESSAGE" << endl;
+ LOG(error) << "Empty client message" << endl;
return;
}
@@ -181,7 +183,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
} else if (path == "/plugins") {
if (msg->response_body->data == NULL) {
- cout << "ERROR: Empty response" << endl;
+ LOG(error) << "Empty response" << endl;
} else {
Glib::Mutex::Lock lock(me->_mutex);
me->_target->response_ok(0);
@@ -191,7 +193,7 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
} else if (path == "/patch") {
if (msg->response_body->data == NULL) {
- cout << "ERROR: Empty response" << endl;
+ LOG(error) << "Empty response" << endl;
} else {
Glib::Mutex::Lock lock(me->_mutex);
me->_target->response_ok(0);
@@ -202,19 +204,19 @@ HTTPClientReceiver::message_callback(SoupSession* session, SoupMessage* msg, voi
} else if (path == "/stream") {
if (msg->response_body->data == NULL) {
- cout << "ERROR: Empty response" << endl;
+ LOG(error) << "Empty response" << endl;
} else {
Glib::Mutex::Lock lock(me->_mutex);
string uri = string(soup_uri_to_string(soup_message_get_uri(msg), false));
uri = uri.substr(0, uri.find_last_of(":"));
uri += string(":") + msg->response_body->data;
- cout << "Stream URI: " << uri << endl;
+ LOG(info) << "Stream URI: " << uri << endl;
me->_listener = boost::shared_ptr<Listener>(new Listener(me, uri));
me->_listener->start();
}
} else {
- cerr << "UNKNOWN MESSAGE: " << path << endl;
+ LOG(error) << "Unknown message: " << path << endl;
me->update(msg->response_body->data);
}
}