From cb5e934666e128e27faa95587fbdecf01f0e324d Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 6 Jan 2010 23:49:17 +0000 Subject: Do all logging output via Raul streams. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2349 a436a847-0d15-0410-975c-d299462d15a1 --- src/bindings/ingen_bindings.cpp | 33 ++++++------ src/client/ClientStore.cpp | 65 +++++++++++------------- src/client/DeprecatedLoader.cpp | 33 ++++++------ src/client/HTTPClientReceiver.cpp | 32 ++++++------ src/client/HTTPEngineSender.cpp | 5 +- src/client/NodeModel.hpp | 1 - src/client/OSCClientReceiver.cpp | 16 +++--- src/client/OSCEngineSender.cpp | 8 +-- src/client/ObjectModel.cpp | 1 - src/client/ObjectModel.hpp | 1 - src/client/PatchModel.cpp | 4 +- src/client/PluginModel.hpp | 1 - src/client/PluginUI.cpp | 16 +++--- src/client/PortModel.hpp | 4 +- src/client/ThreadedSigClientInterface.cpp | 7 +-- src/common/interface/Plugin.hpp | 1 - src/engine/AudioBuffer.cpp | 6 +-- src/engine/AudioBuffer.hpp | 1 - src/engine/BufferFactory.cpp | 8 +-- src/engine/ClientBroadcaster.cpp | 12 +++-- src/engine/CompiledPatch.hpp | 1 - src/engine/ConnectionImpl.cpp | 15 +++--- src/engine/ConnectionImpl.hpp | 1 - src/engine/DuplexPort.cpp | 1 - src/engine/Engine.cpp | 5 +- src/engine/EngineStore.cpp | 19 ++----- src/engine/EventBuffer.cpp | 11 ++-- src/engine/EventSink.cpp | 1 - src/engine/HTTPClientSender.cpp | 3 +- src/engine/HTTPClientSender.hpp | 1 - src/engine/HTTPEngineReceiver.cpp | 6 +-- src/engine/InputPort.cpp | 3 +- src/engine/InternalPlugin.hpp | 1 - src/engine/JackDriver.cpp | 31 ++++++------ src/engine/LADSPANode.cpp | 12 ++--- src/engine/LADSPAPlugin.cpp | 5 +- src/engine/LADSPAPlugin.hpp | 1 - src/engine/LV2Info.cpp | 1 - src/engine/LV2Node.cpp | 16 +++--- src/engine/LV2Plugin.cpp | 2 +- src/engine/LV2Plugin.hpp | 1 - src/engine/LV2ResizeFeature.hpp | 5 +- src/engine/MessageContext.cpp | 7 +-- src/engine/NodeBase.cpp | 11 +--- src/engine/NodeFactory.cpp | 28 ++++------- src/engine/OSCClientSender.cpp | 6 +-- src/engine/OSCClientSender.hpp | 1 - src/engine/OSCEngineReceiver.cpp | 26 ++++------ src/engine/ObjectBuffer.cpp | 6 +-- src/engine/ObjectSender.cpp | 2 +- src/engine/OutputPort.cpp | 3 -- src/engine/PatchImpl.cpp | 18 +++---- src/engine/PluginImpl.cpp | 7 +-- src/engine/PluginImpl.hpp | 1 - src/engine/PortImpl.cpp | 1 - src/engine/PostProcessor.cpp | 5 +- src/engine/ProcessSlave.cpp | 1 - src/engine/QueuedEngineInterface.cpp | 10 ++-- src/engine/QueuedEventSource.cpp | 1 - src/engine/events/CreatePort.cpp | 4 +- src/engine/events/Disconnect.cpp | 8 +-- src/engine/events/SetMetadata.cpp | 3 +- src/engine/events/SetPortValue.cpp | 11 ++-- src/engine/ingen_http.cpp | 1 - src/engine/ingen_jack.cpp | 1 - src/engine/ingen_osc.cpp | 7 ++- src/engine/internals/Controller.cpp | 2 +- src/engine/internals/Note.cpp | 57 ++++++++++++++------- src/engine/internals/Trigger.cpp | 11 ++-- src/engine/mix.hpp | 6 ++- src/engine/util.hpp | 12 ++--- src/gui/App.cpp | 83 ++----------------------------- src/gui/App.hpp | 1 - src/gui/Configuration.cpp | 5 +- src/gui/ConnectWindow.cpp | 8 +-- src/gui/Connection.cpp | 1 - src/gui/ControlPanel.cpp | 56 +-------------------- src/gui/ControlPanel.hpp | 1 - src/gui/Controls.cpp | 7 +-- src/gui/GladeFactory.cpp | 9 ++-- src/gui/LoadPluginWindow.cpp | 1 - src/gui/LoadSubpatchWindow.cpp | 1 - src/gui/NodeControlWindow.cpp | 8 +-- src/gui/NodeMenu.cpp | 1 - src/gui/NodeModule.cpp | 11 ++-- src/gui/PatchCanvas.cpp | 29 ++++------- src/gui/PatchPortModule.cpp | 1 - src/gui/PatchPropertiesWindow.cpp | 1 - src/gui/PatchTreeWindow.cpp | 10 ++-- src/gui/PatchView.cpp | 16 ++---- src/gui/PatchView.hpp | 1 - src/gui/PatchWindow.cpp | 1 - src/gui/Port.cpp | 4 +- src/gui/PortMenu.cpp | 1 - src/gui/SubpatchModule.cpp | 11 ---- src/gui/SubpatchModule.hpp | 1 - src/gui/ThreadedLoader.cpp | 4 +- src/ingen/main.cpp | 1 + src/module/World.cpp | 23 +++++---- src/serialisation/Parser.cpp | 50 +++++++++---------- src/serialisation/Serialiser.cpp | 16 +++--- src/shared/ClashAvoider.cpp | 24 ++++----- src/shared/HTTPSender.cpp | 18 +++---- src/shared/LV2Object.cpp | 7 +-- src/shared/LV2URIMap.cpp | 7 +-- src/shared/OSCSender.cpp | 7 +-- src/shared/Store.cpp | 3 +- wscript | 5 ++ 108 files changed, 460 insertions(+), 628 deletions(-) diff --git a/src/bindings/ingen_bindings.cpp b/src/bindings/ingen_bindings.cpp index 82df3f90..913416c8 100644 --- a/src/bindings/ingen_bindings.cpp +++ b/src/bindings/ingen_bindings.cpp @@ -1,5 +1,5 @@ -#include #include "python2.4/Python.h" +#include "raul/log.hpp" #include "ingen_bindings.hpp" #include "engine/Engine.hpp" #include "module/World.hpp" @@ -7,25 +7,24 @@ bool run(Ingen::Shared::World* world, const char* filename) { - ingen_world = world; - - FILE* fd = fopen(filename, "r"); - if (fd) { - cerr << "Executing script " << filename << endl; - Py_Initialize(); - PyRun_SimpleFile(fd, filename); - Py_Finalize(); - return true; - } else { - cerr << "Unable to open script " << filename << endl; - return false; - } + ingen_world = world; + + FILE* fd = fopen(filename, "r"); + if (fd) { + info << "Executing script " << filename << endl; + Py_Initialize(); + PyRun_SimpleFile(fd, filename); + Py_Finalize(); + return true; + } else { + error << "Unable to open script " << filename << endl; + return false; + } } struct IngenBindingsModule : public Ingen::Shared::Module { void load(Ingen::Shared::World* world) { world->script_runners.insert(make_pair("application/x-python", &run)); - //lib->make_resident(); } }; @@ -44,8 +43,8 @@ ingen_module_load() { void script_iteration(Ingen::Shared::World* world) { - if (world->local_engine) - world->local_engine->main_iteration(); + if (world->local_engine) + world->local_engine->main_iteration(); } } // extern "C" diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 5d80af50..73d2b23e 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -15,6 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "raul/log.hpp" #include "raul/PathTable.hpp" #include "ClientStore.hpp" #include "ObjectModel.hpp" @@ -25,6 +26,8 @@ #include "PatchModel.hpp" #include "SigClientInterface.hpp" +#define LOG(s) s << "[ClientStore] " + using namespace std; using namespace Raul; @@ -96,11 +99,11 @@ ClientStore::add_object(SharedPtr object) i != object->properties().end(); ++i) object->signal_property(i->first, i->second); - /*cout << "[Store] Added " << object->path() << " {" << endl; + LOG(debug) << "Added " << object->path() << " {" << endl; for (iterator i = begin(); i != end(); ++i) { - cout << "\t" << i->first << endl; + LOG(debug) << "\t" << i->first << endl; } - cout << "}" << endl;*/ + LOG(debug) << "}" << endl; } @@ -116,11 +119,11 @@ ClientStore::remove_object(const Path& path) iterator descendants_end = find_descendants_end(i); SharedPtr removed = yank(i, descendants_end); - /*cout << "[Store] Removing " << i->first << " {" << endl; - for (iterator i = removed.begin(); i != removed.end(); ++i) { - cout << "\t" << i->first << endl; + LOG(debug) << "[ClientStore] Removing " << i->first << " {" << endl; + for (iterator i = removed->begin(); i != removed->end(); ++i) { + LOG(debug) << "\t" << i->first << endl; } - cout << "}" << endl;*/ + LOG(debug) << "}" << endl; if (result) result->signal_destroyed.emit(); @@ -201,7 +204,7 @@ ClientStore::del(const Path& path) { SharedPtr removed = remove_object(path); removed.reset(); - //cerr << "[ClientStore] removed object " << path << ", count: " << removed.use_count(); + debug << "[ClientStore] removed object " << path << ", count: " << removed.use_count(); } void @@ -212,7 +215,7 @@ ClientStore::move(const Path& old_path_str, const Path& new_path_str) iterator parent = find(old_path); if (parent == end()) { - cerr << "[Store] Failed to find object " << old_path << " to move." << endl; + LOG(error) << "Failed to find object " << old_path << " to move." << endl; return; } @@ -233,20 +236,12 @@ ClientStore::move(const Path& old_path_str, const Path& new_path_str) else child_new_path = new_path.base() + child_old_path.substr(old_path.length()+1); - cerr << "[Store] Renamed " << child_old_path << " -> " << child_new_path << endl; + LOG(info) << "Renamed " << child_old_path << " -> " << child_new_path << endl; PtrCast(i->second)->set_path(child_new_path); i->first = child_new_path; } cram(*removed.get()); - - //cerr << "[Store] Table:" << endl; - //for (size_t i=0; i < removed.size(); ++i) { - // cerr << removed[i].first << "\t\t: " << removed[i].second << endl; - //} - /*for (iterator i = begin(); i != end(); ++i) { - cerr << i->first << "\t\t: " << i->second << endl; - }*/ } @@ -254,10 +249,10 @@ void ClientStore::put(const URI& uri, const Resource::Properties& properties) { typedef Resource::Properties::const_iterator iterator; - /*cerr << "CLIENT PUT " << uri << " {" << endl; + LOG(debug) << "PUT " << uri << " {" << endl; for (iterator i = properties.begin(); i != properties.end(); ++i) - cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; - cerr << "}" << endl;*/ + LOG(debug) << " " << i->first << " = " << i->second << " :: " << i->second.type() << endl; + LOG(debug) << "}" << endl; bool is_path = Path::is_valid(uri.str()); bool is_meta = ResourceImpl::is_meta_uri(uri); @@ -273,7 +268,7 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) string path_str = is_meta ? (string("/") + uri.chop_start("#")) : uri.str(); if (!Path::is_valid(path_str)) { - cerr << "ERROR: Bad path: " << uri.str() << " - " << path_str << endl; + LOG(error) << "Bad path: " << uri.str() << " - " << path_str << endl; return; } @@ -302,7 +297,7 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) SharedPtr plug; if (p->second.is_valid() && p->second.type() == Atom::URI) { if (!(plug = plugin(p->second.get_uri()))) { - cout << "WARNING: Unable to find plugin " << p->second.get_uri() << endl; + LOG(warn) << "Unable to find plugin " << p->second.get_uri() << endl; plug = SharedPtr( new PluginModel(p->second.get_uri(), "ingen:nil", Resource::Properties())); add_plugin(plug); @@ -312,7 +307,7 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) n->set_properties(properties); add_object(n); } else { - cerr << "ERROR: Plugin with no type" << endl; + LOG(error) << "Plugin with no type" << endl; } } else if (is_port) { if (data_type != PortType::UNKNOWN) { @@ -321,10 +316,10 @@ ClientStore::put(const URI& uri, const Resource::Properties& properties) p->set_properties(properties); add_object(p); } else { - cerr << "WARNING: Port " << path << " has no type" << endl; + LOG(warn) << "Port " << path << " has no type" << endl; } } else { - cerr << "WARNING: Ignoring object " << path << " with unknown type " + LOG(warn) << "Ignoring object " << path << " with unknown type " << is_patch << " " << is_node << " " << is_port << endl; } } @@ -337,7 +332,7 @@ ClientStore::set_property(const URI& subject_uri, const URI& predicate, const At size_t hash = subject_uri.find("#"); if (!value.is_valid()) { - cerr << "ERROR: Property '" << predicate << "' is invalid" << endl; + LOG(error) << "Property '" << predicate << "' is invalid" << endl; } else if (subject) { subject->set_property(predicate, value); } else if (ResourceImpl::is_meta_uri(subject_uri)) { @@ -350,7 +345,7 @@ ClientStore::set_property(const URI& subject_uri, const URI& predicate, const At if (plugin) plugin->set_property(predicate, value); else - cerr << "WARNING: Property '" << predicate << "' for unknown object " << subject_uri << endl; + LOG(warn) << "Property '" << predicate << "' for unknown object " << subject_uri << endl; } } @@ -362,7 +357,7 @@ ClientStore::set_port_value(const Path& port_path, const Atom& value) if (port) port->value(value); else - cerr << "ERROR: Control change for non-existent port " << port_path << endl; + LOG(error) << "Control change for non-existent port " << port_path << endl; } @@ -373,7 +368,7 @@ ClientStore::set_voice_value(const Path& port_path, uint32_t voice, const Atom& if (port) port->value(voice, value); else - cerr << "ERROR: Polyphonic control change for non-existent port " << port_path << endl; + LOG(error) << "Polyphonic control change for non-existent port " << port_path << endl; } @@ -384,7 +379,7 @@ ClientStore::activity(const Path& path) if (port) port->signal_activity.emit(); else - cerr << "ERROR: Activity for non-existent port " << path << endl; + LOG(error) << "Activity for non-existent port " << path << endl; } @@ -406,7 +401,7 @@ ClientStore::connection_patch(const Path& src_port_path, const Path& dst_port_pa patch = PtrCast(this->object(src_port_path.parent().parent())); if (!patch) - cerr << "ERROR: Unable to find connection patch " << src_port_path + LOG(error) << "Unable to find connection patch " << src_port_path << " -> " << dst_port_path << endl; return patch; @@ -458,19 +453,19 @@ ClientStore::disconnect(const Path& src_port_path, const Path& dst_port_path) if (src_port) src_port->disconnected_from(dst_port); else - cerr << "WARNING: Disconnection from non-existent src port " << src_port_path << endl; + LOG(warn) << "Disconnection from non-existent src port " << src_port_path << endl; if (dst_port) dst_port->disconnected_from(dst_port); else - cerr << "WARNING: Disconnection from non-existent dst port " << dst_port_path << endl; + LOG(warn) << "Disconnection from non-existent dst port " << dst_port_path << endl; SharedPtr patch = connection_patch(src_port_path, dst_port_path); if (patch) patch->remove_connection(src_port_path, dst_port_path); else - cerr << "ERROR: Disconnection in non-existent patch: " + LOG(error) << "Disconnection in non-existent patch: " << src_port_path << " -> " << dst_port_path << endl; } diff --git a/src/client/DeprecatedLoader.cpp b/src/client/DeprecatedLoader.cpp index bbc5905d..088bf17d 100644 --- a/src/client/DeprecatedLoader.cpp +++ b/src/client/DeprecatedLoader.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include @@ -28,10 +27,13 @@ #include #include #include +#include "raul/log.hpp" #include "raul/Path.hpp" #include "interface/EngineInterface.hpp" #include "DeprecatedLoader.hpp" +#define LOG(s) s << "[DeprecatedLoader] " + #define NS_INTERNALS "http://drobilla.net/ns/ingen-internals#" using namespace std; @@ -211,7 +213,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, GraphObject::Properties initial_data, bool existing) { - cerr << "[DeprecatedLoader] Loading patch " << filename << " under " + LOG(info) << "Loading patch " << filename << " under " << parent_path << " / " << name << endl; Path path("/"); @@ -233,20 +235,20 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, xmlDocPtr doc = xmlParseFile(filename.c_str()); if (!doc) { - cerr << "Unable to parse patch file." << endl; + LOG(error) << "Unable to parse patch file." << endl; return ""; } xmlNodePtr cur = xmlDocGetRootElement(doc); if (!cur) { - cerr << "Empty document." << endl; + LOG(error) << "Empty document." << endl; xmlFreeDoc(doc); return ""; } if (xmlStrcmp(cur->name, (const xmlChar*) "patch")) { - cerr << "File is not an Ingen patch file (root node != )" << endl; + LOG(error) << "File is not an Om patch file (root node != )" << endl; xmlFreeDoc(doc); return ""; } @@ -340,7 +342,7 @@ DeprecatedLoader::load_patch(const Glib::ustring& filename, _engine->set_port_value(translate_load_path(i->port_path().str()), Atom(value)); } } else { - cerr << "WARNING: Unknown preset: \"" << pm->name() << endl; + LOG(warn) << "Unknown preset: \"" << pm->name() << endl; } } cur = cur->next; @@ -443,8 +445,8 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr } if (path == "") { - cerr << "[DeprecatedLoader] Malformed patch file (node tag has empty children)" << endl; - cerr << "[DeprecatedLoader] Node ignored." << endl; + LOG(error) << "Malformed patch file (node tag has empty children)" << endl; + LOG(error) << "Node ignored." << endl; return false; } @@ -483,7 +485,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr _engine->put(path, props); } else { is_port = false; - cerr << "WARNING: Unknown internal plugin label \"" << plugin_label << "\"" << endl; + LOG(warn) << "Unknown internal plugin label \"" << plugin_label << "\"" << endl; } } @@ -492,7 +494,7 @@ DeprecatedLoader::load_node(const Path& parent, xmlDocPtr doc, const xmlNodePtr const string new_path = (Path::is_valid(old_path) ? old_path : Path::pathify(old_path)); if (!Path::is_valid(old_path)) - cerr << "WARNING: Translating invalid port path \"" << old_path << "\" => \"" + LOG(warn) << "Translating invalid port path \"" << old_path << "\" => \"" << new_path << "\"" << endl; // Set up translations (for connections etc) to alias both the old @@ -584,7 +586,7 @@ DeprecatedLoader::load_subpatch(const string& base_filename, const Path& parent, cur = cur->next; } - cout << "[DeprecatedLoader] Loading subpatch " << filename << " under " << parent << endl; + LOG(info) << "Loading subpatch " << filename << " under " << parent << endl; // load_patch sets the passed variable last, so values stored in the parent // will override values stored in the child patch file load_patch(filename, false, parent, Symbol(nameify_if_invalid(name)), initial_data, false); @@ -623,8 +625,8 @@ DeprecatedLoader::load_connection(const Path& parent, xmlDocPtr doc, const xmlNo } if (source_node == "" || source_port == "" || dest_node == "" || dest_port == "") { - cerr << "ERROR: Malformed patch file (connection tag has empty children)" << endl; - cerr << "ERROR: Connection ignored." << endl; + LOG(error) << "Malformed patch file (connection tag has empty children)" << endl; + LOG(error) << "Connection ignored." << endl; return false; } @@ -689,8 +691,7 @@ DeprecatedLoader::load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePt if (port_name == "") { string msg = "Unable to parse control in patch file ( node = "; msg.append(node_name).append(", port = ").append(port_name).append(")"); - cerr << "ERROR: " << msg << endl; - //m_client_hooks->error(msg); + LOG(error) << msg << endl; } else { // FIXME: temporary compatibility, remove any slashes from port name // remove this soon once patches have migrated @@ -706,7 +707,7 @@ DeprecatedLoader::load_preset(const Path& parent, xmlDocPtr doc, const xmlNodePt cur = cur->next; } if (pm->name() == "") { - cerr << "Preset in patch file has no name." << endl; + LOG(error) << "Preset in patch file has no name." << endl; //m_client_hooks->error("Preset in patch file has no name."); pm->name("Unnamed"); } 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 #include #include -#include #include #include #include +#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(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); } } diff --git a/src/client/HTTPEngineSender.cpp b/src/client/HTTPEngineSender.cpp index ab8c7c3f..105d54a8 100644 --- a/src/client/HTTPEngineSender.cpp +++ b/src/client/HTTPEngineSender.cpp @@ -15,15 +15,14 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include +#include "raul/log.hpp" #include "raul/AtomRDF.hpp" #include "redlandmm/Model.hpp" #include "module/World.hpp" #include "HTTPEngineSender.hpp" #include "HTTPClientReceiver.hpp" - using namespace std; using namespace Raul; @@ -229,7 +228,7 @@ HTTPEngineSender::get(const URI& uri) void HTTPEngineSender::request_property(const URI& object_path, const URI& key) { - cerr << "HTTP REQUEST PROPERTY" << endl; + warn << "TODO: HTTP request property" << endl; } diff --git a/src/client/NodeModel.hpp b/src/client/NodeModel.hpp index 57d2f09c..b1dbb616 100644 --- a/src/client/NodeModel.hpp +++ b/src/client/NodeModel.hpp @@ -19,7 +19,6 @@ #define NODEMODEL_H #include -#include #include #include #include diff --git a/src/client/OSCClientReceiver.cpp b/src/client/OSCClientReceiver.cpp index 02585d3a..bb3c098a 100644 --- a/src/client/OSCClientReceiver.cpp +++ b/src/client/OSCClientReceiver.cpp @@ -15,13 +15,15 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "OSCClientReceiver.hpp" -#include "raul/AtomLiblo.hpp" #include #include #include -#include #include +#include "raul/log.hpp" +#include "raul/AtomLiblo.hpp" +#include "OSCClientReceiver.hpp" + +#define LOG(s) s << "[OSCClientReceiver] " using namespace std; using namespace Raul; @@ -66,10 +68,10 @@ OSCClientReceiver::start(bool dump_osc) } if (_st == NULL) { - cerr << "[OSCClientReceiver] Could not start OSC listener. Aborting." << endl; + LOG(error) << "Could not start OSC listener. Aborting." << endl; exit(EXIT_FAILURE); } else { - cout << "[OSCClientReceiver] Started OSC listener on port " << lo_server_thread_get_port(_st) << endl; + LOG(info) << "Started OSC listener on port " << lo_server_thread_get_port(_st) << endl; } // Print all incoming messages @@ -121,7 +123,7 @@ OSCClientReceiver::generic_cb(const char* path, const char* types, lo_arg** argv void OSCClientReceiver::lo_error_cb(int num, const char* msg, const char* path) { - cerr << "Got error from server: " << msg << endl; + LOG(error) << "Got error from server: " << msg << endl; } @@ -132,7 +134,7 @@ OSCClientReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv std::string msg = "Received unknown OSC message: "; msg += path; - cerr << msg << endl; + LOG(error) << msg << endl; return 0; } diff --git a/src/client/OSCEngineSender.cpp b/src/client/OSCEngineSender.cpp index e2553528..0e2b11ab 100644 --- a/src/client/OSCEngineSender.cpp +++ b/src/client/OSCEngineSender.cpp @@ -15,7 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "raul/log.hpp" #include "raul/AtomLiblo.hpp" #include "raul/Path.hpp" #include "OSCEngineSender.hpp" @@ -23,6 +23,8 @@ #include "common/interface/Port.hpp" #include "common/interface/Plugin.hpp" +#define LOG(s) s << "[OSCEngineSender] " + using namespace std; using namespace Raul; @@ -65,11 +67,11 @@ OSCEngineSender::attach(int32_t ping_id, bool block) _address = lo_address_new_from_url(_engine_url.c_str()); if (_address == NULL) { - cerr << "Aborting: Unable to connect to " << _engine_url << endl; + LOG(error) << "Unable to connect to " << _engine_url << endl; exit(EXIT_FAILURE); } - cout << "[OSCEngineSender] Attempting to contact engine at " << _engine_url << " ..." << endl; + LOG(info) << "Attempting to contact engine at " << _engine_url << " ..." << endl; _id = ping_id; this->ping(); diff --git a/src/client/ObjectModel.cpp b/src/client/ObjectModel.cpp index 6c64735d..7949f316 100644 --- a/src/client/ObjectModel.cpp +++ b/src/client/ObjectModel.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "raul/TableImpl.hpp" #include "interface/GraphObject.hpp" #include "ObjectModel.hpp" diff --git a/src/client/ObjectModel.hpp b/src/client/ObjectModel.hpp index 9b0544f6..79ae1fe9 100644 --- a/src/client/ObjectModel.hpp +++ b/src/client/ObjectModel.hpp @@ -19,7 +19,6 @@ #define OBJECTMODEL_H #include -#include #include #include #include diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index 25255f06..376a6a68 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include "raul/log.hpp" #include "PatchModel.hpp" #include "NodeModel.hpp" #include "ConnectionModel.hpp" @@ -155,7 +155,7 @@ PatchModel::remove_connection(const Path& src_port_path, const Path& dst_port_pa } } - cerr << "[PatchModel::remove_connection] WARNING: Failed to find connection " << + warn << "[PatchModel::remove_connection] Failed to find connection " << src_port_path << " -> " << dst_port_path << endl; } diff --git a/src/client/PluginModel.hpp b/src/client/PluginModel.hpp index b9407334..01cc14dc 100644 --- a/src/client/PluginModel.hpp +++ b/src/client/PluginModel.hpp @@ -19,7 +19,6 @@ #define PLUGINMODEL_H #include "ingen-config.h" -#include #include "raul/SharedPtr.hpp" #include "redlandmm/World.hpp" #ifdef HAVE_SLV2 diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index bb10b3a6..f9882be1 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -15,7 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "raul/log.hpp" #include "event.lv2/event-helpers.h" #include "object.lv2/object.h" #include "shared/LV2Features.hpp" @@ -40,8 +40,7 @@ lv2_ui_write(LV2UI_Controller controller, uint32_t format, const void* buffer) { - /* - cerr << "lv2_ui_write (format " << format << "):" << endl; + /*fprintf(stderr, "lv2_ui_write (format %u):\n", format); fprintf(stderr, "RAW:\n"); for (uint32_t i=0; i < buffer_size; ++i) { unsigned char byte = ((unsigned char*)buffer)[i]; @@ -50,8 +49,7 @@ lv2_ui_write(LV2UI_Controller controller, else fprintf(stderr, "%2X ", ((unsigned char*)buffer)[i]); } - fprintf(stderr, "\n"); - */ + fprintf(stderr, "\n");*/ PluginUI* ui = (PluginUI*)controller; @@ -80,7 +78,7 @@ lv2_ui_write(LV2UI_Controller controller, ui->world()->engine->set_port_value(port->path(), Atom("lv2midi:MidiEvent", ev->size, data)); } else { - cerr << "WARNING: Unable to send event type " << ev->type << + warn << "Unable to send event type " << ev->type << " over OSC, ignoring event" << endl; } @@ -94,7 +92,7 @@ lv2_ui_write(LV2UI_Controller controller, ui->world()->engine->set_port_value(port->path(), val); } else { - cerr << "WARNING: Unknown value format " << format + warn << "Unknown value format " << format << ", either plugin " << ui->node()->plugin()->uri() << " is broken" << " or this is an Ingen bug" << endl; } @@ -142,7 +140,7 @@ PluginUI::create(Ingen::Shared::World* world, } if (ui) { - cout << "Found GTK Plugin UI: " << slv2_ui_get_uri(ui) << endl; + info << "Found GTK Plugin UI: " << slv2_ui_get_uri(ui) << endl; ret = SharedPtr(new PluginUI(world, node)); ret->_features = world->lv2_features->lv2_features(node.get()); SLV2UIInstance inst = slv2_ui_instantiate( @@ -151,7 +149,7 @@ PluginUI::create(Ingen::Shared::World* world, if (inst) { ret->set_instance(inst); } else { - cerr << "ERROR: Failed to instantiate Plugin UI" << endl; + error << "Failed to instantiate Plugin UI" << endl; ret = SharedPtr(); } } diff --git a/src/client/PortModel.hpp b/src/client/PortModel.hpp index 34f909d0..dbf82f1a 100644 --- a/src/client/PortModel.hpp +++ b/src/client/PortModel.hpp @@ -19,9 +19,9 @@ #define PORTMODEL_H #include -#include #include #include +#include "raul/log.hpp" #include "raul/SharedPtr.hpp" #include "interface/Port.hpp" #include "ObjectModel.hpp" @@ -87,7 +87,7 @@ private: , _connections(0) { if (_type == Shared::PortType::UNKNOWN) - std::cerr << "[PortModel] Warning: Unknown port type" << std::endl; + Raul::warn << "[PortModel] Unknown port type" << std::endl; } void add_child(SharedPtr c) { throw; } diff --git a/src/client/ThreadedSigClientInterface.cpp b/src/client/ThreadedSigClientInterface.cpp index 8741ecf7..56eeddf6 100644 --- a/src/client/ThreadedSigClientInterface.cpp +++ b/src/client/ThreadedSigClientInterface.cpp @@ -15,13 +15,14 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "raul/log.hpp" #include "common/interface/Patch.hpp" #include "common/interface/Plugin.hpp" #include "common/interface/Port.hpp" #include "ThreadedSigClientInterface.hpp" using namespace std; +using namespace Raul; namespace Ingen { namespace Client { @@ -38,11 +39,11 @@ ThreadedSigClientInterface::push_sig(Closure ev) while (!success) { success = _sigs.push(ev); if (!success) { - cerr << "WARNING: Client event queue full. Waiting..." << endl; + warn << "Client event queue full. Waiting..." << endl; _mutex.lock(); _cond.wait(_mutex); _mutex.unlock(); - cerr << "Queue drained, continuing" << endl; + warn << "Queue drained, continuing" << endl; } } } diff --git a/src/common/interface/Plugin.hpp b/src/common/interface/Plugin.hpp index 12d8b4d0..b5ba3adf 100644 --- a/src/common/interface/Plugin.hpp +++ b/src/common/interface/Plugin.hpp @@ -19,7 +19,6 @@ #define PLUGIN_H #include -#include #include "interface/Resource.hpp" namespace Ingen { diff --git a/src/engine/AudioBuffer.cpp b/src/engine/AudioBuffer.cpp index 693fa503..a1e10b63 100644 --- a/src/engine/AudioBuffer.cpp +++ b/src/engine/AudioBuffer.cpp @@ -15,9 +15,9 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include +#include "raul/log.hpp" #include "raul/SharedPtr.hpp" #include "object.lv2/object.h" #include "ingen-config.h" @@ -27,6 +27,7 @@ #include "LV2URIMap.hpp" using namespace std; +using namespace Raul; /* TODO: Be sure these functions are vectorized by GCC when its vectorizer * stops sucking. Probably a good idea to inline them as well */ @@ -60,8 +61,7 @@ AudioBuffer::AudioBuffer(BufferFactory& factory, Shared::PortType type, size_t s body->elem_count = size / sizeof(Sample); body->elem_type = 0;//map->float_type; } - - /*cout << "Created Audio Buffer" << endl + /*debug << "Created Audio Buffer" << endl << "\tobject @ " << (void*)object() << endl << "\tbody @ " << (void*)object()->body << "\t(offset " << (char*)object()->body - (char*)object() << ")" << endl diff --git a/src/engine/AudioBuffer.hpp b/src/engine/AudioBuffer.hpp index 38e4d293..c7ac5238 100644 --- a/src/engine/AudioBuffer.hpp +++ b/src/engine/AudioBuffer.hpp @@ -18,7 +18,6 @@ #ifndef AUDIOBUFFER_H #define AUDIOBUFFER_H -#include #include #include #include diff --git a/src/engine/BufferFactory.cpp b/src/engine/BufferFactory.cpp index 02104b92..86862ef8 100644 --- a/src/engine/BufferFactory.cpp +++ b/src/engine/BufferFactory.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include "raul/log.hpp" #include "shared/LV2URIMap.hpp" #include "AudioBuffer.hpp" #include "EventBuffer.hpp" @@ -26,6 +26,8 @@ #include "Driver.hpp" #include "ThreadManager.hpp" +using namespace Raul; + namespace Ingen { using namespace Shared; @@ -65,7 +67,7 @@ BufferFactory::get(Shared::PortType type, size_t size, bool force_create) if (ThreadManager::current_thread_id() != THREAD_PROCESS) { return create(type, size); } else { - cerr << "ERROR: Failed to obtain buffer" << endl; + error << "Failed to obtain buffer" << endl; return Ref(); } } @@ -105,7 +107,7 @@ BufferFactory::create(Shared::PortType type, size_t size) size = 32; // FIXME buffer = new ObjectBuffer(*this, std::max(size, sizeof(LV2_Object) + sizeof(void*))); } else { - cout << "ERROR: Failed to create buffer of unknown type" << endl; + error << "Failed to create buffer of unknown type" << endl; return Ref(); } diff --git a/src/engine/ClientBroadcaster.cpp b/src/engine/ClientBroadcaster.cpp index fa19e2f1..fcae666f 100644 --- a/src/engine/ClientBroadcaster.cpp +++ b/src/engine/ClientBroadcaster.cpp @@ -16,8 +16,8 @@ */ #include -#include #include +#include "raul/log.hpp" #include "interface/ClientInterface.hpp" #include "ClientBroadcaster.hpp" #include "PluginImpl.hpp" @@ -26,6 +26,8 @@ #include "ObjectSender.hpp" #include "util.hpp" +#define LOG(s) s << "[ClientBroadcaster] " + using namespace std; using namespace Raul; using Ingen::Shared::ClientInterface; @@ -42,9 +44,9 @@ ClientBroadcaster::register_client(const URI& uri, ClientInterface* client) if (i == _clients.end()) { _clients[uri] = client; - cout << "[ClientBroadcaster] Registered client: " << uri << endl; + LOG(info) << "Registered client: " << uri << endl; } else { - cout << "[ClientBroadcaster] Client already registered: " << uri << endl; + LOG(warn) << "Client already registered: " << uri << endl; } } @@ -59,9 +61,9 @@ ClientBroadcaster::unregister_client(const URI& uri) size_t erased = _clients.erase(uri); if (erased > 0) - cout << "Unregistered client: " << uri << endl; + LOG(info) << "Unregistered client: " << uri << endl; else - cout << "Failed to find client to unregister: " << uri << endl; + LOG(warn) << "Failed to find client to unregister: " << uri << endl; return (erased > 0); } diff --git a/src/engine/CompiledPatch.hpp b/src/engine/CompiledPatch.hpp index 5444085c..ef12bcd6 100644 --- a/src/engine/CompiledPatch.hpp +++ b/src/engine/CompiledPatch.hpp @@ -18,7 +18,6 @@ #ifndef COMPILED_PATCH_HPP #define COMPILED_PATCH_HPP -#include #include #include "raul/List.hpp" #include "raul/Deletable.hpp" diff --git a/src/engine/ConnectionImpl.cpp b/src/engine/ConnectionImpl.cpp index 47fdce36..a266a5ef 100644 --- a/src/engine/ConnectionImpl.cpp +++ b/src/engine/ConnectionImpl.cpp @@ -16,6 +16,7 @@ */ #include +#include "raul/log.hpp" #include "raul/Maid.hpp" #include "raul/IntrusivePtr.hpp" #include "AudioBuffer.hpp" @@ -65,7 +66,7 @@ ConnectionImpl::ConnectionImpl(BufferFactory& bufs, PortImpl* src_port, PortImpl void ConnectionImpl::dump() const { - cerr << _src_port->path() << " -> " << _dst_port->path() + debug << _src_port->path() << " -> " << _dst_port->path() << (must_mix() ? " (MIX) " : " (DIRECT) ") << (must_queue() ? " (QUEUE)" : " (NOQUEUE)") << endl; } @@ -106,13 +107,13 @@ ConnectionImpl::process(Context& context) if (must_queue()) { IntrusivePtr src_buf = PtrCast(_src_port->buffer(0)); if (!src_buf) { - cerr << "ERROR: Queued connection but source is not an EventBuffer" << endl; + error << "Queued connection but source is not an EventBuffer" << endl; return; } IntrusivePtr local_buf = PtrCast(_local_buffer); if (!local_buf) { - cerr << "ERROR: Queued connection but local buffer is not an ObjectBuffer" << endl; + error << "Queued connection but local buffer is not an ObjectBuffer" << endl; return; } @@ -141,18 +142,18 @@ ConnectionImpl::queue(Context& context) IntrusivePtr src_buf = PtrCast(_src_port->buffer(0)); if (!src_buf) { - cerr << "ERROR: Queued connection but source is not an EventBuffer" << endl; + error << "Queued connection but source is not an EventBuffer" << endl; return; } while (src_buf->is_valid()) { LV2_Event* ev = src_buf->get_event(); LV2_Object* obj = LV2_OBJECT_FROM_EVENT(ev); - /*cout << _src_port->path() << " -> " << _dst_port->path() + /*debug << _src_port->path() << " -> " << _dst_port->path() << " QUEUE OBJECT TYPE " << obj->type << ":"; for (size_t i = 0; i < obj->size; ++i) - cout << " " << std::hex << (int)obj->body[i]; - cout << endl;*/ + debug << " " << std::hex << (int)obj->body[i]; + debug << endl;*/ _queue->write(sizeof(LV2_Object) + obj->size, obj); src_buf->increment(); diff --git a/src/engine/ConnectionImpl.hpp b/src/engine/ConnectionImpl.hpp index 63d2ecc4..00770047 100644 --- a/src/engine/ConnectionImpl.hpp +++ b/src/engine/ConnectionImpl.hpp @@ -18,7 +18,6 @@ #ifndef CONNECTIONIMPL_H #define CONNECTIONIMPL_H -#include #include #include #include "raul/Deletable.hpp" diff --git a/src/engine/DuplexPort.cpp b/src/engine/DuplexPort.cpp index 997c4e29..775e82b3 100644 --- a/src/engine/DuplexPort.cpp +++ b/src/engine/DuplexPort.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include "util.hpp" diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 9a8bd182..bee2cec7 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -17,8 +17,8 @@ #include #include -#include #include +#include "raul/log.hpp" #include "raul/Deletable.hpp" #include "raul/Maid.hpp" #include "raul/SharedPtr.hpp" @@ -48,6 +48,7 @@ #include "tuning.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -111,7 +112,7 @@ Engine::main() nanosleep(&main_rate, NULL); main_iteration(); } - cout << "[Main] Done main loop." << endl; + info << "Finished main loop" << endl; deactivate(); diff --git a/src/engine/EngineStore.cpp b/src/engine/EngineStore.cpp index 1d5e774b..1d17bb48 100644 --- a/src/engine/EngineStore.cpp +++ b/src/engine/EngineStore.cpp @@ -17,6 +17,7 @@ #include #include +#include "raul/log.hpp" #include "raul/List.hpp" #include "raul/PathTable.hpp" #include "raul/TableImpl.hpp" @@ -26,6 +27,8 @@ #include "PortImpl.hpp" #include "ThreadManager.hpp" +#define LOG(s) s << "[EngineStore] " + using namespace std; using namespace Raul; @@ -88,14 +91,7 @@ void EngineStore::add(const Objects& table) { assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); - - //cerr << "[EngineStore] Adding " << o[0].second->path() << endl; cram(table); - - /*cerr << "[EngineStore] Adding Table:" << endl; - for (const_iterator i = table.begin(); i != table.end(); ++i) { - cerr << i->first << " = " << i->second->path() << endl; - }*/ } @@ -123,17 +119,12 @@ EngineStore::remove(iterator object) if (object != end()) { iterator descendants_end = find_descendants_end(object); - //cout << "[EngineStore] Removing " << object->first << " {" << endl; SharedPtr removed = yank(object, descendants_end); - /*for (iterator i = removed->begin(); i != removed->end(); ++i) { - cout << "\t" << i->first << endl; - } - cout << "}" << endl;*/ return removed; } else { - cerr << "[EngineStore] WARNING: Removing " << object->first << " failed." << endl; + LOG(warn) << "Removing " << object->first << " failed." << endl; return SharedPtr(); } } @@ -167,7 +158,7 @@ EngineStore::remove_children(iterator object) return yank(first_child, descendants_end); } } else { - cerr << "[EngineStore] WARNING: Removing children of " << object->first << " failed." << endl; + LOG(warn) << "Removing children of " << object->first << " failed." << endl; return SharedPtr(); } diff --git a/src/engine/EventBuffer.cpp b/src/engine/EventBuffer.cpp index 4f7f6b5f..6b27ef4e 100644 --- a/src/engine/EventBuffer.cpp +++ b/src/engine/EventBuffer.cpp @@ -17,7 +17,7 @@ #define __STDC_LIMIT_MACROS 1 #include -#include +#include "raul/log.hpp" #include "event.lv2/event.h" #include "event.lv2/event-helpers.h" #include "ingen-config.h" @@ -25,6 +25,7 @@ #include "ProcessContext.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -39,7 +40,7 @@ EventBuffer::EventBuffer(BufferFactory& factory, size_t capacity) , _latest_subframes(0) { if (capacity > UINT32_MAX) { - cerr << "Event buffer size " << capacity << " too large, aborting." << endl; + error << "Event buffer size " << capacity << " too large, aborting." << endl; throw std::bad_alloc(); } @@ -51,7 +52,7 @@ EventBuffer::EventBuffer(BufferFactory& factory, size_t capacity) #endif if (ret != 0) { - cerr << "Failed to allocate event buffer. Aborting." << endl; + error << "Failed to allocate event buffer. Aborting." << endl; exit(EXIT_FAILURE); } @@ -207,11 +208,11 @@ EventBuffer::append(uint32_t frames, } #endif - /*cout << "Appending event type " << type << ", size " << size + /*debug << "Appending event type " << type << ", size " << size << " @ " << frames << "." << subframes << endl;*/ if (!lv2_event_write(&_iter, frames, subframes, type, size, data)) { - cerr << "ERROR: Failed to write event." << endl; + error << "Failed to write event." << endl; return false; } else { _latest_frames = frames; diff --git a/src/engine/EventSink.cpp b/src/engine/EventSink.cpp index 2bbdc595..0bbe3d83 100644 --- a/src/engine/EventSink.cpp +++ b/src/engine/EventSink.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "EventSink.hpp" #include "PortImpl.hpp" diff --git a/src/engine/HTTPClientSender.cpp b/src/engine/HTTPClientSender.cpp index b6645f7d..891a7184 100644 --- a/src/engine/HTTPClientSender.cpp +++ b/src/engine/HTTPClientSender.cpp @@ -17,6 +17,7 @@ #include #include +#include "raul/log.hpp" #include "raul/Atom.hpp" #include "raul/AtomRDF.hpp" #include "serialisation/Serialiser.hpp" @@ -40,7 +41,7 @@ HTTPClientSender::response_ok(int32_t id) void HTTPClientSender::response_error(int32_t id, const std::string& msg) { - cout << "HTTP ERROR " << id << ": " << msg << endl; + warn << "HTTP Error " << id << " (" << msg << ")" << endl; } diff --git a/src/engine/HTTPClientSender.hpp b/src/engine/HTTPClientSender.hpp index 30031252..81af61db 100644 --- a/src/engine/HTTPClientSender.hpp +++ b/src/engine/HTTPClientSender.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include "raul/Thread.hpp" #include "interface/ClientInterface.hpp" diff --git a/src/engine/HTTPEngineReceiver.cpp b/src/engine/HTTPEngineReceiver.cpp index ecb8d018..8cc39ddb 100644 --- a/src/engine/HTTPEngineReceiver.cpp +++ b/src/engine/HTTPEngineReceiver.cpp @@ -15,11 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include #include +#include "raul/log.hpp" #include "raul/Atom.hpp" #include "raul/SharedPtr.hpp" #include "interface/ClientInterface.hpp" @@ -51,7 +51,7 @@ HTTPEngineReceiver::HTTPEngineReceiver(Engine& engine, uint16_t port) soup_server_add_handler(_server, NULL, message_callback, this, NULL); - cout << "Started HTTP server on port " << soup_server_get_port(_server) << endl; + info << "Started HTTP server on port " << soup_server_get_port(_server) << endl; Thread::set_name("HTTP Receiver"); if (!engine.world()->parser || !engine.world()->serialiser) @@ -157,7 +157,7 @@ HTTPEngineReceiver::message_callback(SoupServer* server, SoupMessage* msg, const } if (!Path::is_valid(path)) { - cerr << "HTTP BAD PATH: " << path << endl; + error << "Bad HTTP path: " << path << endl; soup_message_set_status (msg, SOUP_STATUS_BAD_REQUEST); const string& err = (boost::format("Bad path: %1%") % path).str(); soup_message_set_response(msg, "text/plain", SOUP_MEMORY_COPY, diff --git a/src/engine/InputPort.cpp b/src/engine/InputPort.cpp index 4a1a8136..6566ab2f 100644 --- a/src/engine/InputPort.cpp +++ b/src/engine/InputPort.cpp @@ -16,7 +16,6 @@ */ #include "InputPort.hpp" -#include #include #include #include "interface/Patch.hpp" @@ -163,7 +162,7 @@ InputPort::remove_connection(const OutputPort* src_port) connection = _connections.erase(i); if ( ! connection) { - cerr << "ERROR: [InputPort::remove_connection] Connection not found!" << endl; + error << "[InputPort::remove_connection] Connection not found!" << endl; return NULL; } diff --git a/src/engine/InternalPlugin.hpp b/src/engine/InternalPlugin.hpp index b7797b49..70f1ba27 100644 --- a/src/engine/InternalPlugin.hpp +++ b/src/engine/InternalPlugin.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include "PluginImpl.hpp" #define NS_INTERNALS "http://drobilla.net/ns/ingen-internals#" diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 9102cbe5..98523f43 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -15,9 +15,9 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include +#include "raul/log.hpp" #include "raul/List.hpp" #include "shared/LV2Features.hpp" #include "shared/LV2URIMap.hpp" @@ -40,6 +40,8 @@ #include "tuning.hpp" #include "util.hpp" +#define LOG(s) s << "[JackDriver] " + using namespace std; using namespace Raul; @@ -83,7 +85,7 @@ JackPort::create() 0); if (_jack_port == NULL) { - cerr << "[JackPort] ERROR: Failed to register port " << _patch_port->path() << endl; + error << "[JackPort] Failed to register port " << _patch_port->path() << endl; throw JackDriver::PortRegistrationFailedException(); } } @@ -94,7 +96,7 @@ JackPort::destroy() { assert(_jack_port); if (jack_port_unregister(_driver->jack_client(), _jack_port)) - cerr << "[JackMidiPort] ERROR: Unable to unregister port" << endl; + error << "[JackPort] Unable to unregister port" << endl; _jack_port = NULL; } @@ -134,7 +136,7 @@ JackPort::pre_process(ProcessContext& context) jack_midi_event_get(&ev, jack_buf, i); if (!patch_buf->append(ev.time, 0, _driver->_midi_event_type, ev.size, ev.buffer)) - cerr << "WARNING: Failed to write MIDI to port buffer, event(s) lost!" << endl; + LOG(warn) << "Failed to write MIDI to port buffer, event(s) lost!" << endl; } } } @@ -226,8 +228,7 @@ JackDriver::attach(const std::string& server_name, _client = jack_client_open(client_name.c_str(), JackServerName, NULL, server_name.c_str()); if (_client) - cerr << "[JackDriver] Connected to JACK server '" << - server_name << "'" << endl; + LOG(info) << "Connected to JACK server '" << server_name << "'" << endl; } // Either server name not specified, or supplied server name does not exist @@ -236,12 +237,12 @@ JackDriver::attach(const std::string& server_name, _client = jack_client_open(client_name.c_str(), JackNullOption, NULL); if (_client) - cerr << "[JackDriver] Connected to default JACK server." << endl; + LOG(info) << "Connected to default JACK server." << endl; } // Still failed if (!_client) { - cerr << "[JackDriver] Unable to connect to Jack. Exiting." << endl; + LOG(error) << "Unable to connect to Jack. Exiting." << endl; return false; } } else { @@ -270,7 +271,7 @@ void JackDriver::activate() { if (_is_activated) { - cerr << "[JackDriver] Jack driver already activated." << endl; + LOG(warn) << "Jack driver already activated." << endl; return; } @@ -283,10 +284,10 @@ JackDriver::activate() _is_activated = true; if (jack_activate(_client)) { - cerr << "[JackDriver] Could not activate Jack client, aborting." << endl; + LOG(error) << "Could not activate Jack client, aborting." << endl; exit(EXIT_FAILURE); } else { - cout << "[JackDriver] Activated Jack client." << endl; + LOG(info) << "Activated Jack client." << endl; } } @@ -310,7 +311,7 @@ JackDriver::deactivate() } _jack_thread->stop(); - cout << "[JackDriver] Deactivated Jack client." << endl; + LOG(info) << "Deactivated Jack client." << endl; } } @@ -348,7 +349,7 @@ JackDriver::remove_port(const Path& path) if ((*i)->patch_port()->path() == path) return (Raul::List::Node*)(_ports.erase(i)); - cerr << "[JackDriver::remove_port] WARNING: Unable to find port " << path << endl; + LOG(warn) << "Unable to find port " << path << endl; return NULL; } @@ -466,7 +467,7 @@ JackDriver::_thread_init_cb() void JackDriver::_shutdown_cb() { - cout << "[JackDriver] Jack shutdown. Exiting." << endl; + LOG(info) << "Jack shutdown. Exiting." << endl; _is_activated = false; delete _jack_thread; _jack_thread = NULL; @@ -478,7 +479,7 @@ int JackDriver::_sample_rate_cb(jack_nframes_t nframes) { if (_is_activated) { - cerr << "[JackDriver] On-the-fly sample rate changing not supported (yet). Aborting." << endl; + LOG(error) << "On-the-fly sample rate changing not supported (yet). Aborting." << endl; exit(EXIT_FAILURE); } else { _sample_rate = nframes; diff --git a/src/engine/LADSPANode.cpp b/src/engine/LADSPANode.cpp index 3d405b5c..d3db5a04 100644 --- a/src/engine/LADSPANode.cpp +++ b/src/engine/LADSPANode.cpp @@ -15,13 +15,13 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include #include -#include "raul/Maid.hpp" #include +#include "raul/log.hpp" +#include "raul/Maid.hpp" #include "LADSPANode.hpp" #include "AudioBuffer.hpp" #include "InputPort.hpp" @@ -75,7 +75,7 @@ LADSPANode::prepare_poly(BufferFactory& bufs, uint32_t poly) for (uint32_t i = _polyphony; i < _prepared_instances->size(); ++i) { _prepared_instances->at(i) = _descriptor->instantiate(_descriptor, _srate); if (_prepared_instances->at(i) == NULL) { - cerr << "Failed to instantiate plugin!" << endl; + error << "Failed to instantiate plugin" << endl; return false; } @@ -154,7 +154,7 @@ LADSPANode::instantiate(BufferFactory& bufs) for (uint32_t i=0; i < _polyphony; ++i) { (*_instances)[i] = _descriptor->instantiate(_descriptor, _srate); if ((*_instances)[i] == NULL) { - cerr << "Failed to instantiate plugin!" << endl; + error << "Failed to instantiate plugin" << endl; return false; } } @@ -222,13 +222,13 @@ LADSPANode::instantiate(BufferFactory& bufs) // Work around broke-ass crackhead plugins if (default_val && default_val.get() < min.get()) { - cerr << "WARNING: Broken LADSPA " << _descriptor->UniqueID + warn << "Broken LADSPA " << _descriptor->UniqueID << ": Port default < minimum. Minimum adjusted." << endl; min = default_val; } if (default_val && default_val.get() > max.get()) { - cerr << "WARNING: Broken LADSPA " << _descriptor->UniqueID + warn << "Broken LADSPA " << _descriptor->UniqueID << ": Maximum adjusted." << endl; max = default_val; } diff --git a/src/engine/LADSPAPlugin.cpp b/src/engine/LADSPAPlugin.cpp index 30b0eae2..7bf4ef4a 100644 --- a/src/engine/LADSPAPlugin.cpp +++ b/src/engine/LADSPAPlugin.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include "LADSPAPlugin.hpp" #include "LADSPANode.hpp" @@ -83,7 +82,7 @@ LADSPAPlugin::instantiate(BufferFactory& bufs, assert(*_module); if (!_module->get_symbol("ladspa_descriptor", df.dp)) { - cerr << "Looks like this isn't a LADSPA plugin." << endl; + warn << _library_path << " is not a LADSPA plugin library" << endl; return NULL; } @@ -104,7 +103,7 @@ LADSPAPlugin::instantiate(BufferFactory& bufs, } } else { - cerr << "Could not find plugin \"" << _id << "\" in " << _library_path << endl; + error << "Could not find plugin \"" << _id << "\" in " << _library_path << endl; } return n; diff --git a/src/engine/LADSPAPlugin.hpp b/src/engine/LADSPAPlugin.hpp index 332bdd8e..5c5e4faa 100644 --- a/src/engine/LADSPAPlugin.hpp +++ b/src/engine/LADSPAPlugin.hpp @@ -23,7 +23,6 @@ #include #include #include -#include #include "raul/Path.hpp" #include "raul/Atom.hpp" #include "PluginImpl.hpp" diff --git a/src/engine/LV2Info.cpp b/src/engine/LV2Info.cpp index 93f4b386..774828dd 100644 --- a/src/engine/LV2Info.cpp +++ b/src/engine/LV2Info.cpp @@ -17,7 +17,6 @@ #define __STDC_LIMIT_MACROS 1 #include -#include #include #include "object.lv2/object.h" #include "LV2Info.hpp" diff --git a/src/engine/LV2Node.cpp b/src/engine/LV2Node.cpp index 6f39782b..3356b4aa 100644 --- a/src/engine/LV2Node.cpp +++ b/src/engine/LV2Node.cpp @@ -15,11 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include #include +#include "raul/log.hpp" #include "raul/Maid.hpp" #include "AudioBuffer.hpp" #include "InputPort.hpp" @@ -86,7 +86,7 @@ LV2Node::prepare_poly(BufferFactory& bufs, uint32_t poly) _lv2_plugin->slv2_plugin(), _srate, _features->array()); if (_prepared_instances->at(i) == NULL) { - cerr << "Failed to instantiate plugin!" << endl; + error << "Failed to instantiate plugin" << endl; return false; } @@ -159,7 +159,7 @@ LV2Node::instantiate(BufferFactory& bufs) for (uint32_t i=0; i < _polyphony; ++i) { (*_instances)[i] = slv2_plugin_instantiate(plug, _srate, _features->array()); if ((*_instances)[i] == NULL) { - cerr << "Failed to instantiate plugin!" << endl; + error << "Failed to instantiate plugin" << endl; return false; } @@ -170,7 +170,7 @@ LV2Node::instantiate(BufferFactory& bufs) (*_instances)[i], LV2_CONTEXT_MESSAGE); if (i == 0 && ctx_ext) { - cerr << _lv2_plugin->uri() << " has message context" << endl; + Raul::info << _lv2_plugin->uri() << " has message context" << endl; assert(!_message_funcs); _message_funcs = (LV2MessageContext*)ctx_ext; } @@ -284,14 +284,14 @@ LV2Node::instantiate(BufferFactory& bufs) SLV2Value c = slv2_values_get_at(contexts, i); const char* context = slv2_value_as_string(c); if (!strcmp(LV2_CONTEXT_MESSAGE, context)) { - cerr << _lv2_plugin->uri() << " port " << i << " has message context" << endl; + Raul::info << _lv2_plugin->uri() << " port " << i << " has message context" << endl; if (!_message_funcs) { - cerr << _lv2_plugin->uri() - << " has a message port, but no context extension data." << endl; + warn << _lv2_plugin->uri() + << " has a message port, but no context extension data." << endl; } port->set_context(Context::MESSAGE); } else { - cout << _lv2_plugin->uri() << " port " << i << " has unknown context " + warn << _lv2_plugin->uri() << " port " << i << " has unknown context " << slv2_value_as_string(slv2_values_get_at(contexts, i)) << endl; } diff --git a/src/engine/LV2Plugin.cpp b/src/engine/LV2Plugin.cpp index b8b159e3..eafa3be2 100644 --- a/src/engine/LV2Plugin.cpp +++ b/src/engine/LV2Plugin.cpp @@ -99,7 +99,7 @@ LV2Plugin::library_path() const if (v) { _library_path = slv2_uri_to_path(slv2_value_as_uri(v)); } else { - cerr << "WARNING: Plugin " << uri() << " has no library path" << endl; + warn << uri() << " has no library path" << endl; return empty_string; } } diff --git a/src/engine/LV2Plugin.hpp b/src/engine/LV2Plugin.hpp index fdb90a22..2a6f1996 100644 --- a/src/engine/LV2Plugin.hpp +++ b/src/engine/LV2Plugin.hpp @@ -29,7 +29,6 @@ #include #include #include -#include #include "slv2/slv2.h" #include "raul/SharedPtr.hpp" #include "PluginImpl.hpp" diff --git a/src/engine/LV2ResizeFeature.hpp b/src/engine/LV2ResizeFeature.hpp index 90452552..723d9447 100644 --- a/src/engine/LV2ResizeFeature.hpp +++ b/src/engine/LV2ResizeFeature.hpp @@ -18,12 +18,13 @@ #ifndef LV2_RESIZE_FEATURE_H #define LV2_RESIZE_FEATURE_H -#include +#include "raul/log.hpp" #include "shared/LV2Features.hpp" #include "NodeImpl.hpp" #include "PortImpl.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -34,7 +35,7 @@ struct ResizeFeature : public Shared::LV2Features::Feature { NodeImpl* node = (NodeImpl*)data; PortImpl* port = node->port_impl(index); if (port->context() == Context::MESSAGE) { - cout << "Resizing " << port->path() << " to " << size << " bytes" << endl; + info << "Resizing " << port->path() << " to " << size << " bytes" << endl; port->buffer(0)->resize(size); port->connect_buffers(); return true; diff --git a/src/engine/MessageContext.cpp b/src/engine/MessageContext.cpp index 1ffc4bfc..71700bbf 100644 --- a/src/engine/MessageContext.cpp +++ b/src/engine/MessageContext.cpp @@ -15,7 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "raul/log.hpp" #include "raul/Atom.hpp" #include "ConnectionImpl.hpp" #include "Engine.hpp" @@ -28,6 +28,7 @@ #include "ThreadManager.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -46,9 +47,9 @@ MessageContext::run(PortImpl* port, FrameTime time) _requests.write(sizeof(Request), &r); // signal() will be called at the end of this process cycle } else if (ThreadManager::current_thread_id() == THREAD_MESSAGE) { - cout << "Message context recursion at " << port->path() << endl; + warn << "Message context recursion at " << port->path() << endl; } else { - cout << "[MessageContext] ERROR: Run requested from unknown thread" << endl; + error << "Run requested from unknown thread" << endl; } } diff --git a/src/engine/NodeBase.cpp b/src/engine/NodeBase.cpp index ab8b7054..8fe266e6 100644 --- a/src/engine/NodeBase.cpp +++ b/src/engine/NodeBase.cpp @@ -17,7 +17,6 @@ #include "NodeBase.hpp" #include -#include #include #include "raul/List.hpp" #include "raul/Array.hpp" @@ -154,7 +153,6 @@ NodeBase::set_buffer_size(BufferFactory& bufs, size_t size) void NodeBase::reset_input_ready() { - //cout << path() << " RESET" << endl; _n_inputs_ready = 0; _process_lock = 0; _input_ready.reset(0); @@ -181,14 +179,8 @@ NodeBase::wait_for_input(size_t num_providers) assert(ThreadManager::current_thread_id() == THREAD_PROCESS); assert(_process_lock.get() == 1); - while ((unsigned)_n_inputs_ready.get() < num_providers) { - //cout << path() << " WAITING " << _n_inputs_ready.get() << endl; + while ((unsigned)_n_inputs_ready.get() < num_providers) _input_ready.wait(); - //cout << path() << " CAUGHT SIGNAL" << endl; - //++_n_inputs_ready; - } - - //cout << path() << " READY" << endl; } @@ -196,7 +188,6 @@ void NodeBase::signal_input_ready() { assert(ThreadManager::current_thread_id() == THREAD_PROCESS); - //cout << path() << " SIGNAL" << endl; ++_n_inputs_ready; _input_ready.post(); } diff --git a/src/engine/NodeFactory.cpp b/src/engine/NodeFactory.cpp index c6dca64b..224c2b68 100644 --- a/src/engine/NodeFactory.cpp +++ b/src/engine/NodeFactory.cpp @@ -15,14 +15,15 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "ingen-config.h" #include #include #include #include #include #include "redlandmm/World.hpp" +#include "raul/log.hpp" #include "raul/Atom.hpp" +#include "ingen-config.h" #include "module/World.hpp" #include "internals/Note.hpp" #include "internals/Trigger.hpp" @@ -43,6 +44,7 @@ #endif using namespace std; +using namespace Raul; namespace Ingen { @@ -96,7 +98,7 @@ NodeFactory::plugin(const string& type, const string& lib, const string& label) } #endif - cerr << "ERROR: Failed to find " << type << " plugin " << lib << " / " << label << endl; + error << "Failed to find " << type << " plugin " << lib << " / " << label << endl; return NULL; } @@ -129,8 +131,6 @@ NodeFactory::load_plugins() } _world->rdf_world->mutex().unlock(); - - //cerr << "[NodeFactory] # Plugins: " << _plugins.size() << endl; } @@ -168,8 +168,6 @@ NodeFactory::load_lv2_plugins() { SLV2Plugins plugins = slv2_world_get_all_plugins(_world->slv2_world); - //cerr << "[NodeFactory] Found " << slv2_plugins_size(plugins) << " LV2 plugins:" << endl; - for (unsigned i=0; i < slv2_plugins_size(plugins); ++i) { SLV2Plugin lv2_plug = slv2_plugins_get_at(plugins, i); @@ -200,9 +198,9 @@ NodeFactory::load_ladspa_plugins() char* env_ladspa_path = getenv("LADSPA_PATH"); string ladspa_path; if (!env_ladspa_path) { - cerr << "[NodeFactory] LADSPA_PATH is empty. Assuming /usr/lib/ladspa:/usr/local/lib/ladspa:~/.ladspa" << endl; + info << "Using default LADSPA_PATH=/usr/lib/ladspa:/usr/local/lib/ladspa:~/.ladspa" << endl; ladspa_path = string("/usr/lib/ladspa:/usr/local/lib/ladspa:").append( - getenv("HOME")).append("/.ladspa"); + getenv("HOME")).append("/.ladspa"); } else { ladspa_path = env_ladspa_path; } @@ -216,10 +214,8 @@ NodeFactory::load_ladspa_plugins() ladspa_path = ""; DIR* pdir = opendir(dir.c_str()); - if (pdir == NULL) { - //cerr << "[NodeFactory] Unreadable directory in LADSPA_PATH: " << dir.c_str() << endl; + if (pdir == NULL) continue; - } struct dirent* pfile; while ((pfile = readdir(pdir))) { @@ -238,10 +234,8 @@ NodeFactory::load_ladspa_plugins() const string lib_path = dir +"/"+ pfile->d_name; // Ignore stupid libtool files. Kludge alert. - if (lib_path.substr(lib_path.length()-3) == ".la") { - //cerr << "WARNING: Skipping stupid libtool file " << pfile->d_name << endl; + if (lib_path.substr(lib_path.length()-3) == ".la") continue; - } Glib::Module* plugin_library = new Glib::Module(lib_path, Glib::MODULE_BIND_LOCAL); if (!plugin_library || !(*plugin_library)) @@ -249,9 +243,7 @@ NodeFactory::load_ladspa_plugins() bool found = plugin_library->get_symbol("ladspa_descriptor", df.dp); if (!found || !df.dp) { - cerr << "WARNING: Non-LADSPA library found in LADSPA path: " << - lib_path << endl; - // Not a LADSPA plugin library + warn << "Non-LADSPA library " << lib_path << " found in LADSPA path" << endl; delete plugin_library; continue; } @@ -272,7 +264,7 @@ NodeFactory::load_ladspa_plugins() _plugins.insert(make_pair(uri, plugin)); } else { - cerr << "Warning: Duplicate " << uri + warn << "Duplicate " << uri << " - Using " << i->second->library_path() << " over " << lib_path << endl; } diff --git a/src/engine/OSCClientSender.cpp b/src/engine/OSCClientSender.cpp index 87382727..13147a42 100644 --- a/src/engine/OSCClientSender.cpp +++ b/src/engine/OSCClientSender.cpp @@ -16,8 +16,8 @@ */ #include -#include #include +#include "raul/log.hpp" #include "raul/AtomLiblo.hpp" #include "interface/ClientInterface.hpp" #include "EngineStore.hpp" @@ -54,7 +54,7 @@ OSCClientSender::response_ok(int32_t id) return; if (lo_send(_address, "/ingen/ok", "i", id) < 0) { - cerr << "Unable to send ok " << id << "! (" + Raul::error << "Unable to send OK " << id << "! (" << lo_address_errstr(_address) << ")" << endl; } } @@ -74,7 +74,7 @@ OSCClientSender::response_error(int32_t id, const std::string& msg) return; if (lo_send(_address, "/ingen/error", "is", id, msg.c_str()) < 0) { - cerr << "Unable to send error " << id << "! (" + Raul::error << "Unable to send error " << id << "! (" << lo_address_errstr(_address) << ")" << endl; } } diff --git a/src/engine/OSCClientSender.hpp b/src/engine/OSCClientSender.hpp index 833ad25e..34d88fc4 100644 --- a/src/engine/OSCClientSender.hpp +++ b/src/engine/OSCClientSender.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #include "interface/ClientInterface.hpp" diff --git a/src/engine/OSCEngineReceiver.cpp b/src/engine/OSCEngineReceiver.cpp index 5afddfe9..e9348d13 100644 --- a/src/engine/OSCEngineReceiver.cpp +++ b/src/engine/OSCEngineReceiver.cpp @@ -17,11 +17,11 @@ //#define ENABLE_AVAHI 1 -#include #include #include #include #include "ingen-config.h" +#include "raul/log.hpp" #include "raul/AtomLiblo.hpp" #include "raul/SharedPtr.hpp" #include "interface/ClientInterface.hpp" @@ -32,6 +32,8 @@ #include "QueuedEventSource.hpp" #include "ThreadManager.hpp" +#define LOG(s) s << "[OSCEngineReceiver] " + using namespace std; using namespace Raul; @@ -66,11 +68,11 @@ OSCEngineReceiver::OSCEngineReceiver(Engine& engine, size_t queue_size, uint16_t #endif if (_server == NULL) { - cerr << "[OSC] Could not start OSC server. Aborting." << endl; + LOG(error) << "Could not start OSC server. Aborting." << endl; exit(EXIT_FAILURE); } else { char* lo_url = lo_server_get_url(_server); - cout << "[OSC] Started OSC server at " << lo_url << endl; + LOG(info) << "Started OSC server at " << lo_url << endl; free(lo_url); } @@ -163,12 +165,6 @@ OSCEngineReceiver::ReceiveThread::_run() * they all get executed in the same cycle */ while (true) { - assert(_receiver._server); - /*if ( ! _server) { - cout << "[OSCEngineReceiver] Server is NULL, exiting" << endl; - break; - }*/ - // Wait on a message and enqueue it lo_server_recv(_receiver._server); @@ -234,7 +230,7 @@ OSCEngineReceiver::set_response_address_cb(const char* path, const char* types, void OSCEngineReceiver::error_cb(int num, const char* msg, const char* path) { - cerr << "liblo server error " << num << " in path \"" << "\" - " << msg << endl; + error << "liblo server error " << num << " in path \"" << "\" - " << msg << endl; } @@ -249,7 +245,7 @@ OSCEngineReceiver::_ping_cb(const char* path, const char* types, lo_arg** argv, { const lo_address addr = lo_message_get_source(msg); if (lo_send(addr, "/ingen/ok", "i", argv[0]->i) < 0) - cerr << "WARNING: Unable to send response: " << lo_address_errstr(addr) << endl; + warn << "Unable to send response (" << lo_address_errstr(addr) << ")" << endl; return 0; } @@ -570,7 +566,7 @@ OSCEngineReceiver::_note_on_cb(const char* path, const char* types, lo_arg** arg const uint8_t note_num = argv[2]->i; const uint8_t velocity = argv[3]->i; */ - cerr << "FIXME: OSC note on\n"; + warn << "TODO: OSC note on" << endl; //note_on(node_path, note_num, velocity); return 0; } @@ -591,7 +587,7 @@ OSCEngineReceiver::_note_off_cb(const char* path, const char* types, lo_arg** ar const char* patch_path = &argv[1]->s; const uint8_t note_num = argv[2]->i; */ - cerr << "FIXME: OSC note off\n"; + warn << "TODO: OSC note off" << endl; //note_off(patch_path, note_num); return 0; } @@ -611,7 +607,7 @@ OSCEngineReceiver::_all_notes_off_cb(const char* path, const char* types, lo_arg const char* patch_path = &argv[1]->s; */ - cerr << "FIXME: OSC all notes off\n"; + warn << "TODO: OSC all notes off" << endl; //all_notes_off(patch_path); return 0; } @@ -734,7 +730,7 @@ OSCEngineReceiver::unknown_cb(const char* path, const char* types, lo_arg** argv const lo_address addr = lo_message_get_source(msg); char* const url = lo_address_get_url(addr); - cerr << "Unknown command " << path << " (" << types << "), sending error.\n"; + warn << "Unknown OSC command " << path << " (" << types << ")" << endl; string error_msg = "Unknown command: "; error_msg.append(path).append(" ").append(types); diff --git a/src/engine/ObjectBuffer.cpp b/src/engine/ObjectBuffer.cpp index 9611f124..a391bb99 100644 --- a/src/engine/ObjectBuffer.cpp +++ b/src/engine/ObjectBuffer.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include "raul/log.hpp" #include "uri-map.lv2/uri-map.h" #include "ingen-config.h" #include "shared/LV2Features.hpp" @@ -28,6 +28,7 @@ #include "Engine.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -40,7 +41,6 @@ using namespace Shared; ObjectBuffer::ObjectBuffer(BufferFactory& factory, size_t capacity) : Buffer(factory, PortType(PortType::VALUE), capacity) { - //cerr << "Creating Object Buffer capacity = " << capacity << endl; assert(capacity >= sizeof(LV2_Object)); #ifdef HAVE_POSIX_MEMALIGN @@ -51,7 +51,7 @@ ObjectBuffer::ObjectBuffer(BufferFactory& factory, size_t capacity) #endif if (ret != 0) { - cerr << "Failed to allocate buffer. Aborting." << endl; + error << "Failed to allocate object buffer. Aborting." << endl; exit(EXIT_FAILURE); } diff --git a/src/engine/ObjectSender.cpp b/src/engine/ObjectSender.cpp index c25bf9c4..65ad4f8b 100644 --- a/src/engine/ObjectSender.cpp +++ b/src/engine/ObjectSender.cpp @@ -102,7 +102,7 @@ ObjectSender::send_node(ClientInterface* client, const NodeImpl* node, bool recu } if (plugin->uri().length() == 0) { - cerr << "Node " << node->path() << " plugin has no URI! Not sending." << endl; + error << "Node " << node->path() << "'s plugin has no URI! Not sending." << endl; return; } diff --git a/src/engine/OutputPort.cpp b/src/engine/OutputPort.cpp index 4524805f..56e4bfdd 100644 --- a/src/engine/OutputPort.cpp +++ b/src/engine/OutputPort.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "interface/Patch.hpp" #include "Buffer.hpp" #include "NodeImpl.hpp" @@ -62,8 +61,6 @@ OutputPort::post_process(Context& context) for (uint32_t v = 0; v < _poly; ++v) buffer(v)->prepare_read(context); - //cerr << path() << " output post: buffer: " << buffer(0) << endl; - if (_broadcast) broadcast_value(context, false); } diff --git a/src/engine/PatchImpl.cpp b/src/engine/PatchImpl.cpp index 6958c8b5..4dc61a21 100644 --- a/src/engine/PatchImpl.cpp +++ b/src/engine/PatchImpl.cpp @@ -17,7 +17,7 @@ #include #include -#include +#include "raul/log.hpp" #include "ThreadManager.hpp" #include "NodeImpl.hpp" #include "PatchImpl.hpp" @@ -310,7 +310,7 @@ PatchImpl::remove_connection(const PortImpl* src_port, const PortImpl* dst_port) } if ( ! found) - cerr << "WARNING: [PatchImpl::remove_connection] Connection not found" << endl; + error << "[PatchImpl::remove_connection] Connection not found" << endl; return connection; } @@ -348,7 +348,7 @@ PortImpl* PatchImpl::create_port(BufferFactory& bufs, const string& name, PortType type, size_t buffer_size, bool is_output) { if (type == PortType::UNKNOWN) { - cerr << "[PatchImpl::create_port] Unknown port type " << type.uri() << endl; + error << "[PatchImpl::create_port] Unknown port type " << type.uri() << endl; return NULL; } @@ -388,7 +388,7 @@ PatchImpl::remove_port(const string& symbol) } if ( ! found) - cerr << "WARNING: [PatchImpl::remove_port] Port not found!" << endl; + error << "[PatchImpl::remove_port] Port not found!" << endl; return ret; } @@ -445,8 +445,6 @@ PatchImpl::compile() const { assert(ThreadManager::current_thread_id() == THREAD_PRE_PROCESS); - //cerr << "*********** Compiling " << path() << endl; - CompiledPatch* const compiled_patch = new CompiledPatch();//_nodes.size()); for (Nodes::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) @@ -466,12 +464,14 @@ PatchImpl::compile() const compile_recursive(node, compiled_patch); } - /*cerr << "----------------------------------------\n"; +#ifdef LOG_DEBUG + debug << path() << " compiled {" << endl; for (size_t i=0; i < process_order->size(); ++i) { assert(process_order->at(i)); - cerr << process_order->at(i)->path() << endl; + debug << " " << process_order->at(i)->path() << endl; } - cerr << "----------------------------------------\n";*/ + debug << "}" << endl; +#endif assert(compiled_patch->size() == _nodes.size()); diff --git a/src/engine/PluginImpl.cpp b/src/engine/PluginImpl.cpp index cdc6ffb2..4aa38032 100644 --- a/src/engine/PluginImpl.cpp +++ b/src/engine/PluginImpl.cpp @@ -15,13 +15,14 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "raul/log.hpp" #include "PluginImpl.hpp" #include "internals/Note.hpp" #include "internals/Trigger.hpp" #include "internals/Controller.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -30,7 +31,7 @@ void PluginImpl::load() { if (!_module) { - //cerr << "Loading " << _library_path << " library" << endl; + debug << "Loading plugin library " << _library_path << endl; _module = new Glib::Module(_library_path, Glib::MODULE_BIND_LOCAL); if (!(*_module)) delete _module; @@ -42,7 +43,7 @@ void PluginImpl::unload() { if (_module) { - //cerr << "Unloading " << _library_path << endl; + debug << "Unloading plugin library " << _library_path << endl; delete _module; _module = NULL; } diff --git a/src/engine/PluginImpl.hpp b/src/engine/PluginImpl.hpp index 6dcf77a5..c8fb9f82 100644 --- a/src/engine/PluginImpl.hpp +++ b/src/engine/PluginImpl.hpp @@ -23,7 +23,6 @@ #include #include #include -#include #include "interface/Plugin.hpp" #include "shared/ResourceImpl.hpp" diff --git a/src/engine/PortImpl.cpp b/src/engine/PortImpl.cpp index bbda42ea..ce4fedbf 100644 --- a/src/engine/PortImpl.cpp +++ b/src/engine/PortImpl.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "raul/Array.hpp" #include "raul/Maid.hpp" #include "contexts.lv2/contexts.h" diff --git a/src/engine/PostProcessor.cpp b/src/engine/PostProcessor.cpp index 513274d5..de073f1a 100644 --- a/src/engine/PostProcessor.cpp +++ b/src/engine/PostProcessor.cpp @@ -16,8 +16,8 @@ */ #include -#include #include +#include "raul/log.hpp" #include "raul/SRSWQueue.hpp" #include "events/SendPortValue.hpp" #include "Event.hpp" @@ -27,6 +27,7 @@ #include "ProcessContext.hpp" using namespace std; +using namespace Raul; namespace Ingen { @@ -59,7 +60,7 @@ PostProcessor::process() Driver* driver = _engine.driver(); if (driver && driver->context().event_sink().read(_event_buffer_size, _event_buffer)) { if (((Event*)_event_buffer)->time() > end_time) { - cerr << "WARNING: Lost event with time " + warn << "Lost event with time " << ((Event*)_event_buffer)->time() << " > " << end_time << endl; break; } diff --git a/src/engine/ProcessSlave.cpp b/src/engine/ProcessSlave.cpp index 3d5a9127..5047ec33 100644 --- a/src/engine/ProcessSlave.cpp +++ b/src/engine/ProcessSlave.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "raul/Atom.hpp" #include "ProcessSlave.hpp" #include "NodeImpl.hpp" diff --git a/src/engine/QueuedEngineInterface.cpp b/src/engine/QueuedEngineInterface.cpp index 5532b732..03365a87 100644 --- a/src/engine/QueuedEngineInterface.cpp +++ b/src/engine/QueuedEngineInterface.cpp @@ -15,7 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include +#include "raul/log.hpp" #include "QueuedEngineInterface.hpp" #include "tuning.hpp" #include "QueuedEventSource.hpp" @@ -23,6 +23,8 @@ #include "Engine.hpp" #include "Driver.hpp" +#define LOG(s) s << "[QueuedEngineInterface] " + using namespace std; using namespace Raul; @@ -158,11 +160,11 @@ QueuedEngineInterface::put(const URI& uri, bool meta = ResourceImpl::is_meta_uri(uri); URI subject(meta ? (string("path:/") + uri.substr(6)) : uri.str()); - /*cerr << "ENGINE PUT " << subject << " {" << endl; + LOG(debug) << "PUT " << subject << " {" << endl; typedef Resource::Properties::const_iterator iterator; for (iterator i = properties.begin(); i != properties.end(); ++i) - cerr << "\t" << i->first << " = " << i->second << " :: " << i->second.type() << endl; - cerr << "}" << endl;*/ + LOG(debug) << " " << i->first << " = " << i->second << " :: " << i->second.type() << endl; + LOG(debug) << "}" << endl; push_queued(new Events::SetMetadata(_engine, _responder, now(), this, true, meta, subject, properties)); } diff --git a/src/engine/QueuedEventSource.cpp b/src/engine/QueuedEventSource.cpp index 98b34acc..9fcd5711 100644 --- a/src/engine/QueuedEventSource.cpp +++ b/src/engine/QueuedEventSource.cpp @@ -16,7 +16,6 @@ */ #include -#include #include "QueuedEventSource.hpp" #include "QueuedEvent.hpp" #include "PostProcessor.hpp" diff --git a/src/engine/events/CreatePort.cpp b/src/engine/events/CreatePort.cpp index ea2b3efa..299e60e9 100644 --- a/src/engine/events/CreatePort.cpp +++ b/src/engine/events/CreatePort.cpp @@ -70,10 +70,8 @@ CreatePort::CreatePort( * TODO: fix this using RCU? */ - if (_data_type == PortType::UNKNOWN) { - cerr << "[CreatePortEvent] Unknown port type " << type << endl; + if (_data_type == PortType::UNKNOWN) _error = UNKNOWN_TYPE; - } } diff --git a/src/engine/events/Disconnect.cpp b/src/engine/events/Disconnect.cpp index 77878d43..c0fc9656 100644 --- a/src/engine/events/Disconnect.cpp +++ b/src/engine/events/Disconnect.cpp @@ -15,6 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "raul/log.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" #include "events/Disconnect.hpp" @@ -29,6 +30,7 @@ #include "EngineStore.hpp" using namespace std; +using namespace Raul; namespace Ingen { namespace Events { @@ -175,8 +177,8 @@ Disconnect::execute(ProcessContext& context) assert(_patch_connection); if (port_connection->elem() != _patch_connection->elem()) { - cerr << "ERROR: Corrupt connections:" << endl; - cerr << "\t" << port_connection->elem() << ": " + error << "Corrupt connections:" << endl + << "\t" << port_connection->elem() << ": " << port_connection->elem()->src_port_path() << " -> " << port_connection->elem()->dst_port_path() << endl << "!=" << endl @@ -207,10 +209,8 @@ Disconnect::post_process() _responder->respond_ok(); _engine.broadcaster()->send_disconnection(_src_port->path(), _dst_port->path()); } else { - // FIXME: better error messages string msg = "Unable to disconnect "; msg.append(_src_port_path.str() + " -> " + _dst_port_path.str()); - cerr << "DISCONNECTION ERROR " << (unsigned)_error << endl; _responder->respond_error(msg); } } diff --git a/src/engine/events/SetMetadata.cpp b/src/engine/events/SetMetadata.cpp index e058b1f4..53e79977 100644 --- a/src/engine/events/SetMetadata.cpp +++ b/src/engine/events/SetMetadata.cpp @@ -17,6 +17,7 @@ #include #include +#include "raul/log.hpp" #include "interface/PortType.hpp" #include "ClientBroadcaster.hpp" #include "CreateNode.hpp" @@ -174,7 +175,7 @@ SetMetadata::pre_process() ev->pre_process(); _set_events.push_back(ev); } else { - cerr << "WARNING: Set value for non-port " << _object->uri() << endl; + warn << "Set value for non-port " << _object->uri() << endl; } } } diff --git a/src/engine/events/SetPortValue.cpp b/src/engine/events/SetPortValue.cpp index 5efc35ae..de1190fb 100644 --- a/src/engine/events/SetPortValue.cpp +++ b/src/engine/events/SetPortValue.cpp @@ -16,6 +16,7 @@ */ #include +#include "raul/log.hpp" #include "event.lv2/event.h" #include "shared/LV2URIMap.hpp" #include "shared/LV2Features.hpp" @@ -207,15 +208,15 @@ SetPortValue::apply(Context& context) if (obuf) { obuf->object()->size = obuf->size() - sizeof(LV2_Object); if (LV2Object::from_atom(_engine.world(), _value, obuf->object())) { - cout << "Converted atom " << _value << " :: " << obuf->object()->type + debug << "Converted atom " << _value << " :: " << obuf->object()->type << " * " << obuf->object()->size << " @ " << obuf->object() << endl; return; } else { - cerr << "WARNING: Failed to convert atom to LV2 object" << endl; + warn << "Failed to convert atom to LV2 object" << endl; } } - cerr << "WARNING: Unknown value type " << (int)_value.type() << endl; + warn << "Unknown value type " << (int)_value.type() << endl; } } @@ -232,7 +233,9 @@ SetPortValue::post_process() _engine.broadcaster()->send_port_value(_port_path, _value); break; case TYPE_MISMATCH: - _responder->respond_error("type mismatch"); + ss << "Illegal value type " << _value.type() + << " for port " << _port_path << endl; + _responder->respond_error(ss.str()); break; case ILLEGAL_VOICE: ss << "Illegal voice number " << _voice_num; diff --git a/src/engine/ingen_http.cpp b/src/engine/ingen_http.cpp index dade5bd3..86ac481a 100644 --- a/src/engine/ingen_http.cpp +++ b/src/engine/ingen_http.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "module/Module.hpp" #include "module/World.hpp" #include "HTTPEngineReceiver.hpp" diff --git a/src/engine/ingen_jack.cpp b/src/engine/ingen_jack.cpp index 63fa6229..cdf9199e 100644 --- a/src/engine/ingen_jack.cpp +++ b/src/engine/ingen_jack.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "module/Module.hpp" #include "module/World.hpp" #include "JackDriver.hpp" diff --git a/src/engine/ingen_osc.cpp b/src/engine/ingen_osc.cpp index 0599adb8..69c8b279 100644 --- a/src/engine/ingen_osc.cpp +++ b/src/engine/ingen_osc.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "module/Module.hpp" #include "module/World.hpp" #include "OSCEngineReceiver.hpp" @@ -27,10 +26,10 @@ using namespace Ingen; struct IngenOSCModule : public Ingen::Shared::Module { void load(Ingen::Shared::World* world) { - cout << "FIXME: OSC port" << endl; - uint16_t port = 16180; SharedPtr interface( - new Ingen::OSCEngineReceiver(*world->local_engine.get(), event_queue_size, port)); + new Ingen::OSCEngineReceiver(*world->local_engine.get(), + event_queue_size, + world->conf->option("engine-port").get_int32())); world->local_engine->add_event_source(interface); } }; diff --git a/src/engine/internals/Controller.cpp b/src/engine/internals/Controller.cpp index bc2f2349..9ad940d2 100644 --- a/src/engine/internals/Controller.cpp +++ b/src/engine/internals/Controller.cpp @@ -138,6 +138,6 @@ ControllerNode::control(ProcessContext& context, uint8_t control_num, uint8_t va } -} // namespace Ingen } // namespace Internals +} // namespace Ingen diff --git a/src/engine/internals/Note.cpp b/src/engine/internals/Note.cpp index cfaab3ed..76659cfd 100644 --- a/src/engine/internals/Note.cpp +++ b/src/engine/internals/Note.cpp @@ -15,11 +15,11 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#include "raul/log.hpp" #include "raul/Array.hpp" #include "raul/Maid.hpp" #include "raul/midi_events.h" -#include -#include #include "internals/Note.hpp" #include "AudioBuffer.hpp" #include "Driver.hpp" @@ -30,6 +30,9 @@ #include "PatchImpl.hpp" #include "ProcessContext.hpp" #include "util.hpp" +#include "ingen-config.h" + +#define LOG(s) s << "[NoteNode] " using namespace std; @@ -132,10 +135,12 @@ NoteNode::process(ProcessContext& context) for (midi_in->rewind(); midi_in->get_event(&frames, &subframes, &type, &size, &buf); midi_in->increment()) { - /*cout << "EVENT TYPE " << type << " @ " << frames << "." << subframes << ": "; +#ifdef LOG_DEBUG + LOG(debug) << "EVENT TYPE " << type << " @ " << frames << "." << subframes << ": "; for (uint16_t i = 0; i < size; ++i) - cout << (int)((char)buf[i]) << " "; - cout << endl;*/ + debug << (int)((char)buf[i]) << " "; + debug << endl; +#endif const FrameTime time = context.start() + (FrameTime)frames; @@ -166,7 +171,7 @@ NoteNode::process(ProcessContext& context) // ? break; default: - //cerr << "Ignored controller " << buf[1] << endl; + //warn << "Ignored controller " << buf[1] << endl; break; } break; @@ -195,7 +200,9 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F uint32_t voice_num = 0; if (key->state != Key::OFF) { - //cerr << "[NoteNode] Double midi note received" << endl; +#ifdef LOG_DEBUG + LOG(debug) << "Double midi note received" << endl; +#endif return; } @@ -224,15 +231,19 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F assert(voice != NULL); assert(voice == &(*_voices)[voice_num]); - /*cerr << "[NoteNode] Note " << (int)note_num << " on @ " << time - << ". Voice " << voice_num << " / " << _polyphony << endl;*/ +#ifdef LOG_DEBUG + LOG(debug) << "Note " << (int)note_num << " on @ " << time + << ". Voice " << voice_num << " / " << _polyphony << endl; +#endif // Update stolen key, if applicable if (voice->state == Voice::Voice::ACTIVE) { assert(_keys[voice->note].state == Key::ON_ASSIGNED); assert(_keys[voice->note].voice == voice_num); _keys[voice->note].state = Key::Key::ON_UNASSIGNED; - //cerr << "[NoteNode] Stole voice " << voice_num << endl; +#ifdef LOG_DEBUG + LOG(debug) << "Stole voice " << voice_num << endl; +#endif } // Store key information for later reallocation on note off @@ -276,7 +287,9 @@ NoteNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time) Key* key = &_keys[note_num]; - //cerr << "[NoteNode] Note " << (int)note_num << " off @ " << time << endl; +#ifdef LOG_DEBUG + debug << "Note " << (int)note_num << " off @ " << time << endl; +#endif if (key->state == Key::ON_ASSIGNED) { // Assigned key, turn off voice and key @@ -284,16 +297,20 @@ NoteNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time) assert((*_voices)[key->voice].note == note_num); if ( ! _sustain) { - //cerr << "... free voice " << key->voice << endl; +#ifdef LOG_DEBUG + debug << "Free voice " << key->voice << endl; +#endif free_voice(context, key->voice, time); } else { - //cerr << "... hold voice " << key->voice << endl; +#ifdef LOG_DEBUG + debug << "Hold voice " << key->voice << endl; +#endif (*_voices)[key->voice].state = Voice::HOLDING; } } else { -#ifndef NDEBUG - cerr << "WARNING: Assigned key, but voice not active" << endl; +#ifdef LOG_DEBUG + debug << "WARNING: Assigned key, but voice not active" << endl; #endif } } @@ -335,7 +352,9 @@ NoteNode::free_voice(ProcessContext& context, uint32_t voice, FrameTime time) (*_voices)[voice].state = Voice::ACTIVE; } else { // No new note for voice, deactivate (set gate low) - //cerr << "[NoteNode] Note off. Key " << (int)note_num << ", Voice " << voice << " Killed" << endl; +#ifdef LOG_DEBUG + LOG(debug) << "Note off: key " << (int)note_num << " voice " << voice << endl; +#endif ((AudioBuffer*)_gate_port->buffer(voice).get())->set_value(0.0f, context.start(), time); (*_voices)[voice].state = Voice::FREE; } @@ -348,7 +367,9 @@ NoteNode::all_notes_off(ProcessContext& context, FrameTime time) assert(time >= context.start() && time <= context.end()); assert(time - context.start() < _buffer_size); - //cerr << "All notes off @ " << offset << endl; +#ifdef LOG_DEBUG + LOG(debug) << "All notes off @ " << offset << endl; +#endif // FIXME: set all keys to Key::OFF? @@ -390,6 +411,6 @@ NoteNode::sustain_off(ProcessContext& context, FrameTime time) } -} // namespace Ingen } // namespace Internals +} // namespace Ingen diff --git a/src/engine/internals/Trigger.cpp b/src/engine/internals/Trigger.cpp index fcd657c7..7c05a1d3 100644 --- a/src/engine/internals/Trigger.cpp +++ b/src/engine/internals/Trigger.cpp @@ -16,6 +16,7 @@ */ #include +#include "raul/log.hpp" #include "raul/midi_events.h" #include "internals/Trigger.hpp" #include "AudioBuffer.hpp" @@ -26,7 +27,10 @@ #include "ProcessContext.hpp" #include "util.hpp" +#define LOG(s) s << "[TriggerNode] " + using namespace std; +using namespace Raul; namespace Ingen { namespace Internals { @@ -124,7 +128,9 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity _learning = false; } - /*cerr << "[TriggerNode] " << path() << " Note " << (int)note_num << " on @ " << time << endl;*/ +#ifdef LOG_DEBUG + LOG(debug) << path() << " note " << (int)note_num << " on @ " << time << endl; +#endif Sample filter_note = ((AudioBuffer*)_note_port->buffer(0).get())->value_at(0); if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uint8_t)filter_note)) { @@ -148,6 +154,5 @@ TriggerNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time) } -} // namespace Ingen } // namespace Internals - +} // namespace Ingen diff --git a/src/engine/mix.hpp b/src/engine/mix.hpp index a4cd16d8..792e4e94 100644 --- a/src/engine/mix.hpp +++ b/src/engine/mix.hpp @@ -18,11 +18,13 @@ #ifndef MIX_HPP #define MIX_HPP -#include +#include "raul/log.hpp" #include "interface/PortType.hpp" #include "Buffer.hpp" #include "Context.hpp" +using namespace Raul; + namespace Ingen { inline void @@ -74,7 +76,7 @@ mix(Context& context, Buffer* dst, const Buffer*const* srcs, uint32_t num_srcs) break; default: - std::cerr << "ERROR: Mix of unsupported buffer types" << std::endl; + error << "Mix of unsupported buffer types" << std::endl; return; } } diff --git a/src/engine/util.hpp b/src/engine/util.hpp index 945e5101..3b9d436c 100644 --- a/src/engine/util.hpp +++ b/src/engine/util.hpp @@ -18,10 +18,10 @@ #ifndef UTIL_HPP #define UTIL_HPP -#include "ingen-config.h" -#include "raul/Path.hpp" -#include #include +#include "raul/log.hpp" +#include "raul/Path.hpp" +#include "ingen-config.h" #include #ifdef __SSE__ @@ -63,11 +63,11 @@ set_denormal_flags() } if (d1 & 1<<26) { /* bit 26, SSE2 support */ _mm_setcsr(_mm_getcsr() | 0x8040); // set DAZ and FZ bits of MXCSR - //cerr << "Set SSE denormal fix flag." << endl; + Raul::info << "Set SSE denormal fix flag" << endl; } } else { - std::cerr << "This code has been built with SSE support, but your processor does" - << " not support the SSE instruction set." << std::endl << "Exiting." << std::endl; + Raul::warn << "This code has been built with SSE support, but your processor does" + << " not support the SSE instruction set, exiting." << std::endl; exit(EXIT_FAILURE); } #endif diff --git a/src/gui/App.cpp b/src/gui/App.cpp index 0f34de2f..3efd9dc0 100644 --- a/src/gui/App.cpp +++ b/src/gui/App.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "raul/log.hpp" #include "raul/Path.hpp" #include "flowcanvas/Connection.hpp" #include "module/World.hpp" @@ -51,6 +52,7 @@ #endif using namespace std; +using namespace Raul; using namespace Ingen::Client; namespace Raul { class Deletable; } @@ -150,7 +152,7 @@ App::run() { assert(_main); _main->run(); - cout << "Gtk exiting." << endl; + info << "GUI exiting" << endl; } @@ -272,84 +274,9 @@ App::animate() } - /******** Event Handlers ************/ -#if 0 -App::event_load_session() -{ - Gtk::FileChooserDialog* dialog - = new Gtk::FileChooserDialog(*_main_window, "Load Session", Gtk::FILE_CHOOSER_ACTION_OPEN); - - dialog->add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dialog->add_button(Gtk::Stock::OPEN, Gtk::RESPONSE_OK); - int result = dialog->run(); - string filename = dialog->get_filename(); - delete dialog; - - cout << result << endl; - - assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE); - - if (result == Gtk::RESPONSE_OK) - //configuration->load_session(filename); - _controller->load_session(filename); -} - - -void -App::event_save_session_as() -{ - Gtk::FileChooserDialog dialog(*_main_window, "Save Session", Gtk::FILE_CHOOSER_ACTION_SAVE); - - /* - Gtk::VBox* box = dialog.get_vbox(); - Gtk::Label warning("Warning: Recursively saving will overwrite any subpatch files \ - without confirmation."); - box->pack_start(warning, false, false, 2); - Gtk::CheckButton recursive_checkbutton("Recursively save all subpatches"); - box->pack_start(recursive_checkbutton, false, false, 0); - recursive_checkbutton.show(); - */ - dialog.add_button(Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL); - dialog.add_button(Gtk::Stock::SAVE, Gtk::RESPONSE_OK); - - int result = dialog.run(); - //bool recursive = recursive_checkbutton.get_active(); - - assert(result == Gtk::RESPONSE_OK || result == Gtk::RESPONSE_CANCEL || result == Gtk::RESPONSE_NONE); - - if (result == Gtk::RESPONSE_OK) { - string filename = dialog.get_filename(); - if (filename.length() < 11 || filename.substr(filename.length()-10) != ".omsession") - filename += ".omsession"; - - bool confirm = false; - std::fstream fin; - fin.open(filename.c_str(), std::ios::in); - if (fin.is_open()) { // File exists - string msg = "File already exists! Are you sure you want to overwrite "; - msg += filename + "?"; - Gtk::MessageDialog confir_dialog(*_main_window, - msg, false, Gtk::MESSAGE_WARNING, Gtk::BUTTONS_YES_NO, true); - if (confir_dialog.run() == Gtk::RESPONSE_YES) - confirm = true; - else - confirm = false; - } else { // File doesn't exist - confirm = true; - } - fin.close(); - - if (confirm) { - _controller->save_session(filename); - } - } -} -#endif - - void App::register_callbacks() { @@ -418,9 +345,8 @@ App::icon_from_path(const string& path, int size) _icons.insert(make_pair(make_pair(path, size), buf.operator->())); buf->add_destroy_notify_callback(new pair(path, size), &App::icon_destroyed); - //cerr << "Loaded icon " << path << " with size " << size << endl; } catch (Glib::Error e) { - cerr << "Error loading icon: " << e.what() << endl; + warn << "Error loading icon: " << e.what() << endl; } return buf; } @@ -430,7 +356,6 @@ void* App::icon_destroyed(void* data) { pair* p = static_cast*>(data); - //cerr << "Destroyed icon " << p->first << " with size " << p->second << endl; Icons::iterator iter = instance()._icons.find(*p); if (iter != instance()._icons.end()) instance()._icons.erase(iter); diff --git a/src/gui/App.hpp b/src/gui/App.hpp index bf55d51b..0ced5584 100644 --- a/src/gui/App.hpp +++ b/src/gui/App.hpp @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp index 83de3321..03f84a5a 100644 --- a/src/gui/Configuration.cpp +++ b/src/gui/Configuration.cpp @@ -18,9 +18,9 @@ #include "Configuration.hpp" #include #include -#include #include #include +#include "raul/log.hpp" #include "client/PortModel.hpp" #include "client/PluginModel.hpp" #include "serialisation/Parser.hpp" @@ -29,6 +29,7 @@ #include "Port.hpp" using namespace std; +using namespace Raul; namespace Ingen { namespace GUI { @@ -102,7 +103,7 @@ Configuration::get_port_color(const PortModel* p) return _event_port_color; } - cerr << "[Configuration] Unknown port type " << p->type().uri() + error << "[Configuration] Unknown port type " << p->type().uri() << ", port will appear black." << endl; return 0x000000FF; diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp index 9643f693..d2783c30 100644 --- a/src/gui/ConnectWindow.cpp +++ b/src/gui/ConnectWindow.cpp @@ -21,6 +21,7 @@ #include #include #include +#include "raul/log.hpp" #include "raul/Process.hpp" #include "ingen-config.h" #include "interface/EngineInterface.hpp" @@ -48,6 +49,7 @@ using Ingen::QueuedEngineInterface; using namespace Ingen::Client; using namespace std; +using namespace Raul; namespace Raul { class Deletable; } @@ -177,8 +179,6 @@ ConnectWindow::connect(bool existing) if (existing) uri = world->engine->uri().str(); - cout << "CONNECT EXISTING " << existing << " URI " << uri << endl; - // Create client-side listener SharedPtr tsci(new ThreadedSigClientInterface(1024)); SharedPtr client; @@ -236,10 +236,10 @@ ConnectWindow::connect(bool existing) sigc::mem_fun(this, &ConnectWindow::gtk_callback), 40); } else { - cerr << "Failed to launch ingen process." << endl; + error << "Failed to launch ingen process." << endl; } #else - cerr << "No OSC support" << endl; + error << "No OSC support" << endl; #endif } else diff --git a/src/gui/Connection.cpp b/src/gui/Connection.cpp index 48cf7372..8f4e3d7b 100644 --- a/src/gui/Connection.cpp +++ b/src/gui/Connection.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include "client/ConnectionModel.hpp" #include "Connection.hpp" #include "Port.hpp" diff --git a/src/gui/ControlPanel.cpp b/src/gui/ControlPanel.cpp index 96559dbf..21728d59 100644 --- a/src/gui/ControlPanel.cpp +++ b/src/gui/ControlPanel.cpp @@ -78,12 +78,9 @@ ControlPanel::init(SharedPtr node, uint32_t poly) node->signal_property.connect( sigc::mem_fun(this, &ControlPanel::variable_changed)); - if (node->parent()) { + if (node->parent()) node->signal_property.connect( sigc::mem_fun(this, &ControlPanel::parent_property_changed)); - } else { - cerr << "[ControlPanel] No parent, polyphonic controls disabled" << endl; - } _callback_enabled = true; } @@ -160,9 +157,6 @@ ControlPanel::add_port(SharedPtr pm) _voice_control_box->size_request(voice_size); _ideal_size.first += voice_size.width; _ideal_size.second += voice_size.height; - - //cerr << "Setting ideal size to " << _ideal_size.first - // << " x " << _ideal_size.second << endl; } @@ -184,54 +178,6 @@ ControlPanel::remove_port(const Path& path) } -/** Rename the control for the given port. - */ -/* -void -ControlPanel::rename_port(const Path& old_path, const Path& new_path) -{ - for (vector::iterator cg = _controls.begin(); cg != _controls.end(); ++cg) { - if ((*cg)->port_model()->path() == old_path) { - (*cg)->set_name(new_path.name()); - return; - } - } -} -*/ - -#if 0 -/** Enable the control for the given port. - * - * Used when all connections to port are un-made. - */ -void -ControlPanel::enable_port(const Path& path) -{ - for (vector::iterator i = _controls.begin(); i != _controls.end(); ++i) { - if ((*i)->port_model()->path() == path) { - (*i)->enable(); - return; - } - } -} - - -/** Disable the control for the given port. - * - * Used when port is connected. - */ -void -ControlPanel::disable_port(const Path& path) -{ - for (vector::iterator i = _controls.begin(); i != _controls.end(); ++i) { - if ((*i)->port_model()->path() == path) { - (*i)->disable(); - return; - } - } -} -#endif - /** Callback for Controls to notify this of a change. */ void diff --git a/src/gui/ControlPanel.hpp b/src/gui/ControlPanel.hpp index 375c0a72..024bd720 100644 --- a/src/gui/ControlPanel.hpp +++ b/src/gui/ControlPanel.hpp @@ -20,7 +20,6 @@ #include #include -#include #include // for pair<> #include #include diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp index 9c66b1ae..5b7d40e8 100644 --- a/src/gui/Controls.cpp +++ b/src/gui/Controls.cpp @@ -16,8 +16,8 @@ */ #include -#include #include +#include "raul/log.hpp" #include "interface/EngineInterface.hpp" #include "client/PluginModel.hpp" #include "client/NodeModel.hpp" @@ -347,8 +347,9 @@ ToggleControl::set_value(const Atom& val) break; case Atom::BOOL: enable = (val.get_bool()); + break; default: - cerr << "Unsupported value type for toggle control" << endl; + error << "Unsupported value type for toggle control" << endl; } _enable_signal = false; @@ -422,7 +423,7 @@ StringControl::set_value(const Atom& val) if (val.type() == Atom::STRING) _entry->set_text(val.get_string()); else - cerr << "ERROR: Non-string value for string port" << endl; + error << "Non-string value for string port" << endl; _enable_signal = true; } diff --git a/src/gui/GladeFactory.cpp b/src/gui/GladeFactory.cpp index 170a5cd4..41fcffc4 100644 --- a/src/gui/GladeFactory.cpp +++ b/src/gui/GladeFactory.cpp @@ -16,12 +16,13 @@ */ #include "GladeFactory.hpp" -#include #include +#include "raul/log.hpp" #include "ingen-config.h" #include "shared/runtime_paths.hpp" using namespace std; +using namespace Raul; namespace Ingen { namespace GUI { @@ -41,12 +42,12 @@ GladeFactory::find_glade_file() ifstream fs(glade_filename.c_str()); if (fs.fail()) { - cerr << "Unable to find ingen_gui.glade in " << INGEN_DATA_DIR << endl; + error << "[GladeFactory] Unable to find ingen_gui.glade in " << INGEN_DATA_DIR << endl; throw; } fs.close(); - cerr << "[GladeFactory] Loading widgets from " << glade_filename.c_str() << endl; + info << "[GladeFactory] Loading widgets from " << glade_filename.c_str() << endl; } @@ -62,7 +63,7 @@ GladeFactory::new_glade_reference(const string& toplevel_widget) else return Gnome::Glade::Xml::create(glade_filename, toplevel_widget.c_str()); } catch (const Gnome::Glade::XmlError& ex) { - cerr << ex.what() << endl; + error << "[GladeFactory] " << ex.what() << endl; throw ex; } } diff --git a/src/gui/LoadPluginWindow.cpp b/src/gui/LoadPluginWindow.cpp index be3a6e1a..daa8e88a 100644 --- a/src/gui/LoadPluginWindow.cpp +++ b/src/gui/LoadPluginWindow.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include diff --git a/src/gui/LoadSubpatchWindow.cpp b/src/gui/LoadSubpatchWindow.cpp index 848e7643..82edc3a2 100644 --- a/src/gui/LoadSubpatchWindow.cpp +++ b/src/gui/LoadSubpatchWindow.cpp @@ -157,7 +157,6 @@ LoadSubpatchWindow::ok_clicked() } if (_poly_from_user_radio->get_active()) { - cerr << "Overriding poly: " << _poly_spinbutton->get_value_as_int() << endl; _initial_data.insert(make_pair("ingen:polyphony", (int)_poly_spinbutton->get_value_as_int())); } else if (_poly_from_parent_radio->get_active()) { _initial_data.insert(make_pair("ingen:polyphony", (int)_patch->poly())); diff --git a/src/gui/NodeControlWindow.cpp b/src/gui/NodeControlWindow.cpp index 65ab5f21..07066d7d 100644 --- a/src/gui/NodeControlWindow.cpp +++ b/src/gui/NodeControlWindow.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include "interface/EngineInterface.hpp" #include "client/NodeModel.hpp" @@ -94,10 +93,7 @@ void NodeControlWindow::resize() { pair controls_size = _control_panel->ideal_size(); - /*int width = 400; - int height = controls_size.second - + ((_node->polyphonic()) ? 4 : 40);*/ - int width = controls_size.first; + int width = controls_size.first; int height = controls_size.second; if (height > property_screen().get_value()->get_height() - 64) @@ -105,8 +101,6 @@ NodeControlWindow::resize() if (width > property_screen().get_value()->get_width() - 64) width = property_screen().get_value()->get_width() - 64; - //cerr << "Resizing to: " << width << " x " << height << endl; - Gtk::Window::resize(width, height); } diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp index 3819f45a..d667181a 100644 --- a/src/gui/NodeMenu.cpp +++ b/src/gui/NodeMenu.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include "interface/EngineInterface.hpp" #include "client/NodeModel.hpp" diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp index 9010221a..de479c54 100644 --- a/src/gui/NodeModule.cpp +++ b/src/gui/NodeModule.cpp @@ -17,6 +17,7 @@ #include #include "ingen-config.h" +#include "raul/log.hpp" #include "raul/Atom.hpp" #include "interface/EngineInterface.hpp" #include "client/PatchModel.hpp" @@ -186,7 +187,7 @@ NodeModule::embed_gui(bool embed) if (embed) { if (_gui_window) { - cerr << "LV2 GUI already popped up, cannot embed" << endl; + warn << "LV2 GUI already popped up, cannot embed" << endl; return; } @@ -206,7 +207,7 @@ NodeModule::embed_gui(bool embed) container->add(*_gui_widget); FlowCanvas::Module::embed(container); } else { - cerr << "ERROR: Failed to create LV2 UI" << endl; + error << "Failed to create LV2 UI" << endl; } if (_gui_widget) { @@ -290,7 +291,7 @@ NodeModule::remove_port(SharedPtr model) Module::remove_port(p); p.reset(); } else { - cerr << "WARNING: Failed to find port on module: " << model->path() << endl; + warn << "Failed to find port on module " << model->path() << endl; } } @@ -301,7 +302,7 @@ NodeModule::popup_gui() #ifdef HAVE_SLV2 if (_node->plugin() && _node->plugin()->type() == PluginModel::LV2) { if (_plugin_ui) { - cerr << "LV2 GUI already embedded, cannot pop up" << endl; + warn << "LV2 GUI already embedded, cannot pop up" << endl; return false; } @@ -327,7 +328,7 @@ NodeModule::popup_gui() return true; } else { - cerr << "No LV2 GUI" << endl; + warn << "No LV2 GUI for " << _node->path() << endl; } } #endif diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp index c83bc04c..2d389e4e 100644 --- a/src/gui/PatchCanvas.cpp +++ b/src/gui/PatchCanvas.cpp @@ -15,12 +15,10 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "ingen-config.h" -#include "module/World.hpp" - #include #include #include +#include "raul/log.hpp" #include "flowcanvas/Canvas.hpp" #include "flowcanvas/Ellipse.hpp" #include "interface/EngineInterface.hpp" @@ -31,6 +29,7 @@ #include "client/PatchModel.hpp" #include "client/NodeModel.hpp" #include "client/ClientStore.hpp" +#include "module/World.hpp" #include "App.hpp" #include "PatchCanvas.hpp" #include "PatchWindow.hpp" @@ -45,6 +44,9 @@ #include "GladeFactory.hpp" #include "WindowFactory.hpp" #include "ThreadedLoader.hpp" +#include "ingen-config.h" + +#define LOG(s) s << "[PatchCanvas] " using Ingen::Client::ClientStore; using Ingen::Serialisation::Serialiser; @@ -413,7 +415,7 @@ PatchCanvas::remove_port(SharedPtr pm) if (i != _views.end()) { bool ret = remove_item(i->second); if (!ret) - cerr << "WARNING: Failed to remove port item: " << pm->path() << endl; + warn << "Failed to remove port item " << pm->path() << endl; i->second.reset(); _views.erase(i); @@ -464,7 +466,7 @@ PatchCanvas::connection(SharedPtr cm) add_connection(boost::shared_ptr(new GUI::Connection(shared_from_this(), cm, src, dst, src->color() + 0x22222200))); } else { - cerr << "[PatchCanvas] ERROR: Unable to find ports to connect " + LOG(error) << "Unable to find ports to connect " << cm->src_port_path() << " -> " << cm->dst_port_path() << endl; } } @@ -479,7 +481,7 @@ PatchCanvas::disconnection(SharedPtr cm) if (src && dst) remove_connection(src, dst); else - cerr << "[PatchCanvas] ERROR: Unable to find ports to disconnect " + LOG(error) << "Unable to find ports to disconnect " << cm->src_port_path() << " -> " << cm->dst_port_path() << endl; } @@ -499,7 +501,7 @@ PatchCanvas::connect(boost::shared_ptr src_port, // Midi binding/learn shortcut if (src->model()->type().is_events() && dst->model()->type().is_control()) { - cerr << "[PatchCanvas] TODO: MIDI binding shortcut" << endl; + LOG(error) << "TODO: MIDI binding shortcut" << endl; } else { App::instance().engine()->connect(src->model()->path(), dst->model()->path()); } @@ -638,7 +640,7 @@ PatchCanvas::paste() Glib::ustring str = Gtk::Clipboard::get()->wait_for_text(); SharedPtr parser = App::instance().loader()->parser(); if (!parser) { - cerr << "Unable to load parser, paste unavailable" << endl; + LOG(error) << "Unable to load parser, paste unavailable" << endl; return; } @@ -681,10 +683,8 @@ PatchCanvas::paste() parent, symbol); for (Store::iterator i = clipboard.begin(); i != clipboard.end(); ++i) { - if (_patch->path().is_root() && i->first.is_root()) { - //cout << "Skipping root" << endl; + if (_patch->path().is_root() && i->first.is_root()) continue; - } GraphObject::Properties::iterator x = i->second->properties().find("ingenuity:canvas-x"); if (x != i->second->properties().end()) x->second = x->second.get_float() + (20.0f * _paste_count); @@ -708,13 +708,6 @@ PatchCanvas::paste() i != root->connections().end(); ++i) { App::instance().engine()->connect((*i)->src_port_path(), (*i)->dst_port_path()); } - - // Orphan connections (just in case...) - /*for (ClientStore::ConnectionRecords::const_iterator i = clipboard.connection_records().begin(); - i != clipboard.connection_records().end(); ++i) { - cout << "WARNING: Orphan connection paste: " << i->first << " -> " << i->second << endl; - App::instance().engine()->connect(i->first, i->second); - }*/ } diff --git a/src/gui/PatchPortModule.cpp b/src/gui/PatchPortModule.cpp index 19a2210f..1147e4c9 100644 --- a/src/gui/PatchPortModule.cpp +++ b/src/gui/PatchPortModule.cpp @@ -16,7 +16,6 @@ */ #include -#include #include #include "PatchPortModule.hpp" #include "interface/EngineInterface.hpp" diff --git a/src/gui/PatchPropertiesWindow.cpp b/src/gui/PatchPropertiesWindow.cpp index 0ece28f4..cf5a9917 100644 --- a/src/gui/PatchPropertiesWindow.cpp +++ b/src/gui/PatchPropertiesWindow.cpp @@ -16,7 +16,6 @@ */ #include -#include #include "client/PatchModel.hpp" #include "PatchPropertiesWindow.hpp" #include "App.hpp" diff --git a/src/gui/PatchTreeWindow.cpp b/src/gui/PatchTreeWindow.cpp index 262c4d60..feb0606c 100644 --- a/src/gui/PatchTreeWindow.cpp +++ b/src/gui/PatchTreeWindow.cpp @@ -15,6 +15,7 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "raul/log.hpp" #include "raul/Path.hpp" #include "interface/EngineInterface.hpp" #include "client/ClientStore.hpp" @@ -24,6 +25,8 @@ #include "SubpatchModule.hpp" #include "WindowFactory.hpp" +#define LOG(s) s << "[PatchTreeWindow] " + using namespace std; using namespace Raul; @@ -161,8 +164,7 @@ PatchTreeWindow::show_patch_menu(GdkEventButton* ev) Gtk::TreeModel::Row row = *active; SharedPtr pm = row[_patch_tree_columns.patch_model_col]; if (pm) - cerr << "FIXME: patch menu\n"; - //pm->show_menu(ev); + warn << "TODO: patch menu from tree window" << endl; } } @@ -204,7 +206,7 @@ PatchTreeWindow::patch_property_changed(const URI& key, const Atom& value, Gtk::TreeModel::Row row = *i; row[_patch_tree_columns.enabled_col] = value.get_bool(); } else { - cerr << "[PatchTreeWindow] Unable to find patch " << patch->path() << endl; + LOG(error) << "Unable to find patch " << patch->path() << endl; } } _enable_signal = true; @@ -223,7 +225,7 @@ PatchTreeWindow::patch_moved(SharedPtr patch) Gtk::TreeModel::Row row = *i; row[_patch_tree_columns.name_col] = patch->path().name(); } else { - cerr << "[PatchTreeWindow] Unable to find patch " << patch->path() << endl; + LOG(error) << "Unable to find patch " << patch->path() << endl; } _enable_signal = true; diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp index c59f787c..6e3282bc 100644 --- a/src/gui/PatchView.cpp +++ b/src/gui/PatchView.cpp @@ -15,9 +15,9 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include +#include "raul/log.hpp" #include "interface/EngineInterface.hpp" #include "client/PatchModel.hpp" #include "App.hpp" @@ -68,8 +68,6 @@ PatchView::set_patch(SharedPtr patch) { assert(!_canvas); // FIXME: remove - //cerr << "Creating view for " << patch->path() << endl; - assert(_breadcrumb_container); // ensure created _patch = patch; @@ -120,18 +118,10 @@ PatchView::set_patch(SharedPtr patch) } -PatchView::~PatchView() -{ - //cerr << "Destroying view for " << _patch->path() << endl; -} - - SharedPtr PatchView::create(SharedPtr patch) - { - -const Glib::RefPtr& xml = GladeFactory::new_glade_reference("patch_view_box"); + const Glib::RefPtr& xml = GladeFactory::new_glade_reference("patch_view_box"); PatchView* result = NULL; xml->get_widget_derived("patch_view_box", result); assert(result); @@ -226,7 +216,7 @@ PatchView::property_changed(const Raul::URI& predicate, const Raul::Atom& value) if (value.type() == Atom::BOOL) _process_but->set_active(value.get_bool()); else - cerr << "WARNING: Bad type for ingen:enabled variable: " << value.type() << endl; + warn << "Bad type for ingen:enabled variable: " << value.type() << endl; } _enable_signal = true; } diff --git a/src/gui/PatchView.hpp b/src/gui/PatchView.hpp index 82a2a1b0..ed713803 100644 --- a/src/gui/PatchView.hpp +++ b/src/gui/PatchView.hpp @@ -58,7 +58,6 @@ class PatchView : public Gtk::Box { public: PatchView(BaseObjectType* cobject, const Glib::RefPtr& glade_xml); - ~PatchView(); SharedPtr canvas() const { return _canvas; } SharedPtr patch() const { return _patch; } diff --git a/src/gui/PatchWindow.cpp b/src/gui/PatchWindow.cpp index 8c9d8c42..c9ca705a 100644 --- a/src/gui/PatchWindow.cpp +++ b/src/gui/PatchWindow.cpp @@ -16,7 +16,6 @@ */ #include "PatchWindow.hpp" -#include #include #include #include diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index 91e64f3a..5e1050f8 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -16,7 +16,7 @@ */ #include -#include +#include "raul/log.hpp" #include "interface/EngineInterface.hpp" #include "flowcanvas/Module.hpp" #include "client/PatchModel.hpp" @@ -131,7 +131,7 @@ Port::value_changed(const Atom& value) else if (value.type() == Atom::FLOAT) FlowCanvas::Port::set_control(value.get_float()); else - cerr << "WARNING: Unknown port value type " << (unsigned)value.type() << endl; + warn << "Unknown port value type " << (unsigned)value.type() << endl; } diff --git a/src/gui/PortMenu.cpp b/src/gui/PortMenu.cpp index 48a0e2c3..a32eb662 100644 --- a/src/gui/PortMenu.cpp +++ b/src/gui/PortMenu.cpp @@ -15,7 +15,6 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include "raul/SharedPtr.hpp" #include "interface/EngineInterface.hpp" diff --git a/src/gui/SubpatchModule.cpp b/src/gui/SubpatchModule.cpp index e25e7068..63377e5c 100644 --- a/src/gui/SubpatchModule.cpp +++ b/src/gui/SubpatchModule.cpp @@ -17,7 +17,6 @@ #include "SubpatchModule.hpp" #include -#include #include "interface/EngineInterface.hpp" #include "client/PatchModel.hpp" #include "App.hpp" @@ -56,7 +55,6 @@ SubpatchModule::on_double_click(GdkEventButton* event) } - /** Browse to this patch in current (parent's) window * (unless an existing window is displaying it) */ @@ -75,15 +73,6 @@ SubpatchModule::browse_to_patch() } - -void -SubpatchModule::show_dialog() -{ - std::cerr << "FIXME: dialog" << std::endl; - //m_patch->show_control_window(); -} - - void SubpatchModule::menu_remove() { diff --git a/src/gui/SubpatchModule.hpp b/src/gui/SubpatchModule.hpp index 7d41f95f..cef2dfb6 100644 --- a/src/gui/SubpatchModule.hpp +++ b/src/gui/SubpatchModule.hpp @@ -53,7 +53,6 @@ public: void on_double_click(GdkEventButton* ev); - void show_dialog(); void browse_to_patch(); void menu_remove(); diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index ae5c995f..007bb816 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -15,8 +15,8 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include +#include "raul/log.hpp" #include "module/World.hpp" #include "module/Module.hpp" #include "module/ingen_module.hpp" @@ -40,7 +40,7 @@ ThreadedLoader::ThreadedLoader(SharedPtr engine) if (parser()) start(); else - cerr << "WARNING: Failed to load ingen_serialisation module, load disabled." << endl; + warn << "Failed to load ingen_serialisation module, load disabled." << endl; } diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp index 715261f3..0532a5e0 100644 --- a/src/ingen/main.cpp +++ b/src/ingen/main.cpp @@ -24,6 +24,7 @@ #include #include #include +#include "raul/log.hpp" #include "raul/Configuration.hpp" #include "raul/Path.hpp" #include "raul/SharedPtr.hpp" diff --git a/src/module/World.cpp b/src/module/World.cpp index d5e50a9e..e3b93c8f 100644 --- a/src/module/World.cpp +++ b/src/module/World.cpp @@ -15,15 +15,18 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include +#include "raul/log.hpp" #include "ingen-config.h" #include "shared/runtime_paths.hpp" #include "World.hpp" +#define LOG(s) s << "[Module] " + using namespace std; +using namespace Raul; namespace Ingen { namespace Shared { @@ -52,11 +55,11 @@ load_module(const string& name) if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { module = new Glib::Module(filename, Glib::MODULE_BIND_LAZY); if (*module) { - cerr << "[Module] Loaded \"" << name << "\" from " << filename << endl; + LOG(info) << "Loaded \"" << name << "\" from " << filename << endl; return SharedPtr(module); } else { delete module; - cerr << Glib::Module::get_last_error() << endl; + error << Glib::Module::get_last_error() << endl; } } } @@ -68,16 +71,16 @@ load_module(const string& name) Glib::MODULE_BIND_LAZY); if (*module) { - cerr << "[Module] Loaded \"" << name << "\" from " << INGEN_MODULE_DIR << endl; + LOG(info) << "Loaded \"" << name << "\" from " << INGEN_MODULE_DIR << endl; return SharedPtr(module); } else if (!module_path_found) { - cerr << "[Module] Unable to find " << name + LOG(error) << "Unable to find " << name << " (" << Glib::Module::get_last_error() << ")" << endl; return SharedPtr(); } else { - cerr << "[Module] Unable to load " << name << " from " << module_path + LOG(error) << "Unable to load " << name << " from " << module_path << " (" << Glib::Module::get_last_error() << ")" << endl; - cerr << "Is Ingen installed? Use ./ingen.dev to run from the source tree." << endl; + LOG(error) << "Is Ingen installed?" << endl; return SharedPtr(); } } @@ -97,7 +100,7 @@ World::load(const char* name) modules.insert(make_pair(string(name), module)); return true; } else { - cerr << "Failed to load module " << name << endl; + LOG(error) << "Failed to load module " << name << endl; return false; } } @@ -120,7 +123,7 @@ World::interface(const std::string& url) const string scheme = url.substr(0, url.find(":")); const InterfaceFactories::const_iterator i = interface_factories.find(scheme); if (i == interface_factories.end()) { - cerr << "WARNING: Unknown URI scheme `'" << scheme << "'" << endl; + warn << "Unknown URI scheme `'" << scheme << "'" << endl; return SharedPtr(); } @@ -134,7 +137,7 @@ World::run(const std::string& mime_type, const std::string& filename) { const ScriptRunners::const_iterator i = script_runners.find(mime_type); if (i == script_runners.end()) { - cerr << "WARNING: Unknown script MIME type `'" << mime_type << "'" << endl; + warn << "Unknown script MIME type `'" << mime_type << "'" << endl; return false; } diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index c3137e05..cee4d656 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -15,10 +15,10 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include #include #include #include +#include "raul/log.hpp" #include "redlandmm/Model.hpp" #include "redlandmm/Node.hpp" #include "redlandmm/Query.hpp" @@ -28,6 +28,8 @@ #include "interface/EngineInterface.hpp" #include "Parser.hpp" +#define LOG(s) s << "[Parser] " + using namespace std; using namespace Raul; using namespace Ingen::Shared; @@ -97,13 +99,13 @@ Parser::parse_document( Redland::Model model(*world->rdf_world, document_uri, document_uri); - cout << "[Parser] Parsing document " << document_uri << endl; + LOG(info) << "Parsing document " << document_uri << endl; if (data_path) - cout << "[Parser] Document path: " << *data_path << endl; + LOG(info) << "Document path: " << *data_path << endl; if (parent) - cout << "[Parser] Parent: " << *parent << endl; + LOG(info) << "Parent: " << *parent << endl; if (symbol) - cout << "[Parser] Symbol: " << *symbol << endl; + LOG(info) << "Symbol: " << *symbol << endl; boost::optional parsed_path = parse(world, target, model, document_uri, data_path, parent, symbol, data); @@ -111,7 +113,7 @@ Parser::parse_document( if (parsed_path) { target->set_property(*parsed_path, "ingen:document", Atom(Atom::URI, document_uri.c_str())); } else { - cerr << "WARNING: document URI lost" << endl; + LOG(warn) << "Document URI lost" << endl; } return parsed_path; @@ -131,10 +133,10 @@ Parser::parse_string( { Redland::Model model(*world->rdf_world, str.c_str(), str.length(), base_uri); - cout << "Parsing " << (data_path ? data_path->str() : "*") << " from string"; + LOG(info) << "Parsing " << (data_path ? data_path->str() : "*") << " from string"; if (base_uri != "") - cout << " (base " << base_uri << ")"; - cout << endl; + LOG(info) << " (base " << base_uri << ")"; + LOG(info) << endl; bool ret = parse(world, target, model, base_uri, data_path, parent, symbol, data); Redland::Resource subject(*world->rdf_world, base_uri); @@ -272,7 +274,7 @@ Parser::parse( path_str = "/" + path_str; if (!Path::is_valid(path_str)) { - cerr << "WARNING: Invalid path '" << path_str << "', object skipped" << endl; + LOG(warn) << "Invalid path '" << path_str << "', object skipped" << endl; continue; } @@ -281,7 +283,7 @@ Parser::parse( : (parent ? parent->base() : "/") + path_str.substr(path_str.find("/")+1); if (!Path::is_valid(path)) { - cerr << "WARNING: Invalid path '" << path << "' transformed to /" << endl; + LOG(warn) << "Invalid path '" << path << "' transformed to /" << endl; path = "/"; } @@ -294,7 +296,7 @@ Parser::parse( } if (!ret) { - cerr << "Failed to parse object " << path << endl; + LOG(error) << "Failed to parse object " << path << endl; return boost::optional(); } @@ -339,8 +341,6 @@ Parser::parse_patch( const Glib::ustring subject = subject_node.to_turtle_token(); - //cout << "**** Parse patch " << subject << endl; - /* Load polyphony from file if necessary */ if (patch_poly == 0) { Redland::Query query(*world->rdf_world, Glib::ustring( @@ -352,7 +352,7 @@ Parser::parse_patch( if (poly_node.is_int()) patch_poly = poly_node.to_int(); else - cerr << "WARNING: Patch has non-integer polyphony, assuming 1" << endl; + LOG(warn) << "Patch has non-integer polyphony, assuming 1" << endl; } } @@ -374,7 +374,7 @@ Parser::parse_patch( string patch_path_str = relative_uri(base_uri, subject_node.to_string(), true); if (!Path::is_valid(patch_path_str)) { - cerr << "ERROR: Patch has invalid path: " << patch_path_str << endl; + LOG(error) << "Patch has invalid path: " << patch_path_str << endl; return boost::optional(); } @@ -454,7 +454,7 @@ Parser::parse_patch( } else if (plug_i != plugin_nodes.end()) { plug_i->second.insert(make_pair(key, AtomRDF::node_to_atom(object))); } else { - cerr << "WARNING: Unrecognized node: " << node.to_string() << endl; + LOG(warn) << "Unrecognized node: " << node.to_string() << endl; } } } @@ -501,7 +501,7 @@ Parser::parse_patch( const string node_uri = (*i)["node"].to_string(); const string port_uri = (*i)["port"].to_string(); if (port_uri.length() <= node_uri.length()) { - cerr << "WARNING: Port on " << node_uri << " has bad URI: " << port_uri << endl; + LOG(warn) << "Port on " << node_uri << " has bad URI: " << port_uri << endl; continue; } @@ -565,7 +565,7 @@ Parser::parse_patch( std::pair types_range = i->second.equal_range("rdf:type"); if (types_range.first == i->second.end()) { - cerr << "WARNING: Patch port has no types" << endl; + LOG(warn) << "Patch port has no types" << endl; continue; } bool is_input = false; @@ -581,12 +581,12 @@ Parser::parse_patch( } else if (!type) { type = &t->second; } else { - cerr << "ERROR: Port has several data types" << endl; + LOG(error) << "Port has several data types" << endl; continue; } } if ((is_input && is_output) || !type) { - cerr << "ERROR: Corrupt patch port" << endl; + LOG(error) << "Corrupt patch port" << endl; continue; } @@ -611,7 +611,7 @@ Parser::parse_patch( target->set_property(patch_path, "ingen:enabled", (bool)true); break; } else { - cerr << "WARNING: Unknown type for ingen:enabled" << endl; + LOG(warn) << "Unknown type for ingen:enabled" << endl; } } @@ -637,13 +637,13 @@ Parser::parse_node( Redland::Query::Results results = query.run(*world->rdf_world, model); if (results.size() == 0) { - cerr << "[Parser] ERROR: Node missing mandatory rdf:instanceOf property" << endl; + LOG(error) << "Node missing mandatory rdf:instanceOf property" << endl; return boost::optional(); } const Redland::Node& plugin_node = (*results.begin())["plug"]; if (plugin_node.type() != Redland::Node::RESOURCE) { - cerr << "[Parser] ERROR: node's rdf:instanceOf property is not a resource" << endl; + LOG(error) << "Node's rdf:instanceOf property is not a resource" << endl; return boost::optional(); } @@ -683,7 +683,7 @@ Parser::parse_connections( if (Path::is_valid(src_path) && Path::is_valid(dst_path)) { target->connect(src_path, dst_path); } else { - cerr << "ERROR: Invalid path in connection " + LOG(error) << "Invalid path in connection " << src_path << " => " << dst_path << endl; } } diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 5dd9b045..18a6d9d9 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -21,7 +21,6 @@ #include // atof #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include "raul/log.hpp" #include "raul/Atom.hpp" #include "raul/AtomRDF.hpp" #include "raul/Path.hpp" @@ -46,6 +46,8 @@ #include "interface/Connection.hpp" #include "Serialiser.hpp" +#define LOG(s) s << "[Serialiser] " + using namespace std; using namespace Raul; using namespace Redland; @@ -151,7 +153,7 @@ Serialiser::to_string(SharedPtr object, _model->add_statement(base_rdf_node, v->first.str(), AtomRDF::atom_to_node(_model->world(), v->second)); } else { - cerr << "Warning: not serialising extra RDF with key '" << v->first << "'" << endl; + LOG(warn) << "Not serialising extra RDF with key '" << v->first << "'" << endl; } } @@ -287,7 +289,7 @@ Serialiser::serialise(SharedPtr object) throw (std::logic_error) return; } - cerr << "[Serialiser] WARNING: Unsupported object type, " + LOG(warn) << "Unsupported object type, " << object->path() << " not serialised." << endl; } @@ -313,7 +315,7 @@ Serialiser::serialise_patch(SharedPtr patch, const Redland::Node& _model->add_statement(patch_id, "lv2:symbol", Redland::Literal(_model->world(), patch->path().name())); } else { - cerr << "WARNING: Patch has no lv2:symbol" << endl; + LOG(warn) << "Patch has no lv2:symbol" << endl; } serialise_properties(patch_id, patch->meta().properties()); @@ -449,7 +451,7 @@ Serialiser::serialise_port_meta(const Port* port, const Redland::Node& port_id) _model->add_statement(port_id, "lv2:default", AtomRDF::atom_to_node(_model->world(), Atom(port->value()))); } else if (port->type() == PortType::CONTROL) { - cerr << "WARNING: Port " << port->path() << " has no lv2:default" << endl; + LOG(warn) << "Port " << port->path() << " has no lv2:default" << endl; } } } @@ -498,11 +500,11 @@ Serialiser::serialise_properties( if (value.is_valid()) { _model->add_statement(subject, key, value); } else { - cerr << "WARNING: can not serialise variable '" << v->first << "' :: " + LOG(warn) << "Can not serialise variable '" << v->first << "' :: " << (int)v->second.type() << endl; } } else { - cerr << "WARNING: property '" << v->first << "' has no value" << endl; + LOG(warn) << "Property '" << v->first << "' has no value" << endl; } } } 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 #include +#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 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 #include #include -#include #include #include #include #include #include #include +#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 +#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 -#include #include +#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 -#include #include #include +#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 +#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; } diff --git a/wscript b/wscript index d359c703..e9321373 100644 --- a/wscript +++ b/wscript @@ -22,6 +22,8 @@ def set_options(opt): help="Ingen module install directory [Default: PREFIX/lib/ingen]") opt.add_option('--no-liblo', action='store_true', default=False, dest='no_liblo', help="Do not build OSC via liblo support, even if liblo exists") + opt.add_option('--log-debug', action='store_true', default=False, dest='log_debug', + help="Print debugging output") def configure(conf): autowaf.configure(conf) @@ -64,6 +66,9 @@ def configure(conf): conf.env['DATADIR'], 'ingen')) conf.define('INGEN_MODULE_DIR', os.path.join( conf.env['LIBDIR'], 'ingen')) + + if Options.options.log_debug: + conf.define('LOG_DEBUG', 1) conf.write_config_header('ingen-config.h') -- cgit v1.2.1