summaryrefslogtreecommitdiffstats
path: root/src/shared
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/shared
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/shared')
-rw-r--r--src/shared/ClashAvoider.cpp24
-rw-r--r--src/shared/HTTPSender.cpp18
-rw-r--r--src/shared/LV2Object.cpp7
-rw-r--r--src/shared/LV2URIMap.cpp7
-rw-r--r--src/shared/OSCSender.cpp7
-rw-r--r--src/shared/Store.cpp3
6 files changed, 35 insertions, 31 deletions
diff --git a/src/shared/ClashAvoider.cpp b/src/shared/ClashAvoider.cpp
index 37b1cc9b..014ce7c1 100644
--- a/src/shared/ClashAvoider.cpp
+++ b/src/shared/ClashAvoider.cpp
@@ -17,6 +17,7 @@
#include <cstdio>
#include <sstream>
+#include "raul/log.hpp"
#include "ClashAvoider.hpp"
#include "Store.hpp"
@@ -40,8 +41,7 @@ ClashAvoider::map_uri(const Raul::URI& in)
const Path
ClashAvoider::map_path(const Raul::Path& in)
{
- //cout << "MAP PATH: " << in;
- //cout << endl << "**** MAP PATH: " << in << endl;
+ debug << "MAP PATH: " << in;
unsigned offset = 0;
bool has_offset = false;
@@ -51,18 +51,18 @@ ClashAvoider::map_path(const Raul::Path& in)
has_offset = (sscanf(trailing.c_str(), "%u", &offset) > 0);
}
- //cout << "OFFSET: " << offset << endl;
+ debug << "OFFSET: " << offset << endl;
// Path without _n suffix
Path base_path = in;
if (has_offset)
base_path = base_path.substr(0, base_path.find_last_of("_"));
- //cout << "BASE: " << base_path << endl;
+ debug << "BASE: " << base_path << endl;
SymbolMap::iterator m = _symbol_map.find(in);
if (m != _symbol_map.end()) {
- //cout << " (1) " << m->second << endl;
+ debug << " (1) " << m->second << endl;
return m->second;
} else {
typedef std::pair<SymbolMap::iterator, bool> InsertRecord;
@@ -70,12 +70,12 @@ ClashAvoider::map_path(const Raul::Path& in)
// See if parent is mapped
Path parent = in.parent();
do {
- //cout << "CHECK: " << parent << endl;
+ debug << "CHECK: " << parent << endl;
SymbolMap::iterator p = _symbol_map.find(parent);
if (p != _symbol_map.end()) {
const Path mapped = p->second.base() + in.substr(parent.base().length());
InsertRecord i = _symbol_map.insert(make_pair(in, mapped));
- //cout << " (2) " << i.first->second << endl;
+ debug << " (2) " << i.first->second << endl;
return i.first->second;
}
parent = parent.parent();
@@ -85,7 +85,7 @@ ClashAvoider::map_path(const Raul::Path& in)
if (!exists(in) && _symbol_map.find(in) == _symbol_map.end()) {
InsertRecord i = _symbol_map.insert(make_pair(in, in));
assert(i.second);
- //cout << " (3) " << i.first->second << endl;;
+ debug << " (3) " << i.first->second << endl;;
return i.first->second;
// Append _2 _3 etc until an unused symbol is found
@@ -99,7 +99,7 @@ ClashAvoider::map_path(const Raul::Path& in)
parent_str = parent_str.substr(0, parent_str.find_last_of("/"));
if (parent_str == "")
parent_str = "/";
- //cout << "***** PARENT: " << parent_str << endl;
+ debug << "PARENT: " << parent_str << endl;
}
if (offset == 0)
@@ -111,13 +111,13 @@ ClashAvoider::map_path(const Raul::Path& in)
const string name = (base_path.length() > 1) ? base_path.name() : "_";
string str = ss.str();
InsertRecord i = _symbol_map.insert(make_pair(in, str));
- //cout << "HIT: offset = " << offset << ", str = " << str << endl;
+ debug << "HIT: offset = " << offset << ", str = " << str << endl;
offset = _store.child_name_offset(in.parent(), name, false);
_offsets.insert(make_pair(base_path, offset));
- //cout << " (4) " << i.first->second << endl;;
+ debug << " (4) " << i.first->second << endl;;
return i.first->second;
} else {
- //cout << "MISSED OFFSET: " << in << " => " << ss.str() << endl;
+ debug << "MISSED OFFSET: " << in << " => " << ss.str() << endl;
if (o != _offsets.end())
offset = ++o->second;
else
diff --git a/src/shared/HTTPSender.cpp b/src/shared/HTTPSender.cpp
index 971fdef1..cbfa0107 100644
--- a/src/shared/HTTPSender.cpp
+++ b/src/shared/HTTPSender.cpp
@@ -15,20 +15,20 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-
#include <cassert>
#include <cstdio>
#include <cstring>
-#include <iostream>
#include <unistd.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <errno.h>
+#include "raul/log.hpp"
#include "HTTPSender.hpp"
using namespace std;
+using namespace Raul;
namespace Ingen {
namespace Shared {
@@ -51,32 +51,32 @@ HTTPSender::HTTPSender()
// Create listen socket
if ((_listen_sock = socket(AF_INET, SOCK_STREAM, 0)) < 0 ) {
- fprintf(stderr, "Error creating listening socket (%s)\n", strerror(errno));
+ error << "Error creating listening socket (" << strerror(errno) << ")" << endl;
exit(EXIT_FAILURE);
}
// Bind our socket addresss to the listening socket
if (bind(_listen_sock, (struct sockaddr*)&addr, sizeof(addr)) < 0) {
- fprintf(stderr, "Error calling bind (%s)\n", strerror(errno));
+ error << "Error calling bind (%s)\n" << strerror(errno) << ")" << endl;
_listen_sock = -1;
}
// Find port number
socklen_t length = sizeof(addr);
if (getsockname(_listen_sock, (struct sockaddr*)&addr, &length) == -1) {
- fprintf(stderr, "Error calling getsockname (%s)\n", strerror(errno));
+ error << "Error calling getsockname (" << strerror(errno) << ")" << endl;
_listen_sock = -1;
return;
}
if (listen(_listen_sock, 1) < 0 ) {
- cerr << "Error calling listen: %s" << strerror(errno) << endl;
+ error << "Error calling listen (" << strerror(errno) << ")" << endl;
_listen_sock = -1;
return;
}
_listen_port = ntohs(addr.sin_port);
- cout << "Opening event stream on TCP port " << _listen_port << endl;
+ info << "Opening event stream on TCP port " << _listen_port << endl;
start();
}
@@ -94,13 +94,13 @@ void
HTTPSender::_run()
{
if (_listen_sock == -1) {
- cerr << "Unable to open socket, exiting sender thread" << endl;
+ error << "Unable to open socket, exiting sender thread" << endl;
return;
}
// Accept connection
if ((_client_sock = accept(_listen_sock, NULL, NULL) ) < 0) {
- cerr << "Error calling accept: " << strerror(errno) << endl;
+ error << "Error calling accept: " << strerror(errno) << endl;
return;
}
diff --git a/src/shared/LV2Object.cpp b/src/shared/LV2Object.cpp
index c3ea6541..16e8ff71 100644
--- a/src/shared/LV2Object.cpp
+++ b/src/shared/LV2Object.cpp
@@ -15,7 +15,7 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include <iostream>
+#include "raul/log.hpp"
#include "raul/Atom.hpp"
#include "module/World.hpp"
#include "uri-map.lv2/uri-map.h"
@@ -25,6 +25,7 @@
#include "LV2URIMap.hpp"
using namespace std;
+using namespace Raul;
namespace Ingen {
namespace Shared {
@@ -81,13 +82,13 @@ from_atom(World* world, const Raul::Atom& atom, LV2_Object* object)
strncpy(str, atom.get_string(), object->size);
break;
case Raul::Atom::BLOB:
- cerr << "TODO: Blob support" << endl;
+ error << "TODO: Blob support" << endl;
/*object->type = map->object_class_string;
*(uint16_t*)(object + 1) = map->uri_to_id(NULL, atom.get_blob_type());
memcpy(((char*)(object + 1) + sizeof(uint32_t)), atom.get_blob(),
std::min(atom.data_size(), (size_t)object->size));*/
default:
- cerr << "Unsupported value type for toggle control" << endl;
+ error << "Unsupported value type for toggle control" << endl;
return false;
}
return true;
diff --git a/src/shared/LV2URIMap.cpp b/src/shared/LV2URIMap.cpp
index e401f6cb..c06d9187 100644
--- a/src/shared/LV2URIMap.cpp
+++ b/src/shared/LV2URIMap.cpp
@@ -17,12 +17,13 @@
#define __STDC_LIMIT_MACROS 1
#include <cassert>
-#include <iostream>
#include <stdint.h>
+#include "raul/log.hpp"
#include "object.lv2/object.h"
#include "LV2URIMap.hpp"
using namespace std;
+using namespace Raul;
namespace Ingen {
namespace Shared {
@@ -74,8 +75,8 @@ LV2URIMap::uri_map_uri_to_id(LV2_URI_Map_Callback_Data callback_data,
me->uri_map.insert(make_pair(string(uri), ret));
}
- /*cout << "URI MAP (" << (map ? (void*)map : NULL)
- << "): " << uri << " -> " << ret << endl;*/
+ debug << "URI MAP (" << (map ? (void*)map : NULL)
+ << "): " << uri << " -> " << ret << endl;
assert(ret <= UINT16_MAX);
return ret;
diff --git a/src/shared/OSCSender.cpp b/src/shared/OSCSender.cpp
index 03dff6f7..2d9cbbc4 100644
--- a/src/shared/OSCSender.cpp
+++ b/src/shared/OSCSender.cpp
@@ -15,13 +15,14 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "OSCSender.hpp"
#include <cassert>
-#include <iostream>
#include <unistd.h>
#include <stdarg.h>
+#include "raul/log.hpp"
+#include "OSCSender.hpp"
using namespace std;
+using namespace Raul;
namespace Ingen {
namespace Shared {
@@ -109,7 +110,7 @@ OSCSender::send_message(const char* path, lo_message msg)
if (_transfer) {
if (lo_bundle_length(_transfer) + lo_message_length(msg, path) > MAX_BUNDLE_SIZE) {
if (_send_state == SendingBundle)
- cerr << "WARNING: Maximum bundle size reached, bundle split" << endl;
+ warn << "Maximum bundle size reached, bundle split" << endl;
lo_send_bundle(_address, _transfer);
lo_timetag t;
lo_timetag_now(&t);
diff --git a/src/shared/Store.cpp b/src/shared/Store.cpp
index 73b2b7b7..f1c82360 100644
--- a/src/shared/Store.cpp
+++ b/src/shared/Store.cpp
@@ -16,6 +16,7 @@
*/
#include <sstream>
+#include "raul/log.hpp"
#include "raul/PathTable.hpp"
#include "raul/TableImpl.hpp"
#include "common/interface/Node.hpp"
@@ -33,7 +34,7 @@ void
Store::add(GraphObject* o)
{
if (find(o->path()) != end()) {
- cerr << "[Store] ERROR: Attempt to add duplicate object " << o->path() << endl;
+ error << "[Store] Attempt to add duplicate object " << o->path() << endl;
return;
}