From 318b37d8b556add13b3f156f31c9e72eca339a16 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 17 Aug 2012 02:14:07 +0000 Subject: Implement real logging system, LV2 log extension support, and purge evil/ugly/untranslatable C++ stream printing. Remove coloured log stuff from Raul. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4717 a436a847-0d15-0410-975c-d299462d15a1 --- src/client/ClientStore.cpp | 80 +++++++++++++++++++++------------------------- src/client/PatchModel.cpp | 5 --- src/client/PluginUI.cpp | 14 ++++---- 3 files changed, 45 insertions(+), 54 deletions(-) (limited to 'src/client') diff --git a/src/client/ClientStore.cpp b/src/client/ClientStore.cpp index 690bec15..7a6f69c1 100644 --- a/src/client/ClientStore.cpp +++ b/src/client/ClientStore.cpp @@ -14,6 +14,7 @@ along with Ingen. If not, see . */ +#include "ingen/Log.hpp" #include "ingen/client/ClientStore.hpp" #include "ingen/client/EdgeModel.hpp" #include "ingen/client/NodeModel.hpp" @@ -22,9 +23,6 @@ #include "ingen/client/PluginModel.hpp" #include "ingen/client/PortModel.hpp" #include "ingen/client/SigClientInterface.hpp" -#include "raul/log.hpp" - -#define LOG(s) (s("[ClientStore] ")) // #define INGEN_CLIENT_STORE_DUMP 1 @@ -34,9 +32,11 @@ namespace Ingen { namespace Client { ClientStore::ClientStore(URIs& uris, + Log& log, SharedPtr engine, SharedPtr emitter) : _uris(uris) + , _log(log) , _engine(engine) , _emitter(emitter) , _plugins(new Plugins()) @@ -96,12 +96,6 @@ ClientStore::add_object(SharedPtr object) for (Iterator i = object->properties().begin(); i != object->properties().end(); ++i) object->signal_property().emit(i->first, i->second); - - LOG(Raul::debug) << "Added " << object->path() << " {" << endl; - for (iterator i = begin(); i != end(); ++i) { - LOG(Raul::debug) << "\t" << i->first << endl; - } - LOG(Raul::debug) << "}" << endl; } SharedPtr @@ -222,11 +216,11 @@ ClientStore::put(const Raul::URI& uri, { typedef Resource::Properties::const_iterator Iterator; #ifdef INGEN_CLIENT_STORE_DUMP - LOG(Raul::info) << "PUT " << uri << " {" << endl; + std::cerr << "Put " << uri << " {" << endl; for (Iterator i = properties.begin(); i != properties.end(); ++i) - LOG(Raul::info) << '\t' << i->first << " = " << _uris.forge.str(i->second) + std::cerr << '\t' << i->first << " = " << _uris.forge.str(i->second) << " :: " << i->second.type() << endl; - LOG(Raul::info) << "}" << endl; + std::cerr << "}" << endl; #endif bool is_patch, is_node, is_port, is_output; @@ -250,8 +244,8 @@ ClientStore::put(const Raul::URI& uri, } if (!GraphObject::uri_is_path(uri)) { - LOG(Raul::error)(Raul::fmt("Put for unknown subject <%1%>\n") - % uri.c_str()); + _log.error(Raul::fmt("Put for unknown subject <%1%>\n") + % uri.c_str()); return; } @@ -276,8 +270,8 @@ ClientStore::put(const Raul::URI& uri, SharedPtr plug; if (p->second.is_valid() && p->second.type() == _uris.forge.URI) { if (!(plug = _plugin(Raul::URI(p->second.get_uri())))) { - LOG(Raul::warn)(Raul::fmt("Unable to find plugin <%1%>\n") - % p->second.get_uri()); + _log.warn(Raul::fmt("Unable to find plugin <%1%>\n") + % p->second.get_uri()); plug = SharedPtr( new PluginModel(uris(), Raul::URI(p->second.get_uri()), @@ -290,8 +284,8 @@ ClientStore::put(const Raul::URI& uri, n->set_properties(properties); add_object(n); } else { - LOG(Raul::warn)(Raul::fmt("Node %1% has no plugin\n") - % path.c_str()); + _log.warn(Raul::fmt("Node %1% has no plugin\n") + % path.c_str()); } } else if (is_port) { PortModel::Direction pdir = (is_output) @@ -305,11 +299,11 @@ ClientStore::put(const Raul::URI& uri, p->set_properties(properties); add_object(p); } else { - LOG(Raul::error) << "Port " << path << " has no index" << endl; + _log.error(Raul::fmt("Port %1% has no index\n") % path); } } else { - LOG(Raul::warn)(Raul::fmt("Ignoring object %1% with unknown type\n") - % path.c_str()); + _log.warn(Raul::fmt("Ignoring object %1% with unknown type\n") + % path.c_str()); } } @@ -320,21 +314,21 @@ ClientStore::delta(const Raul::URI& uri, { typedef Resource::Properties::const_iterator iterator; #ifdef INGEN_CLIENT_STORE_DUMP - LOG(Raul::info) << "DELTA " << uri << " {" << endl; + std::cerr << "Delta " << uri << " {" << endl; for (iterator i = remove.begin(); i != remove.end(); ++i) - LOG(Raul::info) << " - " << i->first - << " = " << _uris.forge.str(i->second) - << " :: " << i->second.type() << endl; + std::cerr << " - " << i->first + << " = " << _uris.forge.str(i->second) + << " :: " << i->second.type() << endl; for (iterator i = add.begin(); i != add.end(); ++i) - LOG(Raul::info) << " + " << i->first - << " = " << _uris.forge.str(i->second) - << " :: " << i->second.type() << endl; - LOG(Raul::info) << "}" << endl; + std::cerr << " + " << i->first + << " = " << _uris.forge.str(i->second) + << " :: " << i->second.type() << endl; + std::cerr << "}" << endl; #endif if (!GraphObject::uri_is_path(uri)) { - LOG(Raul::error)(Raul::fmt("Delta for unknown subject <%1%>\n") - % uri.c_str()); + _log.error(Raul::fmt("Delta for unknown subject <%1%>\n") + % uri.c_str()); return; } @@ -345,8 +339,8 @@ ClientStore::delta(const Raul::URI& uri, obj->remove_properties(remove); obj->add_properties(add); } else { - LOG(Raul::warn)(Raul::fmt("Failed to find object `%1%'\n") - % path.c_str()); + _log.warn(Raul::fmt("Failed to find object `%1%'\n") + % path.c_str()); } } @@ -356,8 +350,8 @@ ClientStore::set_property(const Raul::URI& subject_uri, const Raul::Atom& value) { if (subject_uri == _uris.ingen_engine) { - LOG(Raul::info)(Raul::fmt("Engine property <%1%> = %2%\n") - % predicate.c_str() % _uris.forge.str(value)); + _log.info(Raul::fmt("Engine property <%1%> = %2%\n") + % predicate.c_str() % _uris.forge.str(value)); return; } SharedPtr subject = _resource(subject_uri); @@ -374,8 +368,8 @@ ClientStore::set_property(const Raul::URI& subject_uri, if (plugin) plugin->set_property(predicate, value); else - LOG(Raul::warn)(Raul::fmt("Property <%1%> for unknown object %2%\n") - % predicate.c_str() % subject_uri.c_str()); + _log.warn(Raul::fmt("Property <%1%> for unknown object %2%\n") + % predicate.c_str() % subject_uri.c_str()); } } @@ -398,8 +392,8 @@ ClientStore::connection_patch(const Raul::Path& tail_path, patch = PtrCast(_object(tail_path.parent().parent())); if (!patch) - LOG(Raul::error) << "Unable to find connection patch " << tail_path - << " -> " << head_path << endl; + _log.error(Raul::fmt("Unable to find path for edge %1% => %2%\n") + % tail_path % head_path); return patch; } @@ -421,8 +415,8 @@ ClientStore::attempt_connection(const Raul::Path& tail_path, patch->add_edge(cm); return true; } else { - LOG(Raul::warn) << "Failed to connect " << tail_path - << " => " << head_path << std::endl; + _log.warn(Raul::fmt("Failed to connect %1% => %2%\n") + % tail_path % head_path); return false; } } @@ -460,8 +454,8 @@ ClientStore::disconnect_all(const Raul::Path& parent_patch, SharedPtr object = _object(path); if (!patch || !object) { - LOG(Raul::error) << "Bad disconnect all notification " << path - << " in " << parent_patch << std::endl; + _log.error(Raul::fmt("Bad disconnect all notification %1% in %2%\n") + % path % parent_patch); return; } diff --git a/src/client/PatchModel.cpp b/src/client/PatchModel.cpp index e87d8168..72c17009 100644 --- a/src/client/PatchModel.cpp +++ b/src/client/PatchModel.cpp @@ -16,8 +16,6 @@ #include -#include "raul/log.hpp" - #include "ingen/client/ClientStore.hpp" #include "ingen/client/EdgeModel.hpp" #include "ingen/client/NodeModel.hpp" @@ -145,9 +143,6 @@ PatchModel::remove_edge(const GraphObject* tail, const GraphObject* head) SharedPtr c = PtrCast(i->second); _signal_removed_edge.emit(c); _edges.erase(i); - } else { - Raul::warn(Raul::fmt("Failed to remove patch connection %1% => %2%\n") - % tail->path().c_str() % head->path().c_str()); } } diff --git a/src/client/PluginUI.cpp b/src/client/PluginUI.cpp index 5706c61c..2a63296a 100644 --- a/src/client/PluginUI.cpp +++ b/src/client/PluginUI.cpp @@ -15,13 +15,13 @@ */ #include "ingen/Interface.hpp" +#include "ingen/Log.hpp" #include "ingen/URIs.hpp" #include "ingen/client/NodeModel.hpp" #include "ingen/client/PluginUI.hpp" #include "ingen/client/PortModel.hpp" #include "lv2/lv2plug.in/ns/ext/atom/atom.h" #include "lv2/lv2plug.in/ns/extensions/ui/ui.h" -#include "raul/log.hpp" using namespace std; @@ -41,8 +41,9 @@ lv2_ui_write(SuilController controller, const NodeModel::Ports& ports = ui->node()->ports(); if (port_index >= ports.size()) { - Raul::error(Raul::fmt("%1% UI tried to write to invalid port %2%\n") - % ui->node()->plugin()->uri().c_str() % port_index); + ui->world()->log().error( + Raul::fmt("%1% UI tried to write to invalid port %2%\n") + % ui->node()->plugin()->uri().c_str() % port_index); return; } @@ -70,8 +71,9 @@ lv2_ui_write(SuilController controller, val); } else { - Raul::warn(Raul::fmt("Unknown value format %1% from LV2 UI\n") - % format % ui->node()->plugin()->uri().c_str()); + ui->world()->log().warn( + Raul::fmt("Unknown value format %1% from LV2 UI\n") + % format % ui->node()->plugin()->uri().c_str()); } } @@ -144,7 +146,7 @@ PluginUI::create(Ingen::World* world, if (instance) { ret->_instance = instance; } else { - Raul::error("Failed to instantiate LV2 UI\n"); + world->log().error("Failed to instantiate LV2 UI\n"); ret.reset(); } -- cgit v1.2.1