summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-17 02:14:07 +0000
committerDavid Robillard <d@drobilla.net>2012-08-17 02:14:07 +0000
commit318b37d8b556add13b3f156f31c9e72eca339a16 (patch)
treeca7b881f8980a41eca77602b474f29964b5c89db
parenta42744e1068a8630d8034df73bb344ca21a53b32 (diff)
downloadingen-318b37d8b556add13b3f156f31c9e72eca339a16.tar.gz
ingen-318b37d8b556add13b3f156f31c9e72eca339a16.tar.bz2
ingen-318b37d8b556add13b3f156f31c9e72eca339a16.zip
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
-rw-r--r--ingen/AtomReader.hpp8
-rw-r--r--ingen/Log.hpp48
-rw-r--r--ingen/Resource.hpp2
-rw-r--r--ingen/URIMap.hpp8
-rw-r--r--ingen/URIs.hpp3
-rw-r--r--ingen/World.hpp8
-rw-r--r--ingen/client/ClientStore.hpp6
-rw-r--r--ingen/client/PortModel.hpp1
-rw-r--r--ingen/client/ThreadedSigClientInterface.hpp2
-rw-r--r--src/AtomReader.cpp54
-rw-r--r--src/ClashAvoider.cpp15
-rw-r--r--src/Log.cpp68
-rw-r--r--src/Resource.cpp4
-rw-r--r--src/Store.cpp3
-rw-r--r--src/URIMap.cpp11
-rw-r--r--src/URIs.cpp4
-rw-r--r--src/World.cpp44
-rw-r--r--src/bindings/ingen_bindings.cpp1
-rw-r--r--src/client/ClientStore.cpp80
-rw-r--r--src/client/PatchModel.cpp5
-rw-r--r--src/client/PluginUI.cpp14
-rw-r--r--src/gui/App.cpp16
-rw-r--r--src/gui/App.hpp2
-rw-r--r--src/gui/Configuration.cpp4
-rw-r--r--src/gui/ConnectWindow.cpp10
-rw-r--r--src/gui/NodeMenu.cpp7
-rw-r--r--src/gui/NodeModule.cpp13
-rw-r--r--src/gui/PatchCanvas.cpp31
-rw-r--r--src/gui/PatchTreeWindow.cpp23
-rw-r--r--src/gui/PatchTreeWindow.hpp2
-rw-r--r--src/gui/PatchView.cpp11
-rw-r--r--src/gui/Port.cpp4
-rw-r--r--src/gui/PropertiesWindow.cpp21
-rw-r--r--src/gui/RenameWindow.cpp1
-rw-r--r--src/gui/ThreadedLoader.cpp9
-rw-r--r--src/gui/WidgetFactory.cpp23
-rw-r--r--src/gui/ingen_gui_lv2.cpp10
-rw-r--r--src/ingen/main.cpp5
-rw-r--r--src/runtime_paths.cpp4
-rw-r--r--src/serialisation/Parser.cpp58
-rw-r--r--src/serialisation/Serialiser.cpp16
-rw-r--r--src/server/Broadcaster.cpp9
-rw-r--r--src/server/Buffer.cpp12
-rw-r--r--src/server/BufferFactory.cpp4
-rw-r--r--src/server/Context.cpp14
-rw-r--r--src/server/ControlBindings.cpp18
-rw-r--r--src/server/EdgeImpl.cpp1
-rw-r--r--src/server/EdgeImpl.hpp1
-rw-r--r--src/server/Engine.cpp5
-rw-r--r--src/server/Engine.hpp5
-rw-r--r--src/server/EventWriter.cpp2
-rw-r--r--src/server/GraphObjectImpl.cpp2
-rw-r--r--src/server/InputPort.cpp7
-rw-r--r--src/server/JackDriver.cpp30
-rw-r--r--src/server/LV2Node.cpp32
-rw-r--r--src/server/LV2ResizeFeature.hpp1
-rw-r--r--src/server/NodeFactory.cpp5
-rw-r--r--src/server/PatchImpl.cpp8
-rw-r--r--src/server/Worker.cpp18
-rw-r--r--src/server/Worker.hpp6
-rw-r--r--src/server/events/Delta.cpp22
-rw-r--r--src/server/events/Disconnect.cpp1
-rw-r--r--src/server/events/SetPortValue.cpp1
-rw-r--r--src/server/ingen_engine.cpp2
-rw-r--r--src/server/ingen_jack.cpp4
-rw-r--r--src/server/ingen_lv2.cpp83
-rw-r--r--src/server/internals/Delay.cpp3
-rw-r--r--src/server/internals/Note.cpp37
-rw-r--r--src/server/internals/Trigger.cpp7
-rw-r--r--src/server/mix.cpp2
-rw-r--r--src/server/util.hpp39
-rw-r--r--src/socket/Socket.cpp14
-rw-r--r--src/socket/SocketListener.cpp13
-rw-r--r--src/socket/SocketReader.cpp20
-rw-r--r--src/socket/ingen_socket_client.cpp6
-rw-r--r--src/socket/ingen_socket_server.cpp2
-rw-r--r--src/wscript1
-rw-r--r--wscript5
78 files changed, 544 insertions, 557 deletions
diff --git a/ingen/AtomReader.hpp b/ingen/AtomReader.hpp
index 579dc0ea..8a821194 100644
--- a/ingen/AtomReader.hpp
+++ b/ingen/AtomReader.hpp
@@ -28,6 +28,7 @@ namespace Ingen {
class AtomSink;
class Forge;
+class Log;
class URIMap;
/** An AtomSink that calls methods on an Interface.
@@ -36,7 +37,11 @@ class URIMap;
class AtomReader : public AtomSink
{
public:
- AtomReader(URIMap& map, URIs& uris, Forge& forge, Interface& iface);
+ AtomReader(URIMap& map,
+ URIs& uris,
+ Log& log,
+ Forge& forge,
+ Interface& iface);
~AtomReader() {}
static bool is_message(URIs& uris, const LV2_Atom* msg);
@@ -54,6 +59,7 @@ private:
URIMap& _map;
URIs& _uris;
+ Log& _log;
Forge& _forge;
Interface& _iface;
};
diff --git a/ingen/Log.hpp b/ingen/Log.hpp
new file mode 100644
index 00000000..750d6ec3
--- /dev/null
+++ b/ingen/Log.hpp
@@ -0,0 +1,48 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2012 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_LOG_HPP
+#define INGEN_LOG_HPP
+
+#include <string>
+
+#include "lv2/lv2plug.in/ns/ext/log/log.h"
+#include "raul/fmt.hpp"
+
+namespace Ingen {
+
+class URIs;
+
+class Log {
+public:
+ Log(LV2_Log_Log* log, URIs& uris);
+
+ void error(const std::string& msg);
+ void info(const std::string& msg);
+ void warn(const std::string& msg);
+
+ inline void error(const Raul::fmt& fmt) { error(fmt.str()); }
+ inline void info(const Raul::fmt& fmt) { info(fmt.str()); }
+ inline void warn(const Raul::fmt& fmt) { warn(fmt.str()); }
+
+private:
+ LV2_Log_Log* _log;
+ URIs& _uris;
+};
+
+} // namespace Ingen
+
+#endif // INGEN_LOG_HPP
diff --git a/ingen/Resource.hpp b/ingen/Resource.hpp
index 92f253cd..028579fb 100644
--- a/ingen/Resource.hpp
+++ b/ingen/Resource.hpp
@@ -24,7 +24,6 @@
#include "raul/Atom.hpp"
#include "raul/Deletable.hpp"
#include "raul/URI.hpp"
-#include "raul/log.hpp"
#define NS_INGEN "http://drobilla.net/ns/ingen#"
@@ -66,7 +65,6 @@ public:
} else if (!strcmp(suffix, "internalContext")) {
return INTERNAL;
} else {
- Raul::error << "Unknown context URI " << uri << std::endl;
return DEFAULT;
}
}
diff --git a/ingen/URIMap.hpp b/ingen/URIMap.hpp
index c46f4197..d519b564 100644
--- a/ingen/URIMap.hpp
+++ b/ingen/URIMap.hpp
@@ -21,9 +21,10 @@
#include <utility>
#include "ingen/LV2Features.hpp"
+#include "ingen/Log.hpp"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
-#include "raul/URI.hpp"
#include "raul/Noncopyable.hpp"
+#include "raul/URI.hpp"
namespace Ingen {
@@ -32,7 +33,7 @@ namespace Ingen {
*/
class URIMap : public Raul::Noncopyable {
public:
- URIMap(LV2_URID_Map* map, LV2_URID_Unmap* unmap);
+ URIMap(Log& log, LV2_URID_Map* map, LV2_URID_Unmap* unmap);
virtual ~URIMap() {}
uint32_t map_uri(const char* uri);
@@ -54,10 +55,11 @@ public:
};
struct URIDMapFeature : public Feature {
- URIDMapFeature(URIMap* map, LV2_URID_Map* urid_map);
+ URIDMapFeature(URIMap* map, LV2_URID_Map* urid_map, Log& log);
LV2_URID map(const char* uri);
static LV2_URID default_map(LV2_URID_Map_Handle h, const char* uri);
LV2_URID_Map urid_map;
+ Log& log;
};
struct URIDUnmapFeature : public Feature {
diff --git a/ingen/URIs.hpp b/ingen/URIs.hpp
index ace1652b..174e5e9e 100644
--- a/ingen/URIs.hpp
+++ b/ingen/URIs.hpp
@@ -94,6 +94,9 @@ public:
const Quark ingen_tail;
const Quark ingen_uiEmbedded;
const Quark ingen_value;
+ const Quark log_Error;
+ const Quark log_Note;
+ const Quark log_Warning;
const Quark lv2_AudioPort;
const Quark lv2_CVPort;
const Quark lv2_ControlPort;
diff --git a/ingen/World.hpp b/ingen/World.hpp
index 68ecd843..e00b23fe 100644
--- a/ingen/World.hpp
+++ b/ingen/World.hpp
@@ -20,6 +20,7 @@
#include <string>
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
+#include "lv2/lv2plug.in/ns/ext/log/log.h"
#include "raul/Noncopyable.hpp"
#include "raul/SharedPtr.hpp"
#include "raul/URI.hpp"
@@ -32,6 +33,7 @@ namespace Ingen {
class EngineBase;
class Interface;
+class Log;
namespace Serialisation {
class Parser;
@@ -70,11 +72,13 @@ public:
* @param argv Argument vector (as in C main())
* @param map LV2 URID map implementation, or NULL to use internal.
* @param unmap LV2 URID unmap implementation, or NULL to use internal.
+ * @param log LV2 log implementation, or NULL to use internal.
*/
World(int& argc,
char**& argv,
LV2_URID_Map* map,
- LV2_URID_Unmap* unmap);
+ LV2_URID_Unmap* unmap,
+ LV2_Log_Log* log);
virtual ~World();
@@ -141,6 +145,8 @@ public:
virtual void set_jack_uuid(const std::string& uuid);
virtual std::string jack_uuid();
+ virtual Log& log();
+
private:
class Impl;
diff --git a/ingen/client/ClientStore.hpp b/ingen/client/ClientStore.hpp
index cfa9df12..42519158 100644
--- a/ingen/client/ClientStore.hpp
+++ b/ingen/client/ClientStore.hpp
@@ -31,9 +31,9 @@ namespace Raul { class Atom; }
namespace Ingen {
-class URIs;
-
class GraphObject;
+class Log;
+class URIs;
namespace Client {
@@ -54,6 +54,7 @@ class ClientStore : public Store
public:
ClientStore(
URIs& uris,
+ Log& log,
SharedPtr<Interface> engine = SharedPtr<Interface>(),
SharedPtr<SigClientInterface> emitter = SharedPtr<SigClientInterface>());
@@ -127,6 +128,7 @@ private:
const Raul::Path& head_path);
URIs& _uris;
+ Log& _log;
SharedPtr<Interface> _engine;
SharedPtr<SigClientInterface> _emitter;
diff --git a/ingen/client/PortModel.hpp b/ingen/client/PortModel.hpp
index a59de578..bfc56a9d 100644
--- a/ingen/client/PortModel.hpp
+++ b/ingen/client/PortModel.hpp
@@ -21,7 +21,6 @@
#include <string>
#include "raul/SharedPtr.hpp"
-#include "raul/log.hpp"
#include "lv2/lv2plug.in/ns/ext/port-props/port-props.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
diff --git a/ingen/client/ThreadedSigClientInterface.hpp b/ingen/client/ThreadedSigClientInterface.hpp
index a6028cc6..633bd265 100644
--- a/ingen/client/ThreadedSigClientInterface.hpp
+++ b/ingen/client/ThreadedSigClientInterface.hpp
@@ -133,11 +133,9 @@ private:
while (!success) {
success = _sigs.push(ev);
if (!success) {
- Raul::warn << "Client event queue full. Waiting..." << std::endl;
_mutex.lock();
_cond.wait(_mutex);
_mutex.unlock();
- Raul::warn << "Queue drained, continuing" << std::endl;
}
}
}
diff --git a/src/AtomReader.cpp b/src/AtomReader.cpp
index 045660db..712f8dd2 100644
--- a/src/AtomReader.cpp
+++ b/src/AtomReader.cpp
@@ -18,16 +18,21 @@
#include "ingen/AtomReader.hpp"
#include "ingen/GraphObject.hpp"
+#include "ingen/Log.hpp"
#include "ingen/URIMap.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "raul/Path.hpp"
-#include "raul/log.hpp"
namespace Ingen {
-AtomReader::AtomReader(URIMap& map, URIs& uris, Forge& forge, Interface& iface)
+AtomReader::AtomReader(URIMap& map,
+ URIs& uris,
+ Log& log,
+ Forge& forge,
+ Interface& iface)
: _map(map)
, _uris(uris)
+ , _log(log)
, _forge(forge)
, _iface(iface)
{
@@ -43,8 +48,8 @@ AtomReader::get_atom(const LV2_Atom* in, Raul::Atom& out)
if (uri) {
out = _forge.alloc_uri(_map.unmap_uri(urid->body));
} else {
- Raul::error(Raul::fmt("Unable to unmap URID %1%\n")
- % urid->body);
+ _log.error(Raul::fmt("Unable to unmap URID %1%\n")
+ % urid->body);
}
} else {
out = _forge.alloc(in->size, in->type, LV2_ATOM_BODY_CONST(in));
@@ -111,8 +116,8 @@ bool
AtomReader::write(const LV2_Atom* msg)
{
if (msg->type != _uris.atom_Blank && msg->type != _uris.atom_Resource) {
- Raul::warn(Raul::fmt("Unknown message type <%1%>\n")
- % _map.unmap_uri(msg->type));
+ _log.warn(Raul::fmt("Unknown message type <%1%>\n")
+ % _map.unmap_uri(msg->type));
return false;
}
@@ -151,7 +156,7 @@ AtomReader::write(const LV2_Atom* msg)
} else if (subject_path && other_path) {
_iface.disconnect_all(*subject_path, *other_path);
} else {
- Raul::warn << "Delete of unknown object." << std::endl;
+ _log.warn("Delete of unknown object\n");
return false;
}
}
@@ -159,10 +164,10 @@ AtomReader::write(const LV2_Atom* msg)
const LV2_Atom_Object* body = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
if (!body) {
- Raul::warn << "Put message has no body" << std::endl;
+ _log.warn("Put message has no body\n");
return false;
} else if (!subject_uri) {
- Raul::warn << "Put message has no subject" << std::endl;
+ _log.warn("Put message has no subject\n");
return false;
}
@@ -174,7 +179,7 @@ AtomReader::write(const LV2_Atom* msg)
(LV2_URID)_uris.ingen_head, &head,
NULL);
if (!tail || !head) {
- Raul::warn << "Edge has no tail or head" << std::endl;
+ _log.warn("Edge has no tail or head\n");
return false;
}
@@ -183,7 +188,7 @@ AtomReader::write(const LV2_Atom* msg)
if (tail_path && head_path) {
_iface.connect(*tail_path, *head_path);
} else {
- Raul::warn << "Edge has non-path tail or head" << std::endl;
+ _log.warn("Edge has non-path tail or head\n");
}
} else {
Ingen::Resource::Properties props;
@@ -195,10 +200,10 @@ AtomReader::write(const LV2_Atom* msg)
const LV2_Atom_Object* body = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_body, &body, 0);
if (!body) {
- Raul::warn << "Set message has no body" << std::endl;
+ _log.warn("Set message has no body\n");
return false;
} else if (!subject_uri) {
- Raul::warn << "Set message has no subject" << std::endl;
+ _log.warn("Set message has no subject\n");
return false;
}
@@ -210,21 +215,21 @@ AtomReader::write(const LV2_Atom* msg)
}
} else if (obj->body.otype == _uris.patch_Patch) {
if (!subject) {
- Raul::warn << "Patch message has no subject" << std::endl;
+ _log.warn("Patch message has no subject\n");
return false;
}
const LV2_Atom_Object* remove = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_remove, &remove, 0);
if (!remove) {
- Raul::warn << "Patch message has no remove" << std::endl;
+ _log.warn("Patch message has no remove\n");
return false;
}
const LV2_Atom_Object* add = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_add, &add, 0);
if (!add) {
- Raul::warn << "Patch message has no add" << std::endl;
+ _log.warn("Patch message has no add\n");
return false;
}
@@ -237,26 +242,26 @@ AtomReader::write(const LV2_Atom* msg)
_iface.delta(Raul::URI(subject_uri), remove_props, add_props);
} else if (obj->body.otype == _uris.patch_Move) {
if (!subject) {
- Raul::warn << "Move message has no subject" << std::endl;
+ _log.warn("Move message has no subject\n");
return false;
}
const LV2_Atom* dest = NULL;
lv2_atom_object_get(obj, (LV2_URID)_uris.patch_destination, &dest, 0);
if (!dest) {
- Raul::warn << "Move message has no destination" << std::endl;
+ _log.warn("Move message has no destination\n");
return false;
}
boost::optional<Raul::Path> subject_path(atom_to_path(subject));
if (!subject_path) {
- Raul::warn << "Move message has non-path subject" << std::endl;
+ _log.warn("Move message has non-path subject\n");
return false;
}
boost::optional<Raul::Path> dest_path(atom_to_path(dest));
if (!dest_path) {
- Raul::warn << "Move message has non-path destination" << std::endl;
+ _log.warn("Move message has non-path destination\n");
return false;
}
@@ -269,19 +274,18 @@ AtomReader::write(const LV2_Atom* msg)
(LV2_URID)_uris.patch_body, &body,
0);
if (!request || request->type != _uris.atom_Int) {
- Raul::warn << "Response message has no request" << std::endl;
+ _log.warn("Response message has no request\n");
return false;
} else if (!body || body->type != _uris.atom_Int) {
- Raul::warn << "Response message body is not integer" << std::endl;
+ _log.warn("Response message body is not integer\n");
return false;
}
_iface.response(((const LV2_Atom_Int*)request)->body,
(Ingen::Status)((const LV2_Atom_Int*)body)->body,
subject_uri ? subject_uri : "");
} else {
- Raul::warn << "Unknown object type <"
- << _map.unmap_uri(obj->body.otype)
- << ">" << std::endl;
+ _log.warn(Raul::fmt("Unknown object type <%1%>\n")
+ % _map.unmap_uri(obj->body.otype));
}
return true;
diff --git a/src/ClashAvoider.cpp b/src/ClashAvoider.cpp
index 7af132f5..13afc283 100644
--- a/src/ClashAvoider.cpp
+++ b/src/ClashAvoider.cpp
@@ -19,8 +19,6 @@
#include <string>
#include <utility>
-#include "raul/log.hpp"
-
#include "ingen/ClashAvoider.hpp"
#include "ingen/Store.hpp"
@@ -41,8 +39,6 @@ ClashAvoider::map_uri(const Raul::URI& in)
const Raul::Path
ClashAvoider::map_path(const Raul::Path& in)
{
- Raul::debug << "MAP PATH: " << in;
-
unsigned offset = 0;
bool has_offset = false;
const size_t pos = in.find_last_of('_');
@@ -51,8 +47,6 @@ ClashAvoider::map_path(const Raul::Path& in)
has_offset = (sscanf(trailing.c_str(), "%u", &offset) > 0);
}
- Raul::debug << "OFFSET: " << offset << endl;
-
// Path without _n suffix
std::string base_path_str = in;
if (has_offset) {
@@ -60,11 +54,9 @@ ClashAvoider::map_path(const Raul::Path& in)
}
Raul::Path base_path(base_path_str);
- Raul::debug << "BASE: " << base_path << endl;
SymbolMap::iterator m = _symbol_map.find(in);
if (m != _symbol_map.end()) {
- Raul::debug << " (1) " << m->second << endl;
return m->second;
} else {
typedef std::pair<SymbolMap::iterator, bool> InsertRecord;
@@ -72,13 +64,11 @@ ClashAvoider::map_path(const Raul::Path& in)
// See if parent is mapped
Raul::Path parent = in.parent();
do {
- Raul::debug << "CHECK: " << parent << endl;
SymbolMap::iterator p = _symbol_map.find(parent);
if (p != _symbol_map.end()) {
const Raul::Path mapped = Raul::Path(
p->second.base() + in.substr(parent.base().length()));
InsertRecord i = _symbol_map.insert(make_pair(in, mapped));
- Raul::debug << " (2) " << i.first->second << endl;
return i.first->second;
}
parent = parent.parent();
@@ -88,7 +78,6 @@ 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);
- Raul::debug << " (3) " << i.first->second << endl;
return i.first->second;
// Append _2 _3 etc until an unused symbol is found
@@ -102,7 +91,6 @@ ClashAvoider::map_path(const Raul::Path& in)
parent_str = parent_str.substr(0, parent_str.find_last_of("/"));
if (parent_str.empty())
parent_str = "/";
- Raul::debug << "PARENT: " << parent_str << endl;
}
if (offset == 0)
@@ -117,13 +105,10 @@ ClashAvoider::map_path(const Raul::Path& in)
Raul::Symbol sym(name);
string str = ss.str();
InsertRecord i = _symbol_map.insert(make_pair(in, str));
- Raul::debug << "HIT: offset = " << offset << ", str = " << str << endl;
offset = _store.child_name_offset(in.parent(), sym, false);
_offsets.insert(make_pair(base_path, offset));
- Raul::debug << " (4) " << i.first->second << endl;
return i.first->second;
} else {
- Raul::debug << "MISSED OFFSET: " << in << " => " << ss.str() << endl;
if (o != _offsets.end())
offset = ++o->second;
else
diff --git a/src/Log.cpp b/src/Log.cpp
new file mode 100644
index 00000000..402e4609
--- /dev/null
+++ b/src/Log.cpp
@@ -0,0 +1,68 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2012 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include <iostream>
+
+#include "ingen/Log.hpp"
+#include "ingen/URIs.hpp"
+
+namespace Ingen {
+
+static const char* const ANSI_RESET = "\033[0m";
+static const char* const ANSI_RED = "\033[0;31m";
+static const char* const ANSI_GREEN = "\033[0;32m";
+static const char* const ANSI_YELLOW = "\033[0;33m";
+static const char* const ANSI_BLUE = "\033[0;34m";
+static const char* const ANSI_MAGENTA = "\033[0;35m";
+static const char* const ANSI_CYAN = "\033[0;36m";
+static const char* const ANSI_WHITE = "\033[0;37m";
+
+Log::Log(LV2_Log_Log* log, URIs& uris)
+ : _log(log)
+ , _uris(uris)
+{}
+
+void
+Log::error(const std::string& msg)
+{
+ if (_log) {
+ _log->printf(_log->handle, _uris.log_Error, msg.c_str());
+ } else {
+ std::cerr << ANSI_RED << msg << ANSI_RESET;
+ }
+}
+
+void
+Log::warn(const std::string& msg)
+{
+ if (_log) {
+ _log->printf(_log->handle, _uris.log_Warning, msg.c_str());
+ } else {
+ std::cerr << ANSI_YELLOW << msg << ANSI_RESET;
+ }
+}
+
+void
+Log::info(const std::string& msg)
+{
+ if (_log) {
+ _log->printf(_log->handle, _uris.log_Note, msg.c_str());
+ } else {
+ std::cout << msg;
+ }
+}
+
+} // namespace Ingen
diff --git a/src/Resource.cpp b/src/Resource.cpp
index e7271634..60e79642 100644
--- a/src/Resource.cpp
+++ b/src/Resource.cpp
@@ -19,7 +19,6 @@
#include "ingen/Resource.hpp"
#include "ingen/URIs.hpp"
#include "raul/Atom.hpp"
-#include "raul/log.hpp"
using namespace std;
@@ -123,8 +122,7 @@ Resource::type(const URIs& uris,
for (iterator i = types_range.first; i != types_range.second; ++i) {
const Raul::Atom& atom = i->second;
if (atom.type() != uris.forge.URI && atom.type() != uris.forge.URID) {
- Raul::warn << "[Resource] Non-URI type " << uris.forge.str(atom) << endl;
- continue;
+ continue; // Non-URI type, ignore garbage data
}
if (atom == uris.ingen_Patch) {
diff --git a/src/Store.cpp b/src/Store.cpp
index 47a9e1a6..ae40bcc5 100644
--- a/src/Store.cpp
+++ b/src/Store.cpp
@@ -17,7 +17,6 @@
#include <sstream>
#include "ingen/Store.hpp"
-#include "raul/log.hpp"
using namespace std;
@@ -27,8 +26,6 @@ void
Store::add(GraphObject* o)
{
if (find(o->path()) != end()) {
- Raul::error << "[Store] Attempt to add duplicate object "
- << o->path() << endl;
return;
}
diff --git a/src/URIMap.cpp b/src/URIMap.cpp
index 3d55046f..3344b1d0 100644
--- a/src/URIMap.cpp
+++ b/src/URIMap.cpp
@@ -18,22 +18,23 @@
#include <glib.h>
-#include "raul/log.hpp"
#include "ingen/URIMap.hpp"
using namespace std;
namespace Ingen {
-URIMap::URIMap(LV2_URID_Map* map, LV2_URID_Unmap* unmap)
- : _urid_map_feature(new URIDMapFeature(this, map))
+URIMap::URIMap(Log& log, LV2_URID_Map* map, LV2_URID_Unmap* unmap)
+ : _urid_map_feature(new URIDMapFeature(this, map, log))
, _urid_unmap_feature(new URIDUnmapFeature(this, unmap))
{
}
URIMap::URIDMapFeature::URIDMapFeature(URIMap* map,
- LV2_URID_Map* impl)
+ LV2_URID_Map* impl,
+ Log& alog)
: Feature(LV2_URID__map, &urid_map)
+ , log(alog)
{
if (impl) {
urid_map = *impl;
@@ -54,7 +55,7 @@ LV2_URID
URIMap::URIDMapFeature::map(const char* uri)
{
if (!Raul::URI::is_valid(uri)) {
- Raul::warn(Raul::fmt("Attempt to map invalid URI <%1%>\n") % uri);
+ log.error(Raul::fmt("Attempt to map invalid URI <%1%>\n") % uri);
return 0;
}
return urid_map.map(urid_map.handle, uri);
diff --git a/src/URIs.cpp b/src/URIs.cpp
index f3e5c67d..c5564aa7 100644
--- a/src/URIs.cpp
+++ b/src/URIs.cpp
@@ -17,6 +17,7 @@
#include "ingen/URIMap.hpp"
#include "ingen/URIs.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
+#include "lv2/lv2plug.in/ns/ext/log/log.h"
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "lv2/lv2plug.in/ns/ext/patch/patch.h"
#include "lv2/lv2plug.in/ns/ext/port-props/port-props.h"
@@ -78,6 +79,9 @@ URIs::URIs(Forge& f, URIMap* map)
, ingen_tail (forge, map, NS_INGEN "tail")
, ingen_uiEmbedded (forge, map, NS_INGEN "uiEmbedded")
, ingen_value (forge, map, NS_INGEN "value")
+ , log_Error (forge, map, LV2_LOG__Error)
+ , log_Note (forge, map, LV2_LOG__Note)
+ , log_Warning (forge, map, LV2_LOG__Warning)
, lv2_AudioPort (forge, map, LV2_CORE__AudioPort)
, lv2_CVPort (forge, map, LV2_CORE__CVPort)
, lv2_ControlPort (forge, map, LV2_CORE__ControlPort)
diff --git a/src/World.cpp b/src/World.cpp
index 1477544b..fa2ae1ed 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -23,17 +23,15 @@
#include "ingen/Configuration.hpp"
#include "ingen/LV2Features.hpp"
+#include "ingen/Log.hpp"
#include "ingen/Module.hpp"
#include "ingen/URIMap.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
#include "ingen/runtime_paths.hpp"
#include "lilv/lilv.h"
-#include "raul/log.hpp"
#include "sord/sordmm.hpp"
-#define LOG(s) (s("[World] "))
-
using namespace std;
namespace Ingen {
@@ -54,7 +52,7 @@ namespace Serialisation { class Parser; class Serialiser; }
* \param name The base name of the module, e.g. "ingen_serialisation"
*/
static Glib::Module*
-ingen_load_module(const string& name)
+ingen_load_module(Log& log, const string& name)
{
Glib::Module* module = NULL;
@@ -69,10 +67,9 @@ ingen_load_module(const string& name)
if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) {
module = new Glib::Module(filename);
if (*module) {
- LOG(Raul::info)(Raul::fmt("Loading %1%\n") % filename);
return module;
} else {
- Raul::error << Glib::Module::get_last_error() << endl;
+ log.error(Glib::Module::get_last_error());
}
}
}
@@ -82,16 +79,14 @@ ingen_load_module(const string& name)
module = new Glib::Module(Ingen::module_path(name));
if (*module) {
- LOG(Raul::info)(Raul::fmt("Loading %1%\n") % Ingen::module_path(name));
return module;
} else if (!module_path_found) {
- LOG(Raul::error)(Raul::fmt("Unable to find %1% (%2%)\n")
- % name % Glib::Module::get_last_error());
+ log.error(Raul::fmt("Unable to find %1% (%2%)\n")
+ % name % Glib::Module::get_last_error());
return NULL;
} else {
- LOG(Raul::error)(Raul::fmt("Unable to load %1% from %2% (%3%)\n")
- % name % module_path % Glib::Module::get_last_error());
- LOG(Raul::error)("Is Ingen installed?\n");
+ log.error(Raul::fmt("Unable to load %1% from %2% (%3%)\n")
+ % name % module_path % Glib::Module::get_last_error());
return NULL;
}
}
@@ -101,14 +96,16 @@ public:
Impl(int& a_argc,
char**& a_argv,
LV2_URID_Map* map,
- LV2_URID_Unmap* unmap)
+ LV2_URID_Unmap* unmap,
+ LV2_Log_Log* lv2_log)
: argc(a_argc)
, argv(a_argv)
, lv2_features(NULL)
, rdf_world(new Sord::World())
- , uri_map(new URIMap(map, unmap))
+ , uri_map(new URIMap(log, map, unmap))
, forge(new Forge(*uri_map))
, uris(new URIs(*forge, uri_map))
+ , log(lv2_log, *uris)
, lilv_world(lilv_world_new())
{
conf.parse(argc, argv);
@@ -180,6 +177,8 @@ public:
URIMap* uri_map;
Forge* forge;
URIs* uris;
+ LV2_Log_Log* lv2_log;
+ Log log;
SharedPtr<Interface> interface;
SharedPtr<EngineBase> engine;
SharedPtr<Serialisation::Serialiser> serialiser;
@@ -192,8 +191,9 @@ public:
World::World(int& argc,
char**& argv,
LV2_URID_Map* map,
- LV2_URID_Unmap* unmap)
- : _impl(new Impl(argc, argv, map, unmap))
+ LV2_URID_Unmap* unmap,
+ LV2_Log_Log* log)
+ : _impl(new Impl(argc, argv, map, unmap, log))
{
}
@@ -217,6 +217,7 @@ SharedPtr<Store> World::store() { return _impl->store
int& World::argc() { return _impl->argc; }
char**& World::argv() { return _impl->argv; }
Configuration& World::conf() { return _impl->conf; }
+Log& World::log() { return _impl->log; }
Sord::World* World::rdf_world() { return _impl->rdf_world; }
LilvWorld* World::lilv_world() { return _impl->lilv_world; }
@@ -231,10 +232,9 @@ World::load_module(const char* name)
{
Impl::Modules::iterator i = _impl->modules.find(name);
if (i != _impl->modules.end()) {
- LOG(Raul::info)(Raul::fmt("Module `%1%' already loaded\n") % name);
return true;
}
- Glib::Module* lib = ingen_load_module(name);
+ Glib::Module* lib = ingen_load_module(log(), name);
Ingen::Module* (*module_load)() = NULL;
if (lib && lib->get_symbol("ingen_module_load", (void*&)module_load)) {
Module* module = module_load();
@@ -246,7 +246,7 @@ World::load_module(const char* name)
}
}
- LOG(Raul::error)(Raul::fmt("Failed to load module `%1%'\n") % name);
+ log().error(Raul::fmt("Failed to load module `%1%'\n") % name);
delete lib;
return false;
}
@@ -256,7 +256,7 @@ World::run_module(const char* name)
{
Impl::Modules::iterator i = _impl->modules.find(name);
if (i == _impl->modules.end()) {
- LOG(Raul::error) << "Attempt to run unloaded module `" << name << "'" << endl;
+ log().error(Raul::fmt("Attempt to run unloaded module `%1%'\n") % name);
return false;
}
@@ -278,7 +278,7 @@ World::new_interface(const Raul::URI& engine_uri,
{
const Impl::InterfaceFactories::const_iterator i = _impl->interface_factories.find(engine_uri.scheme());
if (i == _impl->interface_factories.end()) {
- Raul::warn << "Unknown URI scheme `" << engine_uri.scheme() << "'" << endl;
+ log().warn(Raul::fmt("Unknown URI scheme `%1%'\n") % engine_uri.scheme());
return SharedPtr<Interface>();
}
@@ -291,7 +291,7 @@ World::run(const std::string& mime_type, const std::string& filename)
{
const Impl::ScriptRunners::const_iterator i = _impl->script_runners.find(mime_type);
if (i == _impl->script_runners.end()) {
- Raul::warn << "Unknown script MIME type `" << mime_type << "'" << endl;
+ log().warn(Raul::fmt("Unknown script MIME type `%1%'\n") % mime_type);
return false;
}
diff --git a/src/bindings/ingen_bindings.cpp b/src/bindings/ingen_bindings.cpp
index 39fd9fbf..b289e685 100644
--- a/src/bindings/ingen_bindings.cpp
+++ b/src/bindings/ingen_bindings.cpp
@@ -15,7 +15,6 @@
*/
#include "python2.4/Python.h"
-#include "raul/log.hpp"
#include "ingen_bindings.hpp"
#include "server/Engine.hpp"
#include "ingen/World.hpp"
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 <http://www.gnu.org/licenses/>.
*/
+#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<Interface> engine,
SharedPtr<SigClientInterface> emitter)
: _uris(uris)
+ , _log(log)
, _engine(engine)
, _emitter(emitter)
, _plugins(new Plugins())
@@ -96,12 +96,6 @@ ClientStore::add_object(SharedPtr<ObjectModel> 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<ObjectModel>
@@ -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<PluginModel> 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<PluginModel>(
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<Resource> 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<PatchModel>(_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<ObjectModel> 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 <cassert>
-#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<EdgeModel> c = PtrCast<EdgeModel>(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();
}
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index e9c9c663..cfba10c7 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -25,15 +25,15 @@
#include "ganv/Edge.hpp"
#include "ingen/EngineBase.hpp"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
+#include "ingen/World.hpp"
#include "ingen/client/ClientStore.hpp"
#include "ingen/client/ObjectModel.hpp"
#include "ingen/client/PatchModel.hpp"
#include "ingen/client/SigClientInterface.hpp"
-#include "ingen/World.hpp"
#include "ingen/runtime_paths.hpp"
#include "lilv/lilv.h"
#include "raul/Path.hpp"
-#include "raul/log.hpp"
#include "App.hpp"
#include "Configuration.hpp"
@@ -49,8 +49,6 @@
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
-#define LOG(s) (s("[GUI] "))
-
using namespace std;
namespace Raul { class Deletable; }
@@ -148,7 +146,6 @@ App::run()
break;
_main->run();
- LOG(Raul::info)("Exiting\n");
}
void
@@ -163,7 +160,7 @@ App::attach(SharedPtr<SigClientInterface> client)
}
_client = client;
- _store = SharedPtr<ClientStore>(new ClientStore(_world->uris(), _world->interface(), client));
+ _store = SharedPtr<ClientStore>(new ClientStore(_world->uris(), _world->log(), _world->interface(), client));
_loader = SharedPtr<ThreadedLoader>(new ThreadedLoader(*this, _world->interface()));
_patch_tree_window->init(*this, *_store);
@@ -229,10 +226,10 @@ App::property_change(const Raul::URI& subject,
{
if (subject == uris().ingen_engine && key == uris().ingen_sampleRate) {
if (value.type() == forge().Int) {
- LOG(Raul::info)(Raul::fmt("Sample rate: %1%\n") % uris().forge.str(value));
+ log().info(Raul::fmt("Sample rate: %1%\n") % uris().forge.str(value));
_sample_rate = value.get_int32();
} else {
- Raul::error << "Engine sample rate property is not an integer" << std::endl;
+ log().error("Engine sample rate property is not an integer\n");
}
}
}
@@ -378,7 +375,8 @@ App::icon_from_path(const string& path, int size)
new IconDestroyNotification(*this, make_pair(path, size)),
&App::icon_destroyed);
} catch (const Glib::Error& e) {
- Raul::warn << "Error loading icon: " << e.what() << endl;
+ log().warn(Raul::fmt("Error loading icon %1%: %2%\n")
+ % path % e.what());
}
return buf;
}
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index 5d93c805..32c59300 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -35,6 +35,7 @@
namespace Ingen {
class Interface;
+ class Log;
class Port;
class World;
namespace Client {
@@ -118,6 +119,7 @@ public:
inline Ingen::World* world() const { return _world; }
inline Ingen::URIs& uris() const { return _world->uris(); }
+ inline Ingen::Log& log() const { return _world->log(); }
protected:
diff --git a/src/gui/Configuration.cpp b/src/gui/Configuration.cpp
index f7f8977c..1fb48c58 100644
--- a/src/gui/Configuration.cpp
+++ b/src/gui/Configuration.cpp
@@ -21,10 +21,10 @@
#include <string>
#include "ganv/Port.hpp"
+#include "ingen/Log.hpp"
#include "ingen/client/PluginModel.hpp"
#include "ingen/client/PortModel.hpp"
#include "ingen/serialisation/Parser.hpp"
-#include "raul/log.hpp"
#include "App.hpp"
#include "Configuration.hpp"
@@ -95,7 +95,7 @@ Configuration::get_port_color(const Client::PortModel* p)
return _event_port_color;
}
- Raul::warn << "[Configuration] No known port type for " << p->path() << endl;
+ _app.log().warn(Raul::fmt("No known port type for %1%\n") % p->path());
return 0x666666FF;
}
diff --git a/src/gui/ConnectWindow.cpp b/src/gui/ConnectWindow.cpp
index 0aef8dbd..ea196175 100644
--- a/src/gui/ConnectWindow.cpp
+++ b/src/gui/ConnectWindow.cpp
@@ -21,16 +21,16 @@
#include <gtkmm/stock.h>
#include "raul/Process.hpp"
-#include "raul/log.hpp"
-#include "ingen_config.h"
#include "ingen/EngineBase.hpp"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
+#include "ingen/Module.hpp"
+#include "ingen/World.hpp"
#include "ingen/client/ClientStore.hpp"
#include "ingen/client/PatchModel.hpp"
#include "ingen/client/ThreadedSigClientInterface.hpp"
-#include "ingen/Module.hpp"
-#include "ingen/World.hpp"
+#include "ingen_config.h"
#include "App.hpp"
#include "ConnectWindow.hpp"
@@ -209,7 +209,7 @@ ConnectWindow::connect(bool existing)
Glib::signal_timeout().connect(
sigc::mem_fun(this, &ConnectWindow::gtk_callback), 40);
} else {
- Raul::error << "Failed to launch ingen process." << endl;
+ world->log().error("Failed to launch ingen process\n");
}
return;
}
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index 08f88c8b..35a35c39 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -20,6 +20,7 @@
#include <gtkmm/stock.h>
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/client/NodeModel.hpp"
#include "ingen/client/PluginModel.hpp"
#include "lv2/lv2plug.in/ns/ext/presets/presets.h"
@@ -108,9 +109,9 @@ NodeMenu::init(App& app, SharedPtr<const Client::NodeModel> node)
lilv_nodes_free(labels);
} else {
- Raul::error << "Preset <"
- << lilv_node_as_string(lilv_nodes_get(presets, i))
- << "> has no rdfs:label" << std::endl;
+ app.log().error(
+ Raul::fmt("Preset <%1> has no rdfs:label\n")
+ % lilv_node_as_string(lilv_nodes_get(presets, i)));
}
}
diff --git a/src/gui/NodeModule.cpp b/src/gui/NodeModule.cpp
index c2305e03..89ecc4a1 100644
--- a/src/gui/NodeModule.cpp
+++ b/src/gui/NodeModule.cpp
@@ -22,12 +22,12 @@
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/client/NodeModel.hpp"
#include "ingen/client/PatchModel.hpp"
#include "ingen/client/PluginModel.hpp"
#include "ingen/client/PluginUI.hpp"
#include "raul/Atom.hpp"
-#include "raul/log.hpp"
#include "App.hpp"
#include "Configuration.hpp"
@@ -220,7 +220,7 @@ NodeModule::embed_gui(bool embed)
{
if (embed) {
if (_gui_window) {
- Raul::warn << "LV2 GUI already popped up, cannot embed" << endl;
+ app().log().warn("LV2 GUI already popped up, cannot embed\n");
return;
}
@@ -239,7 +239,7 @@ NodeModule::embed_gui(bool embed)
container->add(*_gui_widget);
Ganv::Module::embed(container);
} else {
- Raul::error << "Failed to create LV2 UI" << endl;
+ app().log().error("Failed to create LV2 UI\n");
}
if (_gui_widget) {
@@ -294,7 +294,8 @@ NodeModule::delete_port_view(SharedPtr<const PortModel> model)
if (p) {
delete p;
} else {
- Raul::warn << "Failed to find port on module " << model->path() << endl;
+ app().log().warn(Raul::fmt("Failed to find port %1% on module %2%\n")
+ % model->path() % _node->path());
}
}
@@ -303,7 +304,7 @@ NodeModule::popup_gui()
{
if (_node->plugin() && _node->plugin()->type() == PluginModel::LV2) {
if (_plugin_ui) {
- Raul::warn << "LV2 GUI already embedded, cannot pop up" << endl;
+ app().log().warn("LV2 GUI already embedded, cannot pop up\n");
return false;
}
@@ -332,7 +333,7 @@ NodeModule::popup_gui()
return true;
} else {
- Raul::warn << "No LV2 GUI for " << _node->path() << endl;
+ app().log().warn(Raul::fmt("No LV2 GUI for %1%\n") % _node->path());
}
}
diff --git a/src/gui/PatchCanvas.cpp b/src/gui/PatchCanvas.cpp
index 25552202..bc103d50 100644
--- a/src/gui/PatchCanvas.cpp
+++ b/src/gui/PatchCanvas.cpp
@@ -24,17 +24,17 @@
#include "ganv/Canvas.hpp"
#include "ganv/Circle.hpp"
+#include "ingen/Builder.hpp"
+#include "ingen/ClashAvoider.hpp"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
+#include "ingen/World.hpp"
#include "ingen/client/ClientStore.hpp"
#include "ingen/client/NodeModel.hpp"
#include "ingen/client/PatchModel.hpp"
#include "ingen/client/PluginModel.hpp"
#include "ingen/serialisation/Serialiser.hpp"
-#include "ingen/Builder.hpp"
-#include "ingen/ClashAvoider.hpp"
-#include "ingen/World.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
-#include "raul/log.hpp"
#include "App.hpp"
#include "Edge.hpp"
@@ -50,8 +50,6 @@
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
-#define LOG(s) s << "[PatchCanvas] "
-
#define FOREACH_ITEM(iter, coll) \
for (Items::const_iterator (iter) = coll.begin(); \
(iter) != coll.end(); ++(iter))
@@ -228,8 +226,8 @@ PatchCanvas::build_plugin_class_menu(
const char* sub_label_str = lilv_node_as_string(lilv_plugin_class_get_label(c));
const char* sub_uri_str = lilv_node_as_string(lilv_plugin_class_get_uri(c));
if (ancestors.find(sub_uri_str) != ancestors.end()) {
- LOG(Raul::warn) << "Infinite LV2 class recursion: " << class_uri_str
- << " <: " << sub_uri_str << endl;
+ _app.log().warn(Raul::fmt("Infinite LV2 class recursion: %1% <: %2%\n")
+ % class_uri_str % sub_uri_str);
return 0;
}
@@ -490,8 +488,8 @@ PatchCanvas::connection(SharedPtr<const EdgeModel> cm)
if (tail && head) {
new GUI::Edge(*this, cm, tail, head, tail->get_fill_color());
} else {
- LOG(Raul::error) << "Unable to find ports to connect "
- << cm->tail_path() << " -> " << cm->head_path() << endl;
+ _app.log().error(Raul::fmt("Unable to find ports to connect %1% => %2%\n")
+ % cm->tail_path() % cm->head_path());
}
}
@@ -501,11 +499,12 @@ PatchCanvas::disconnection(SharedPtr<const EdgeModel> cm)
Ganv::Port* const src = get_port_view(cm->tail());
Ganv::Port* const dst = get_port_view(cm->head());
- if (src && dst)
+ if (src && dst) {
remove_edge(src, dst);
- else
- LOG(Raul::error) << "Unable to find ports to disconnect "
- << cm->tail_path() << " -> " << cm->head_path() << endl;
+ } else {
+ _app.log().error(Raul::fmt("Unable to find ports to disconnect %1% => %2%\n")
+ % cm->tail_path() % cm->head_path());
+ }
}
void
@@ -703,7 +702,7 @@ PatchCanvas::paste()
Glib::ustring str = Gtk::Clipboard::get()->wait_for_text();
SharedPtr<Serialisation::Parser> parser = _app.loader()->parser();
if (!parser) {
- LOG(Raul::error) << "Unable to load parser, paste unavailable" << endl;
+ _app.log().error("Unable to load parser, paste unavailable\n");
return;
}
@@ -714,7 +713,7 @@ PatchCanvas::paste()
const URIs& uris = _app.uris();
Builder builder(_app.world()->uris(), *_app.interface());
- ClientStore clipboard(_app.world()->uris());
+ ClientStore clipboard(_app.world()->uris(), _app.log());
clipboard.set_plugins(_app.store()->plugins());
// mkdir -p
diff --git a/src/gui/PatchTreeWindow.cpp b/src/gui/PatchTreeWindow.cpp
index 06eed694..00b96926 100644
--- a/src/gui/PatchTreeWindow.cpp
+++ b/src/gui/PatchTreeWindow.cpp
@@ -14,17 +14,15 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "raul/log.hpp"
-#include "raul/Path.hpp"
-#include "ingen/Interface.hpp"
-#include "ingen/client/ClientStore.hpp"
-#include "ingen/client/PatchModel.hpp"
#include "App.hpp"
#include "PatchTreeWindow.hpp"
#include "SubpatchModule.hpp"
#include "WindowFactory.hpp"
-
-#define LOG(s) s << "[PatchTreeWindow] "
+#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
+#include "ingen/client/ClientStore.hpp"
+#include "ingen/client/PatchModel.hpp"
+#include "raul/Path.hpp"
using namespace std;
@@ -160,8 +158,9 @@ PatchTreeWindow::show_patch_menu(GdkEventButton* ev)
if (active) {
Gtk::TreeModel::Row row = *active;
SharedPtr<PatchModel> pm = row[_patch_tree_columns.patch_model_col];
- if (pm)
- Raul::warn << "TODO: patch menu from tree window" << endl;
+ if (pm) {
+ _app->log().warn("TODO: patch menu from tree window");
+ }
}
}
@@ -205,7 +204,8 @@ PatchTreeWindow::patch_property_changed(const Raul::URI& key,
Gtk::TreeModel::Row row = *i;
row[_patch_tree_columns.enabled_col] = value.get_bool();
} else {
- LOG(Raul::error) << "Unable to find patch " << patch->path() << endl;
+ _app->log().error(Raul::fmt("Unable to find patch %1%\n")
+ % patch->path());
}
}
_enable_signal = true;
@@ -223,7 +223,8 @@ PatchTreeWindow::patch_moved(SharedPtr<PatchModel> patch)
Gtk::TreeModel::Row row = *i;
row[_patch_tree_columns.name_col] = patch->symbol().c_str();
} else {
- LOG(Raul::error) << "Unable to find patch " << patch->path() << endl;
+ _app->log().error(Raul::fmt("Unable to find patch %1%\n")
+ % patch->path());
}
_enable_signal = true;
diff --git a/src/gui/PatchTreeWindow.hpp b/src/gui/PatchTreeWindow.hpp
index 8321644f..86e10370 100644
--- a/src/gui/PatchTreeWindow.hpp
+++ b/src/gui/PatchTreeWindow.hpp
@@ -28,7 +28,7 @@ namespace Raul { class Path; }
namespace Ingen {
-namespace Client { class ClientStore; }
+namespace Client { class ClientStore; class ObjectModel; }
namespace GUI {
diff --git a/src/gui/PatchView.cpp b/src/gui/PatchView.cpp
index f1f4c96d..e81d16f7 100644
--- a/src/gui/PatchView.cpp
+++ b/src/gui/PatchView.cpp
@@ -16,15 +16,16 @@
#include <cassert>
#include <fstream>
-#include "raul/log.hpp"
+
#include "ingen/Interface.hpp"
#include "ingen/client/PatchModel.hpp"
+
#include "App.hpp"
-#include "PatchView.hpp"
-#include "PatchCanvas.hpp"
#include "LoadPluginWindow.hpp"
#include "NewSubpatchWindow.hpp"
+#include "PatchCanvas.hpp"
#include "PatchTreeWindow.hpp"
+#include "PatchView.hpp"
#include "WidgetFactory.hpp"
using namespace std;
@@ -192,14 +193,10 @@ PatchView::property_changed(const Raul::URI& predicate, const Raul::Atom& value)
if (predicate == _app->uris().ingen_enabled) {
if (value.type() == _app->uris().forge.Bool) {
_process_but->set_active(value.get_bool());
- } else {
- Raul::warn << "Bad type for ingen:enabled: " << value.type() << endl;
}
} else if (predicate == _app->uris().ingen_polyphony) {
if (value.type() == _app->uris().forge.Int) {
_poly_spin->set_value(value.get_int32());
- } else {
- Raul::warn << "Bad type for ingen:polyphony: " << value.type() << endl;
}
}
_enable_signal = true;
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index a238d60f..265b4caf 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -19,9 +19,9 @@
#include "ganv/Module.hpp"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/client/PatchModel.hpp"
#include "ingen/client/PortModel.hpp"
-#include "raul/log.hpp"
#include "App.hpp"
#include "Configuration.hpp"
@@ -143,7 +143,7 @@ void
Port::on_value_changed(GVariant* value)
{
if (!g_variant_is_of_type(value, G_VARIANT_TYPE_DOUBLE)) {
- Raul::warn("TODO: Non-float port value changed\n");
+ _app.log().warn("TODO: Non-float port value changed\n");
return;
}
diff --git a/src/gui/PropertiesWindow.cpp b/src/gui/PropertiesWindow.cpp
index b146d412..2acb7ffe 100644
--- a/src/gui/PropertiesWindow.cpp
+++ b/src/gui/PropertiesWindow.cpp
@@ -21,15 +21,14 @@
#include <gtkmm/label.h>
#include <gtkmm/spinbutton.h>
-#include "App.hpp"
-#include "PropertiesWindow.hpp"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/World.hpp"
#include "ingen/client/NodeModel.hpp"
#include "ingen/client/PluginModel.hpp"
-#include "raul/log.hpp"
-#define LOG(s) s << "[PropertiesWindow] "
+#include "App.hpp"
+#include "PropertiesWindow.hpp"
using namespace std;
@@ -351,7 +350,8 @@ PropertiesWindow::create_value_widget(const Raul::URI& uri, const Raul::Atom& va
return widget;
}
- LOG(Raul::error) << "Unable to create widget for value " << forge.str(value) << endl;
+ _app->log().error(Raul::fmt("Unable to create widget for value %1%\n")
+ % forge.str(value));
return NULL;
}
@@ -408,7 +408,8 @@ PropertiesWindow::value_edited(const Raul::URI& predicate)
{
Records::iterator r = _records.find(predicate);
if (r == _records.end()) {
- LOG(Raul::error) << "Unknown property `" << predicate << "' edited" << endl;
+ _app->log().error(Raul::fmt("Unknown property `%1%' edited\n")
+ % predicate);
return;
}
@@ -440,7 +441,8 @@ PropertiesWindow::value_edited(const Raul::URI& predicate)
return;
bad_type:
- LOG(Raul::error) << "Property `" << predicate << "' value widget has wrong type" << endl;
+ _app->log().error(Raul::fmt("Property `%1%' value widget has wrong type\n")
+ % predicate);
return;
}
@@ -517,21 +519,16 @@ PropertiesWindow::cancel_clicked()
void
PropertiesWindow::apply_clicked()
{
- LOG(Raul::debug) << "apply {" << endl;
Resource::Properties properties;
for (Records::const_iterator r = _records.begin(); r != _records.end(); ++r) {
const Raul::URI& uri = r->first;
const Record& record = r->second;
if (!_model->has_property(uri, record.value)) {
- LOG(Raul::debug) << "\t" << uri
- << " = " << _app->forge().str(record.value) << endl;
properties.insert(make_pair(uri, record.value));
}
}
_app->interface()->put(_model->uri(), properties);
-
- LOG(Raul::debug) << "}" << endl;
}
void
diff --git a/src/gui/RenameWindow.cpp b/src/gui/RenameWindow.cpp
index df22a3c0..25528df1 100644
--- a/src/gui/RenameWindow.cpp
+++ b/src/gui/RenameWindow.cpp
@@ -80,7 +80,6 @@ void
RenameWindow::values_changed()
{
const string& symbol = _symbol_entry->get_text();
- const string& label = _label_entry->get_text();
if (!Raul::Symbol::is_valid(symbol)) {
_message_label->set_text("Invalid symbol");
_ok_button->property_sensitive() = false;
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp
index 3154dfbb..bc7aa19c 100644
--- a/src/gui/ThreadedLoader.cpp
+++ b/src/gui/ThreadedLoader.cpp
@@ -16,10 +16,10 @@
#include <string>
+#include "ingen/Log.hpp"
#include "ingen/Module.hpp"
#include "ingen/World.hpp"
#include "ingen/client/PatchModel.hpp"
-#include "raul/log.hpp"
#include "App.hpp"
#include "ThreadedLoader.hpp"
@@ -36,10 +36,11 @@ ThreadedLoader::ThreadedLoader(App& app, SharedPtr<Interface> engine)
, _sem(0)
, _engine(engine)
{
- if (parser())
+ if (parser()) {
start();
- else
- Raul::warn << "Failed to load ingen_serialisation module, load disabled." << endl;
+ } else {
+ app.log().warn("Parser unavailable, patch loading disabled\n");
+ }
}
ThreadedLoader::~ThreadedLoader()
diff --git a/src/gui/WidgetFactory.cpp b/src/gui/WidgetFactory.cpp
index 31749ffe..642e3cea 100644
--- a/src/gui/WidgetFactory.cpp
+++ b/src/gui/WidgetFactory.cpp
@@ -17,8 +17,7 @@
#include <fstream>
#include <string>
-#include "raul/log.hpp"
-
+#include "raul/fmt.hpp"
#include "ingen/runtime_paths.hpp"
#include "WidgetFactory.hpp"
@@ -59,25 +58,21 @@ WidgetFactory::find_ui_file()
if (is_readable(ui_filename))
return;
- Raul::error << "[WidgetFactory] Unable to find ingen_gui.ui in "
- << INGEN_DATA_DIR << endl;
- throw std::runtime_error("Unable to find UI file");
+ throw std::runtime_error((Raul::fmt("Unable to find ingen_gui.ui in %1%\n")
+ % INGEN_DATA_DIR).str());
}
Glib::RefPtr<Gtk::Builder>
WidgetFactory::create(const string& toplevel_widget)
{
- if (ui_filename.empty())
+ if (ui_filename.empty()) {
find_ui_file();
+ }
- try {
- if (toplevel_widget.empty())
- return Gtk::Builder::create_from_file(ui_filename);
- else
- return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str());
- } catch (const Gtk::BuilderError& ex) {
- Raul::error << "[WidgetFactory] " << ex.what() << endl;
- throw ex;
+ if (toplevel_widget.empty()) {
+ return Gtk::Builder::create_from_file(ui_filename);
+ } else {
+ return Gtk::Builder::create_from_file(ui_filename, toplevel_widget.c_str());
}
}
diff --git a/src/gui/ingen_gui_lv2.cpp b/src/gui/ingen_gui_lv2.cpp
index 3dcb6d71..937ecd38 100644
--- a/src/gui/ingen_gui_lv2.cpp
+++ b/src/gui/ingen_gui_lv2.cpp
@@ -89,15 +89,18 @@ instantiate(const LV2UI_Descriptor* descriptor,
LV2_URID_Map* map = NULL;
LV2_URID_Unmap* unmap = NULL;
+ LV2_Log_Log* log = NULL;
for (int i = 0; features[i]; ++i) {
- if (!strcmp(features[i]->URI, LV2_URID_URI "#map")) {
+ if (!strcmp(features[i]->URI, LV2_URID__map)) {
map = (LV2_URID_Map*)features[i]->data;
- } else if (!strcmp(features[i]->URI, LV2_URID_URI "#unmap")) {
+ } else if (!strcmp(features[i]->URI, LV2_URID__unmap)) {
unmap = (LV2_URID_Unmap*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_LOG__log)) {
+ log = (LV2_Log_Log*)features[i]->data;
}
}
- ui->world = new Ingen::World(ui->argc, ui->argv, map, unmap);
+ ui->world = new Ingen::World(ui->argc, ui->argv, map, unmap, log);
ui->forge = new Ingen::Forge(ui->world->uri_map());
@@ -125,6 +128,7 @@ instantiate(const LV2UI_Descriptor* descriptor,
ui->reader = SharedPtr<Ingen::AtomReader>(
new Ingen::AtomReader(ui->world->uri_map(),
ui->world->uris(),
+ ui->world->log(),
ui->world->forge(),
*ui->client.get()));
diff --git a/src/ingen/main.cpp b/src/ingen/main.cpp
index dcb27ea1..44f042a4 100644
--- a/src/ingen/main.cpp
+++ b/src/ingen/main.cpp
@@ -26,7 +26,7 @@
#include "raul/Configuration.hpp"
#include "raul/Path.hpp"
#include "raul/SharedPtr.hpp"
-#include "raul/log.hpp"
+#include "raul/fmt.hpp"
#include "ingen_config.h"
@@ -79,7 +79,7 @@ main(int argc, char** argv)
// Create world
try {
- world = new Ingen::World(argc, argv, NULL, NULL);
+ world = new Ingen::World(argc, argv, NULL, NULL, NULL);
if (argc <= 1) {
world->conf().print_usage("ingen", cout);
return EXIT_FAILURE;
@@ -204,7 +204,6 @@ main(int argc, char** argv)
while (world->engine()->main_iteration()) {
Glib::usleep(125000); // 1/8 second
}
- Raul::info("Finished main loop\n");
}
// Shut down
diff --git a/src/runtime_paths.cpp b/src/runtime_paths.cpp
index 352afa42..8b12f500 100644
--- a/src/runtime_paths.cpp
+++ b/src/runtime_paths.cpp
@@ -24,8 +24,6 @@
#include <glibmm/module.h>
#include <glibmm/miscutils.h>
-#include "raul/log.hpp"
-
#include "ingen/runtime_paths.hpp"
#include "ingen_config.h"
@@ -53,8 +51,6 @@ set_bundle_path_from_code(void* function)
const char* bin_loc = dli.dli_fname;
#endif
- Raul::info(Raul::fmt("Binary location: %1%\n") % bin_loc);
-
string bundle = bin_loc;
bundle = bundle.substr(0, bundle.find_last_of(G_DIR_SEPARATOR));
bundle_path = bundle;
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp
index 6a34a04b..bac5e06f 100644
--- a/src/serialisation/Parser.cpp
+++ b/src/serialisation/Parser.cpp
@@ -25,19 +25,17 @@
#include <glibmm/ustring.h>
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/URIMap.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
#include "ingen/serialisation/Parser.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "raul/Atom.hpp"
-#include "raul/log.hpp"
#include "serd/serd.h"
#include "sord/sordmm.hpp"
#include "sratom/sratom.h"
-#define LOG(s) (s("[Parser] "))
-
#define NS_RDF "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
#define NS_RDFS "http://www.w3.org/2000/01/rdf-schema#"
@@ -155,7 +153,7 @@ get_port(Ingen::World* world,
if (i == props.end()
|| i->second.type() != world->forge().Int
|| i->second.get_int32() < 0) {
- LOG(Raul::error) << "Port " << subject << " has no valid index" << endl;
+ world->log().warn(Raul::fmt("Port %1% has no valid index\n") % subject);
return boost::optional<PortRecord>();
}
index = i->second.get_int32();
@@ -163,7 +161,7 @@ get_port(Ingen::World* world,
// Get symbol
Resource::Properties::const_iterator s = props.find(uris.lv2_symbol);
if (s == props.end()) {
- LOG(Raul::error) << "Port " << subject << " has no symbol" << endl;
+ world->log().warn(Raul::fmt("Port %1% has no symbol\n") % subject);
return boost::optional<PortRecord>();
}
const Raul::Symbol port_sym(s->second.get_string());
@@ -234,7 +232,7 @@ parse_node(Ingen::World* world,
Sord::Iter i = model.find(subject, ingen_prototype, nil);
if (i.end() || i.get_object().type() != Sord::Node::URI) {
- LOG(Raul::error) << "Node missing mandatory ingen:prototype" << endl;
+ world->log().error("Node missing mandatory ingen:prototype\n");
return boost::optional<Raul::Path>();
}
@@ -312,7 +310,8 @@ parse_patch(Ingen::World* world,
patch_path_str = parent->child(*a_symbol);
if (!Raul::Path::is_valid(patch_path_str)) {
- LOG(Raul::error) << "Patch has invalid path: " << patch_path_str << endl;
+ world->log().error(Raul::fmt("Patch %1% has invalid path\n")
+ % patch_path_str);
return boost::optional<Raul::Path>();
}
@@ -340,7 +339,7 @@ parse_patch(Ingen::World* world,
boost::optional<PortRecord> port_record = get_port(
world, model, port, node_path, index);
if (!port_record) {
- LOG(Raul::error) << "Invalid port " << port << endl;
+ world->log().error(Raul::fmt("Invalid port %1%\n") % port);
return boost::optional<Raul::Path>();
}
@@ -361,7 +360,7 @@ parse_patch(Ingen::World* world,
boost::optional<PortRecord> port_record = get_port(
world, model, port, patch_path, index);
if (!port_record) {
- LOG(Raul::error) << "Invalid port " << port << endl;
+ world->log().error(Raul::fmt("Invalid port %1%\n") % port);
return boost::optional<Raul::Path>();
}
@@ -397,32 +396,32 @@ parse_edge(Ingen::World* world,
const Glib::ustring& base_uri = model.base_uri().to_string();
if (t.end()) {
- LOG(Raul::error) << "Edge has no tail" << endl;
+ world->log().error("Edge has no tail");
return false;
} else if (h.end()) {
- LOG(Raul::error) << "Edge has no head" << endl;
+ world->log().error("Edge has no head");
return false;
}
const std::string tail_str = relative_uri(
base_uri, t.get_object().to_string(), true);
if (!Raul::Path::is_valid(tail_str)) {
- LOG(Raul::error) << "Edge tail has invalid URI" << endl;
+ world->log().error("Edge tail has invalid URI");
return false;
}
const std::string head_str = relative_uri(
base_uri, h.get_object().to_string(), true);
if (!Raul::Path::is_valid(head_str)) {
- LOG(Raul::error) << "Edge head has invalid URI" << endl;
+ world->log().error("Edge head has invalid URI");
return false;
}
if (!(++t).end()) {
- LOG(Raul::error) << "Edge has multiple tails" << endl;
+ world->log().error("Edge has multiple tails");
return false;
} else if (!(++h).end()) {
- LOG(Raul::error) << "Edge has multiple heads" << endl;
+ world->log().error("Edge has multiple heads");
return false;
}
@@ -530,17 +529,7 @@ parse(Ingen::World* world,
Raul::Path parent_path(parent ? parent.get() : Raul::Path("/"));
parse_edge(world, target, model, s, parent_path);
} else {
- LOG(Raul::error) << "Subject has no known types" << endl;
- }
-
- if (!ret) {
- LOG(Raul::error) << "Failed to parse " << path << endl;
- LOG(Raul::error) << "Types:" << endl;
- for (std::set<Sord::Node>::const_iterator t = types.begin();
- t != types.end(); ++t) {
- LOG(Raul::error) << " :: " << *t << endl;
- assert((*t).is_uri());
- }
+ world->log().error("Subject has no known types\n");
}
}
@@ -571,7 +560,8 @@ Parser::parse_file(Ingen::World* world,
try {
uri = Glib::filename_to_uri(path, "");
} catch (const Glib::ConvertError& e) {
- LOG(Raul::error) << "Path to URI conversion error: " << e.what() << endl;
+ world->log().error(Raul::fmt("Path to URI conversion error: %1%\n")
+ % e.what());
return false;
}
@@ -585,11 +575,11 @@ Parser::parse_file(Ingen::World* world,
serd_env_free(env);
- LOG(Raul::info)(Raul::fmt("Parsing %1%\n") % path);
+ world->log().info(Raul::fmt("Parsing %1%\n") % path);
if (parent)
- LOG(Raul::info)(Raul::fmt("Parent: %1%\n") % parent->c_str());
+ world->log().info(Raul::fmt("Parent: %1%\n") % parent->c_str());
if (symbol)
- LOG(Raul::info)(Raul::fmt("Symbol: %1%\n") % symbol->c_str());
+ world->log().info(Raul::fmt("Symbol: %1%\n") % symbol->c_str());
Sord::Node subject(*world->rdf_world(), Sord::Node::URI, uri);
boost::optional<Raul::Path> parsed_path
@@ -600,7 +590,7 @@ Parser::parse_file(Ingen::World* world,
Raul::URI("http://drobilla.net/ns/ingen#document"),
world->forge().alloc_uri(uri));
} else {
- LOG(Raul::warn)("Document URI lost\n");
+ world->log().warn("Document URI lost\n");
}
return parsed_path;
@@ -623,11 +613,7 @@ Parser::parse_string(Ingen::World* world,
model.load_string(env, SERD_TURTLE, str.c_str(), str.length(), base_uri);
serd_env_free(env);
- LOG(Raul::info) << "Parsing string";
- if (!base_uri.empty()) {
- Raul::info << " (base " << base_uri << ")";
- }
- Raul::info << endl;
+ world->log().info(Raul::fmt("Parsing string (base %1%)\n") % base_uri);
Sord::Node subject;
return parse(world, target, model, base_uri, subject, parent, symbol, data);
diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp
index c8ee42c0..b480d531 100644
--- a/src/serialisation/Serialiser.cpp
+++ b/src/serialisation/Serialiser.cpp
@@ -29,22 +29,20 @@
#include "ingen/Edge.hpp"
#include "ingen/GraphObject.hpp"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/Plugin.hpp"
#include "ingen/Resource.hpp"
-#include "ingen/serialisation/Serialiser.hpp"
#include "ingen/Store.hpp"
#include "ingen/URIMap.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
+#include "ingen/serialisation/Serialiser.hpp"
#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "lv2/lv2plug.in/ns/extensions/ui/ui.h"
#include "raul/Path.hpp"
-#include "raul/log.hpp"
#include "sord/sordmm.hpp"
#include "sratom/sratom.h"
-#define LOG(s) s << "[Serialiser] "
-
using namespace std;
using namespace Sord;
using namespace Ingen;
@@ -254,8 +252,8 @@ Serialiser::Impl::finish()
if (_mode == TO_FILE) {
SerdStatus st = _model->write_to_file(_base_uri, SERD_TURTLE);
if (st) {
- LOG(Raul::error) << "Error writing file `" << _base_uri << "' ("
- << serd_strerror(st) << ")" << std::endl;
+ _world.log().error(Raul::fmt("Error writing file %1% (%2%)\n")
+ % _base_uri % serd_strerror(st));
}
} else {
ret = _model->write_to_string(_base_uri, SERD_TURTLE);
@@ -295,8 +293,8 @@ Serialiser::serialise(SharedPtr<const GraphObject> object) throw (std::logic_err
Resource::DEFAULT,
me->path_rdf_node(object->path()));
} else {
- LOG(Raul::warn) << "Unsupported object type, "
- << object->path() << " not serialised." << endl;
+ me->serialise_properties(me->path_rdf_node(object->path()),
+ object->properties());
}
}
@@ -471,7 +469,7 @@ Serialiser::Impl::serialise_port(const GraphObject* port,
if (val.is_valid()) {
props.insert(make_pair(uris.lv2_default, val));
} else {
- Raul::warn("Control input has no value, lv2:default omitted.\n");
+ _world.log().warn("Control input has no value, lv2:default omitted.\n");
}
}
diff --git a/src/server/Broadcaster.cpp b/src/server/Broadcaster.cpp
index fe8ceae4..33ee5369 100644
--- a/src/server/Broadcaster.cpp
+++ b/src/server/Broadcaster.cpp
@@ -18,14 +18,11 @@
#include <glibmm/thread.h>
#include "ingen/Interface.hpp"
-#include "raul/log.hpp"
#include "Broadcaster.hpp"
#include "PluginImpl.hpp"
#include "NodeFactory.hpp"
-#define LOG(s) (s("[Broadcaster] "))
-
namespace Ingen {
namespace Server {
@@ -36,7 +33,6 @@ Broadcaster::register_client(const Raul::URI& uri,
SharedPtr<Interface> client)
{
Glib::Mutex::Lock lock(_clients_mutex);
- LOG(Raul::info)(Raul::fmt("Registered client <%1%>\n") % uri.c_str());
_clients[uri] = client;
}
@@ -49,11 +45,6 @@ Broadcaster::unregister_client(const Raul::URI& uri)
{
Glib::Mutex::Lock lock(_clients_mutex);
const size_t erased = _clients.erase(uri);
-
- if (erased > 0) {
- LOG(Raul::info)(Raul::fmt("Unregistered client <%1%>\n") % uri.c_str());
- }
-
return (erased > 0);
}
diff --git a/src/server/Buffer.cpp b/src/server/Buffer.cpp
index 9bc2572f..79ec3847 100644
--- a/src/server/Buffer.cpp
+++ b/src/server/Buffer.cpp
@@ -31,7 +31,7 @@
#include "ingen/World.hpp"
#include "ingen_config.h"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
-#include "raul/log.hpp"
+#include "ingen/Log.hpp"
#include "Buffer.hpp"
#include "BufferFactory.hpp"
@@ -55,7 +55,7 @@ Buffer::Buffer(BufferFactory& bufs, LV2_URID type, uint32_t capacity)
#endif
if (ret) {
- Raul::error << "Failed to allocate event buffer." << std::endl;
+ bufs.engine().log().error("Failed to allocate event buffer\n");
throw std::bad_alloc();
}
@@ -129,18 +129,12 @@ Buffer::port_data(PortType port_type)
return (float*)LV2_ATOM_BODY(_atom);
} else if (_atom->type == _factory.uris().atom_Sound) {
return (float*)LV2_ATOM_CONTENTS(LV2_Atom_Vector, _atom);
- } else {
- Raul::warn << "Audio data requested from non-audio buffer " << this << " :: "
- << _atom->type << " - "
- << _factory.engine().world()->uri_map().unmap_uri(_atom->type)
- << std::endl;
- assert(false);
- return NULL;
}
break;
default:
return _atom;
}
+ return NULL;
}
const void*
diff --git a/src/server/BufferFactory.cpp b/src/server/BufferFactory.cpp
index a295611f..69cba30b 100644
--- a/src/server/BufferFactory.cpp
+++ b/src/server/BufferFactory.cpp
@@ -14,8 +14,8 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "ingen/Log.hpp"
#include "ingen/URIs.hpp"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "BufferFactory.hpp"
@@ -112,7 +112,7 @@ BufferFactory::get(LV2_URID type,
return create(type, capacity);
} else {
assert(false);
- Raul::error << "Failed to obtain buffer" << std::endl;
+ _engine.world()->log().error("Failed to obtain buffer");
return BufferRef();
}
}
diff --git a/src/server/Context.cpp b/src/server/Context.cpp
index a7a78b43..3b07373d 100644
--- a/src/server/Context.cpp
+++ b/src/server/Context.cpp
@@ -15,8 +15,8 @@
*/
#include "ingen/Forge.hpp"
+#include "ingen/Log.hpp"
#include "ingen/URIMap.hpp"
-#include "raul/log.hpp"
#include "Context.hpp"
#include "Engine.hpp"
@@ -63,12 +63,12 @@ Context::notify(LV2_URID key,
{
const Notification n(port, time, key, size, type);
if (_event_sink.write_space() < sizeof(n) + size) {
- Raul::warn("Notification ring overflow\n");
+ _engine.log().warn("Notification ring overflow\n");
} else {
if (_event_sink.write(sizeof(n), &n) != sizeof(n)) {
- Raul::error("Error writing header to notification ring\n");
+ _engine.log().error("Error writing header to notification ring\n");
} else if (_event_sink.write(size, body) != size) {
- Raul::error("Error writing body to notification ring\n");
+ _engine.log().error("Error writing body to notification ring\n");
}
}
}
@@ -93,13 +93,13 @@ Context::emit_notifications(FrameTime end)
_engine.broadcaster()->set_property(
note.port->uri(), Raul::URI(key), value);
} else {
- Raul::error("Error unmapping notification key URI\n");
+ _engine.log().error("Error unmapping notification key URI\n");
}
} else {
- Raul::error("Error reading body from notification ring\n");
+ _engine.log().error("Error reading body from notification ring\n");
}
} else {
- Raul::error("Error reading header from notification ring\n");
+ _engine.log().error("Error reading header from notification ring\n");
}
}
}
diff --git a/src/server/ControlBindings.cpp b/src/server/ControlBindings.cpp
index c5e20853..de6818ff 100644
--- a/src/server/ControlBindings.cpp
+++ b/src/server/ControlBindings.cpp
@@ -16,12 +16,12 @@
#include <math.h>
+#include "ingen/Log.hpp"
#include "ingen/URIMap.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "ControlBindings.hpp"
@@ -31,8 +31,6 @@
#include "ProcessContext.hpp"
#include "ThreadManager.hpp"
-#define LOG(s) s << "[ControlBindings] "
-
using namespace std;
namespace Ingen {
@@ -81,9 +79,9 @@ ControlBindings::binding_key(const Raul::Atom& binding) const
lv2_atom_object_body_get(
binding.size(), obj, (LV2_URID)uris.midi_controllerNumber, &num, NULL);
if (!num) {
- Raul::error << "Controller binding missing number" << std::endl;
+ _engine.log().error("Controller binding missing number\n");
} else if (num->type != uris.atom_Int) {
- Raul::error << "Controller number not an integer" << std::endl;
+ _engine.log().error("Controller number not an integer\n");
} else {
key = Key(MIDI_CC, ((LV2_Atom_Int*)num)->body);
}
@@ -91,15 +89,15 @@ ControlBindings::binding_key(const Raul::Atom& binding) const
lv2_atom_object_body_get(
binding.size(), obj, (LV2_URID)uris.midi_noteNumber, &num, NULL);
if (!num) {
- Raul::error << "Note binding missing number" << std::endl;
+ _engine.log().error("Note binding missing number\n");
} else if (num->type != uris.atom_Int) {
- Raul::error << "Note number not an integer" << std::endl;
+ _engine.log().error("Note number not an integer\n");
} else {
key = Key(MIDI_NOTE, ((LV2_Atom_Int*)num)->body);
}
}
} else if (binding.type()) {
- Raul::error << "Unknown binding type " << binding.type() << std::endl;
+ _engine.log().error(Raul::fmt("Unknown binding type %1%\n") % binding.type());
}
return key;
}
@@ -252,14 +250,10 @@ ControlBindings::port_value_to_control(ProcessContext& context,
float normal = (value - min) / (max - min);
if (normal < 0.0f) {
- LOG(Raul::warn) << "Value " << value << " (normal " << normal << ") for "
- << port->path() << " out of range" << endl;
normal = 0.0f;
}
if (normal > 1.0f) {
- LOG(Raul::warn) << "Value " << value << " (normal " << normal << ") for "
- << port->path() << " out of range" << endl;
normal = 1.0f;
}
diff --git a/src/server/EdgeImpl.cpp b/src/server/EdgeImpl.cpp
index b044e5c5..23b840d4 100644
--- a/src/server/EdgeImpl.cpp
+++ b/src/server/EdgeImpl.cpp
@@ -16,7 +16,6 @@
#include "ingen/URIs.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "BufferFactory.hpp"
diff --git a/src/server/EdgeImpl.hpp b/src/server/EdgeImpl.hpp
index fd5b5ca0..4a4553b1 100644
--- a/src/server/EdgeImpl.hpp
+++ b/src/server/EdgeImpl.hpp
@@ -25,7 +25,6 @@
#include "ingen/Edge.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/atom.h"
#include "raul/Deletable.hpp"
-#include "raul/log.hpp"
#include "BufferRef.hpp"
#include "Context.hpp"
diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp
index c7fef892..4efb9f5e 100644
--- a/src/server/Engine.cpp
+++ b/src/server/Engine.cpp
@@ -21,6 +21,7 @@
#include "ingen/Store.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
+#include "ingen/Log.hpp"
#include "raul/Maid.hpp"
#include "raul/SharedPtr.hpp"
@@ -59,7 +60,7 @@ Engine::Engine(Ingen::World* world)
, _post_processor(new PostProcessor(*this))
, _event_writer(new EventWriter(*this))
, _root_patch(NULL)
- , _worker(new Worker(event_queue_size()))
+ , _worker(new Worker(world->log(), event_queue_size()))
, _process_context(*this)
, _quit_flag(false)
, _direct_driver(true)
@@ -319,12 +320,14 @@ Engine::process_events()
void
Engine::register_client(const Raul::URI& uri, SharedPtr<Interface> client)
{
+ log().info(Raul::fmt("Registering client <%1%>\n") % uri.c_str());
_broadcaster->register_client(uri, client);
}
bool
Engine::unregister_client(const Raul::URI& uri)
{
+ log().info(Raul::fmt("Unregistering client <%1%>\n") % uri.c_str());
return _broadcaster->unregister_client(uri);
}
diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp
index 81cdc5d5..ca844261 100644
--- a/src/server/Engine.hpp
+++ b/src/server/Engine.hpp
@@ -96,10 +96,11 @@ public:
BufferFactory* buffer_factory() const { return _buffer_factory; }
ControlBindings* control_bindings() const { return _control_bindings; }
Driver* driver() const { return _driver.get(); }
- Raul::Maid* maid() const { return _maid; }
+ Log& log() const { return _world->log(); }
NodeFactory* node_factory() const { return _node_factory; }
- PostProcessor* post_processor() const { return _post_processor; }
PatchImpl* root_patch() const { return _root_patch; }
+ PostProcessor* post_processor() const { return _post_processor; }
+ Raul::Maid* maid() const { return _maid; }
Worker* worker() const { return _worker; }
ProcessContext& process_context() { return _process_context; }
diff --git a/src/server/EventWriter.cpp b/src/server/EventWriter.cpp
index c913c17a..b4f95294 100644
--- a/src/server/EventWriter.cpp
+++ b/src/server/EventWriter.cpp
@@ -20,8 +20,6 @@
#include "EventWriter.hpp"
#include "events.hpp"
-#define LOG(s) s << "[EventWriter] "
-
using namespace std;
namespace Ingen {
diff --git a/src/server/GraphObjectImpl.cpp b/src/server/GraphObjectImpl.cpp
index 447e859c..212e5196 100644
--- a/src/server/GraphObjectImpl.cpp
+++ b/src/server/GraphObjectImpl.cpp
@@ -14,8 +14,6 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "raul/log.hpp"
-
#include "GraphObjectImpl.hpp"
#include "PatchImpl.hpp"
#include "ThreadManager.hpp"
diff --git a/src/server/InputPort.cpp b/src/server/InputPort.cpp
index 8e50e3b8..0bce5b93 100644
--- a/src/server/InputPort.cpp
+++ b/src/server/InputPort.cpp
@@ -17,6 +17,9 @@
#include <cstdlib>
#include <cassert>
+#include "ingen/Log.hpp"
+#include "ingen/URIs.hpp"
+
#include "Buffer.hpp"
#include "BufferFactory.hpp"
#include "EdgeImpl.hpp"
@@ -26,7 +29,6 @@
#include "OutputPort.hpp"
#include "PatchImpl.hpp"
#include "ProcessContext.hpp"
-#include "ingen/URIs.hpp"
#include "mix.hpp"
using namespace std;
@@ -143,8 +145,7 @@ InputPort::remove_edge(ProcessContext& context, const OutputPort* tail)
}
if (!edge) {
- Raul::error << "[InputPort::remove_edge] Edge not found!"
- << std::endl;
+ context.engine().log().error("Attempt to remove non-existent edge\n");
return NULL;
}
diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp
index 83a86a54..b950c350 100644
--- a/src/server/JackDriver.cpp
+++ b/src/server/JackDriver.cpp
@@ -28,9 +28,9 @@
#include "ingen/Configuration.hpp"
#include "ingen/LV2Features.hpp"
+#include "ingen/Log.hpp"
#include "ingen/World.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "DuplexPort.hpp"
@@ -41,8 +41,6 @@
#include "ThreadManager.hpp"
#include "util.hpp"
-#define LOG(s) (s("[JackDriver] "))
-
using namespace std;
typedef jack_default_audio_sample_t jack_sample_t;
@@ -83,7 +81,7 @@ JackDriver::attach(const std::string& server_name,
_client = jack_client_open(client_name.c_str(),
JackSessionID, NULL,
uuid.c_str());
- LOG(Raul::info)(Raul::fmt("Connected to JACK as `%1%' (UUID `%2%')\n")
+ _engine.log().info(Raul::fmt("Connected to JACK as `%1%' (UUID `%2%')\n")
% client_name.c_str() % uuid);
}
#endif
@@ -93,7 +91,7 @@ JackDriver::attach(const std::string& server_name,
if ((_client = jack_client_open(client_name.c_str(),
JackServerName, NULL,
server_name.c_str()))) {
- LOG(Raul::info)(Raul::fmt("Connected to JACK server `%1%'\n")
+ _engine.log().info(Raul::fmt("Connected to JACK server `%1%'\n")
% server_name);
}
}
@@ -102,12 +100,12 @@ JackDriver::attach(const std::string& server_name,
// Connect to default server
if (!_client) {
if ((_client = jack_client_open(client_name.c_str(), JackNullOption, NULL)))
- LOG(Raul::info)("Connected to default JACK server\n");
+ _engine.log().info("Connected to default JACK server\n");
}
// Still failed
if (!_client) {
- LOG(Raul::error)("Unable to connect to Jack\n");
+ _engine.log().error("Unable to connect to Jack\n");
return false;
}
} else {
@@ -138,7 +136,7 @@ JackDriver::activate()
World* world = _engine.world();
if (_is_activated) {
- LOG(Raul::warn)("Jack driver already activated\n");
+ _engine.log().warn("Jack driver already activated\n");
return;
}
@@ -151,10 +149,10 @@ JackDriver::activate()
_is_activated = true;
if (jack_activate(_client)) {
- LOG(Raul::error)("Could not activate Jack client, aborting\n");
+ _engine.log().error("Could not activate Jack client, aborting\n");
exit(EXIT_FAILURE);
} else {
- LOG(Raul::info)("Activated Jack client\n");
+ _engine.log().info("Activated Jack client\n");
}
}
@@ -176,7 +174,7 @@ JackDriver::deactivate()
_client = NULL;
}
- LOG(Raul::info)("Deactivated Jack client\n");
+ _engine.log().info("Deactivated Jack client\n");
}
}
@@ -227,7 +225,7 @@ void
JackDriver::unregister_port(EnginePort& port)
{
if (jack_port_unregister(_client, (jack_port_t*)port.handle())) {
- LOG(Raul::error)("Failed to unregister Jack port\n");
+ _engine.log().error("Failed to unregister Jack port\n");
}
}
@@ -293,7 +291,7 @@ JackDriver::pre_process_port(ProcessContext& context, EnginePort* port)
if (!patch_buf->append_event(
ev.time, ev.size, _midi_event_type, ev.buffer)) {
- LOG(Raul::warn)("Failed to write to MIDI buffer, events lost!\n");
+ _engine.log().warn("Failed to write to MIDI buffer, events lost!\n");
}
}
}
@@ -382,7 +380,7 @@ JackDriver::_thread_init_cb()
void
JackDriver::_shutdown_cb()
{
- LOG(Raul::info)("Jack shutdown, exiting\n");
+ _engine.log().info("Jack shutdown, exiting\n");
_is_activated = false;
_client = NULL;
}
@@ -403,7 +401,7 @@ JackDriver::_block_length_cb(jack_nframes_t nframes)
void
JackDriver::_session_cb(jack_session_event_t* event)
{
- LOG(Raul::info)(Raul::fmt("Jack session save to %1%\n") % event->session_dir);
+ _engine.log().info(Raul::fmt("Jack session save to %1%\n") % event->session_dir);
const string cmd = (boost::format("ingen -eg -n %1% -u %2% -l ${SESSION_DIR}")
% jack_get_client_name(_client)
@@ -423,7 +421,7 @@ JackDriver::_session_cb(jack_session_event_t* event)
case JackSessionSave:
break;
case JackSessionSaveAndQuit:
- LOG(Raul::warn)("Jack session quit\n");
+ _engine.log().warn("Jack session quit\n");
_engine.quit();
break;
case JackSessionSaveTemplate:
diff --git a/src/server/LV2Node.cpp b/src/server/LV2Node.cpp
index c1951baa..654aeab0 100644
--- a/src/server/LV2Node.cpp
+++ b/src/server/LV2Node.cpp
@@ -22,10 +22,10 @@
#include "lv2/lv2plug.in/ns/ext/resize-port/resize-port.h"
#include "lv2/lv2plug.in/ns/ext/morph/morph.h"
-#include "raul/log.hpp"
#include "raul/Maid.hpp"
#include "raul/Array.hpp"
+#include "ingen/Log.hpp"
#include "ingen/URIMap.hpp"
#include "ingen/URIs.hpp"
@@ -36,6 +36,7 @@
#include "LV2Node.hpp"
#include "LV2Plugin.hpp"
#include "OutputPort.hpp"
+#include "PatchImpl.hpp"
#include "ProcessContext.hpp"
using namespace std;
@@ -77,8 +78,9 @@ LV2Node::make_instance(URIs& uris,
_lv2_plugin->lilv_plugin(), rate, _features->array());
if (!inst) {
- Raul::error(Raul::fmt("Failed to instantiate <%1%>\n")
- % _lv2_plugin->uri().c_str());
+ parent_patch()->engine().log().error(
+ Raul::fmt("Failed to instantiate <%1%>\n")
+ % _lv2_plugin->uri().c_str());
return SharedPtr<LilvInstance>();
}
@@ -91,7 +93,6 @@ LV2Node::make_instance(URIs& uris,
? port->prepared_buffer(voice).get()
: port->buffer(voice).get();
if (port->is_morph() && port->is_a(PortType::CV)) {
- //Raul::info(Raul::fmt("Morphing %1% to CV\n") % port->path());
if (morph_iface) {
morph_iface->morph_port(
inst->lv2_handle, p, uris.lv2_CVPort, NULL);
@@ -115,15 +116,12 @@ LV2Node::make_instance(URIs& uris,
inst->lv2_handle, p, NULL);
if (type == _uris.lv2_ControlPort) {
port->set_type(PortType::CONTROL, 0);
- /*Raul::info(Raul::fmt("Auto-morphed %1% to control\n")
- % port->path());*/
} else if (type == _uris.lv2_CVPort) {
port->set_type(PortType::CV, 0);
- /*Raul::info(Raul::fmt("Auto-morphed %1% to CV\n")
- % port->path());*/
} else {
- Raul::error(Raul::fmt("%1% auto-morphed to unknown type %2%\n")
- % port->path().c_str() % type);
+ parent_patch()->engine().log().error(
+ Raul::fmt("%1% auto-morphed to unknown type %2%\n")
+ % port->path().c_str() % type);
return SharedPtr<LilvInstance>();
}
}
@@ -293,8 +291,9 @@ LV2Node::instantiate(BufferFactory& bufs)
}
lilv_nodes_free(sizes);
- Raul::info(Raul::fmt("Atom port %1% buffer size %2%\n")
- % path().c_str() % port_buffer_size);
+ bufs.engine().log().info(
+ Raul::fmt("Atom port %1% buffer size %2%\n")
+ % path().c_str() % port_buffer_size);
}
enum { UNKNOWN, INPUT, OUTPUT } direction = UNKNOWN;
@@ -305,8 +304,9 @@ LV2Node::instantiate(BufferFactory& bufs)
}
if (port_type == PortType::UNKNOWN || direction == UNKNOWN) {
- Raul::error(Raul::fmt("<%1%> port %2% has unknown type or direction\n")
- % _lv2_plugin->uri().c_str() % port_sym.c_str());
+ parent_patch()->engine().log().error(
+ Raul::fmt("<%1%> port %2% has unknown type or direction\n")
+ % _lv2_plugin->uri().c_str() % port_sym.c_str());
ret = false;
break;
}
@@ -422,8 +422,8 @@ LV2Node::work(uint32_t size, const void* data)
if (_worker_iface) {
LV2_Handle inst = lilv_instance_get_handle(instance(0));
if (_worker_iface->work(inst, work_respond, this, size, data)) {
- Raul::error(Raul::fmt("Error calling %1% work method\n")
- % _path.c_str());
+ parent_patch()->engine().log().error(
+ Raul::fmt("Error calling %1% work method\n") % _path);
}
}
}
diff --git a/src/server/LV2ResizeFeature.hpp b/src/server/LV2ResizeFeature.hpp
index a32d3d8f..eeab3d4a 100644
--- a/src/server/LV2ResizeFeature.hpp
+++ b/src/server/LV2ResizeFeature.hpp
@@ -19,7 +19,6 @@
#include "ingen/LV2Features.hpp"
#include "lv2/lv2plug.in/ns/ext/resize-port/resize-port.h"
-#include "raul/log.hpp"
#include "NodeImpl.hpp"
#include "PortImpl.hpp"
diff --git a/src/server/NodeFactory.cpp b/src/server/NodeFactory.cpp
index 5f525434..3f07e534 100644
--- a/src/server/NodeFactory.cpp
+++ b/src/server/NodeFactory.cpp
@@ -18,11 +18,12 @@
#include "lilv/lilv.h"
+#include "ingen/Log.hpp"
+#include "ingen/World.hpp"
#include "internals/Controller.hpp"
#include "internals/Delay.hpp"
#include "internals/Note.hpp"
#include "internals/Trigger.hpp"
-#include "ingen/World.hpp"
#include "InternalPlugin.hpp"
#include "LV2Plugin.hpp"
@@ -120,7 +121,7 @@ NodeFactory::load_lv2_plugins()
const Raul::URI uri(lilv_node_as_uri(lilv_plugin_get_uri(lv2_plug)));
if (_plugins.find(uri) != _plugins.end()) {
- Raul::warn(Raul::fmt("Already discovered <%s>\n") % uri);
+ _world->log().warn(Raul::fmt("Already discovered <%s>\n") % uri);
continue;
}
diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp
index 5ea3b93b..b280886e 100644
--- a/src/server/PatchImpl.cpp
+++ b/src/server/PatchImpl.cpp
@@ -16,9 +16,9 @@
#include <cassert>
+#include "ingen/Log.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
-#include "raul/log.hpp"
#include "BufferFactory.hpp"
#include "EdgeImpl.hpp"
@@ -216,7 +216,6 @@ PatchImpl::remove_edge(const PortImpl* tail, const PortImpl* dst_port)
_edges.erase(i);
return c;
} else {
- Raul::error << "[PatchImpl::remove_edge] Edge not found" << endl;
return SharedPtr<EdgeImpl>();
}
}
@@ -248,7 +247,8 @@ PatchImpl::create_port(BufferFactory& bufs,
bool polyphonic)
{
if (type == PortType::UNKNOWN) {
- Raul::error << "[PatchImpl::create_port] Unknown port type " << type.uri() << endl;
+ bufs.engine().log().error(Raul::fmt("Unknown port type %1%\n")
+ % type.uri());
return NULL;
}
@@ -369,7 +369,7 @@ PatchImpl::compile()
}
if (compiled_patch->size() != _nodes.size()) {
- Raul::error(Raul::fmt("Failed to compile patch %1%\n") % _path);
+ _engine.log().error(Raul::fmt("Failed to compile patch %1%\n") % _path);
delete compiled_patch;
return NULL;
}
diff --git a/src/server/Worker.cpp b/src/server/Worker.cpp
index 9f255081..e8c51335 100644
--- a/src/server/Worker.cpp
+++ b/src/server/Worker.cpp
@@ -15,8 +15,8 @@
*/
#include "ingen/LV2Features.hpp"
+#include "ingen/Log.hpp"
#include "lv2/lv2plug.in/ns/ext/worker/worker.h"
-#include "raul/log.hpp"
#include "Driver.hpp"
#include "Engine.hpp"
@@ -51,18 +51,19 @@ Worker::request(LV2Node* node,
uint32_t size,
const void* data)
{
+ Engine& engine = node->parent_patch()->engine();
if (_requests.write_space() < sizeof(MessageHeader) + size) {
- Raul::error("Work request ring overflow\n");
+ engine.log().error("Work request ring overflow\n");
return LV2_WORKER_ERR_NO_SPACE;
}
const MessageHeader msg = { node, size };
if (_requests.write(sizeof(msg), &msg) != sizeof(msg)) {
- Raul::error("Error writing header to work request ring\n");
+ engine.log().error("Error writing header to work request ring\n");
return LV2_WORKER_ERR_UNKNOWN;
}
if (_requests.write(size, data) != size) {
- Raul::error("Error writing body to work request ring\n");
+ engine.log().error("Error writing body to work request ring\n");
return LV2_WORKER_ERR_UNKNOWN;
}
@@ -99,9 +100,10 @@ Worker::Schedule::feature(World* world, GraphObject* n)
}
-Worker::Worker(uint32_t buffer_size)
+Worker::Worker(Log& log, uint32_t buffer_size)
: Raul::Thread()
, _schedule(new Schedule())
+ , _log(log)
, _sem(0)
, _requests(buffer_size)
, _responses(buffer_size)
@@ -123,17 +125,17 @@ Worker::_run()
MessageHeader msg;
if (_requests.read_space() > sizeof(msg)) {
if (_requests.read(sizeof(msg), &msg) != sizeof(msg)) {
- Raul::error("Error reading header from work request ring\n");
+ _log.error("Error reading header from work request ring\n");
continue;
}
if (msg.size >= _buffer_size - sizeof(msg)) {
- Raul::error("Corrupt work request ring\n");
+ _log.error("Corrupt work request ring\n");
return;
}
if (_requests.read(msg.size, _buffer) != msg.size) {
- Raul::error("Error reading body from work request ring\n");
+ _log.error("Error reading body from work request ring\n");
continue;
}
diff --git a/src/server/Worker.hpp b/src/server/Worker.hpp
index 25300502..0310de90 100644
--- a/src/server/Worker.hpp
+++ b/src/server/Worker.hpp
@@ -24,6 +24,9 @@
#include "raul/Thread.hpp"
namespace Ingen {
+
+class Log;
+
namespace Server {
class LV2Node;
@@ -31,7 +34,7 @@ class LV2Node;
class Worker : public Raul::Thread
{
public:
- Worker(uint32_t buffer_size);
+ Worker(Log& log, uint32_t buffer_size);
~Worker();
struct Schedule : public LV2Features::Feature {
@@ -47,6 +50,7 @@ public:
private:
SharedPtr<Schedule> _schedule;
+ Log& _log;
Raul::Semaphore _sem;
Raul::RingBuffer _requests;
Raul::RingBuffer _responses;
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 17ef8d45..1120af92 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -35,10 +35,8 @@
#include "PortType.hpp"
#include "SetPortValue.hpp"
-#define LOG(s) s << "[Delta] "
-
// #define DUMP 1
-#include "ingen/URIMap.hpp"
+// #include "ingen/URIMap.hpp"
namespace Ingen {
namespace Server {
@@ -75,20 +73,22 @@ Delta::Delta(Engine& engine,
}
#ifdef DUMP
- LOG(Raul::info) << "Delta " << subject << " : " << context << " {" << std::endl;
+ std::cerr << "Delta " << subject << " : " << context << " {" << std::endl;
typedef Resource::Properties::const_iterator iterator;
for (iterator i = properties.begin(); i != properties.end(); ++i) {
- LOG(Raul::info) << " + " << i->first
- << " = " << engine.world()->forge().str(i->second)
- << " :: " << engine.world()->uri_map().unmap_uri(i->second.type()) << std::endl;
+ std::cerr << " + " << i->first
+ << " = " << engine.world()->forge().str(i->second)
+ << " :: " << engine.world()->uri_map().unmap_uri(i->second.type())
+ << std::endl;
}
typedef Resource::Properties::const_iterator iterator;
for (iterator i = remove.begin(); i != remove.end(); ++i) {
- LOG(Raul::info) << " - " << i->first
- << " = " << engine.world()->forge().str(i->second)
- << " :: " << engine.world()->uri_map().unmap_uri(i->second.type()) << std::endl;
+ std::cerr << " - " << i->first
+ << " = " << engine.world()->forge().str(i->second)
+ << " :: " << engine.world()->uri_map().unmap_uri(i->second.type())
+ << std::endl;
}
- LOG(Raul::info) << "}" << std::endl;
+ std::cerr << "}" << std::endl;
#endif
}
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 5b756d84..9e1e9531 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -21,7 +21,6 @@
#include "ingen/Store.hpp"
#include "raul/Maid.hpp"
#include "raul/Path.hpp"
-#include "raul/log.hpp"
#include "Broadcaster.hpp"
#include "Buffer.hpp"
diff --git a/src/server/events/SetPortValue.cpp b/src/server/events/SetPortValue.cpp
index 38b36a7c..d81a38f7 100644
--- a/src/server/events/SetPortValue.cpp
+++ b/src/server/events/SetPortValue.cpp
@@ -18,7 +18,6 @@
#include "ingen/Store.hpp"
#include "ingen/URIs.hpp"
#include "ingen/World.hpp"
-#include "raul/log.hpp"
#include "Broadcaster.hpp"
#include "Buffer.hpp"
diff --git a/src/server/ingen_engine.cpp b/src/server/ingen_engine.cpp
index 3a0d4324..d0311cae 100644
--- a/src/server/ingen_engine.cpp
+++ b/src/server/ingen_engine.cpp
@@ -24,7 +24,7 @@ using namespace Ingen;
struct IngenEngineModule : public Ingen::Module {
virtual void load(Ingen::World* world) {
- Server::set_denormal_flags();
+ Server::set_denormal_flags(world->log());
SharedPtr<Server::Engine> engine(new Server::Engine(world));
world->set_engine(engine);
if (!world->interface()) {
diff --git a/src/server/ingen_jack.cpp b/src/server/ingen_jack.cpp
index 6019d1d8..ec690756 100644
--- a/src/server/ingen_jack.cpp
+++ b/src/server/ingen_jack.cpp
@@ -19,8 +19,8 @@
#include "ingen/Configuration.hpp"
#include "ingen/Module.hpp"
#include "ingen/World.hpp"
+#include "ingen/Log.hpp"
#include "raul/Configuration.hpp"
-#include "raul/log.hpp"
#include "JackDriver.hpp"
#include "Engine.hpp"
@@ -31,7 +31,7 @@ using namespace Ingen;
struct IngenJackModule : public Ingen::Module {
void load(Ingen::World* world) {
if (((Server::Engine*)world->engine().get())->driver()) {
- Raul::warn << "Engine already has a driver" << std::endl;
+ world->log().warn("Engine already has a driver\n");
return;
}
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 095e0fd6..100e1a4c 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -26,11 +26,13 @@
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h"
+#include "lv2/lv2plug.in/ns/ext/log/log.h"
#include "lv2/lv2plug.in/ns/ext/state/state.h"
#include "lv2/lv2plug.in/ns/ext/urid/urid.h"
#include "lv2/lv2plug.in/ns/lv2core/lv2.h"
#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/serialisation/Parser.hpp"
#include "ingen/serialisation/Serialiser.hpp"
#include "ingen/AtomReader.hpp"
@@ -41,7 +43,6 @@
#include "raul/Semaphore.hpp"
#include "raul/SharedPtr.hpp"
#include "raul/Thread.hpp"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "Driver.hpp"
@@ -92,6 +93,7 @@ public:
, _main_sem(0)
, _reader(engine.world()->uri_map(),
engine.world()->uris(),
+ engine.world()->log(),
engine.world()->forge(),
*engine.world()->interface().get())
, _writer(engine.world()->uri_map(),
@@ -132,7 +134,7 @@ public:
if (!patch_buf->append_event(
ev->time.frames, ev->body.size, ev->body.type,
(const uint8_t*)LV2_ATOM_BODY(&ev->body))) {
- Raul::warn("Failed to write to buffer, event lost!\n");
+ _engine.log().warn("Failed to write to buffer, event lost!\n");
}
if (AtomReader::is_message(uris, &ev->body)) {
@@ -233,7 +235,7 @@ public:
void enqueue_message(const LV2_Atom* atom) {
if (_from_ui.write(lv2_atom_total_size(atom), atom) == 0) {
#ifndef NDEBUG
- Raul::error << "Control input buffer overflow" << std::endl;
+ _engine.log().error("Control input buffer overflow\n");
#endif
}
}
@@ -260,7 +262,7 @@ public:
for (uint32_t read = 0; read < read_space;) {
LV2_Atom atom;
if (!_from_ui.read(sizeof(LV2_Atom), &atom)) {
- Raul::error << "Error reading head from from-UI ring" << std::endl;
+ _engine.log().error("Error reading head from from-UI ring\n");
break;
}
@@ -268,7 +270,7 @@ public:
memcpy(buf, &atom, sizeof(LV2_Atom));
if (!_from_ui.read(atom.size, (char*)buf + sizeof(LV2_Atom))) {
- Raul::error << "Error reading body from from-UI ring" << std::endl;
+ _engine.log().error("Error reading body from from-UI ring\n");
break;
}
@@ -283,7 +285,7 @@ public:
LV2_Atom_Sequence* seq = (LV2_Atom_Sequence*)_ports[1]->buffer();
if (!seq) {
- Raul::error << "Control out port not connected" << std::endl;
+ _engine.log().error("Control out port not connected\n");
return;
}
@@ -298,7 +300,7 @@ public:
for (uint32_t read = 0; read < read_space;) {
LV2_Atom atom;
if (!_to_ui.peek(sizeof(LV2_Atom), &atom)) {
- Raul::error << "Error reading head from to-UI ring" << std::endl;
+ _engine.log().error("Error reading head from to-UI ring\n");
break;
}
@@ -314,7 +316,7 @@ public:
_to_ui.skip(sizeof(LV2_Atom));
if (!_to_ui.read(ev->body.size, LV2_ATOM_BODY(&ev->body))) {
- Raul::error << "Error reading body from to-UI ring" << std::endl;
+ _engine.log().error("Error reading body from to-UI ring\n");
break;
}
@@ -432,8 +434,6 @@ find_patches(const Glib::ustring& manifest_uri)
patches.push_back(boost::shared_ptr<const LV2Patch>(
new LV2Patch(patch_uri, (const char*)file_path)));
free(file_path);
- } else {
- Raul::error << "[Ingen] Patch has no rdfs:seeAlso" << std::endl;
}
}
@@ -447,6 +447,23 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
const char* bundle_path,
const LV2_Feature*const* features)
{
+ // Get features from features array
+ LV2_URID_Map* map = NULL;
+ LV2_URID_Unmap* unmap = NULL;
+ LV2_Buf_Size_Access* access = NULL;
+ LV2_Log_Log* log = NULL;
+ for (int i = 0; features[i]; ++i) {
+ if (!strcmp(features[i]->URI, LV2_URID__map)) {
+ map = (LV2_URID_Map*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_URID__unmap)) {
+ unmap = (LV2_URID_Unmap*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_BUF_SIZE__access)) {
+ access = (LV2_Buf_Size_Access*)features[i]->data;
+ } else if (!strcmp(features[i]->URI, LV2_LOG__log)) {
+ log = (LV2_Log_Log*)features[i]->data;
+ }
+ }
+
if (!Glib::thread_supported()) {
Glib::thread_init();
}
@@ -464,25 +481,23 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
}
if (!patch) {
- Raul::error << "Could not find patch " << descriptor->URI << std::endl;
- return NULL;
- }
-
- IngenPlugin* plugin = new IngenPlugin();
- LV2_URID_Unmap* unmap = NULL;
- LV2_Buf_Size_Access* access = NULL;
- for (int i = 0; features[i]; ++i) {
- if (!strcmp(features[i]->URI, LV2_URID__map)) {
- plugin->map = (LV2_URID_Map*)features[i]->data;
- } else if (!strcmp(features[i]->URI, LV2_URID__unmap)) {
- unmap = (LV2_URID_Unmap*)features[i]->data;
- } else if (!strcmp(features[i]->URI, LV2_BUF_SIZE__access)) {
- access = (LV2_Buf_Size_Access*)features[i]->data;
+ const std::string msg((Raul::fmt("Could not find patch %1%\n")
+ % descriptor->URI).str());
+ if (log) {
+ log->vprintf(log->handle,
+ map->map(map->handle, LV2_LOG__Error),
+ msg.c_str(),
+ NULL);
+ } else {
+ std::cerr << msg.c_str() << std::endl;
}
+ return NULL;
}
+ IngenPlugin* plugin = new IngenPlugin();
+ plugin->map = map;
plugin->world = new Ingen::World(
- plugin->argc, plugin->argv, plugin->map, unmap);
+ plugin->argc, plugin->argv, map, unmap, log);
if (!plugin->world->load_module("serialisation")) {
delete plugin->world;
return NULL;
@@ -497,10 +512,12 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
access->get_buf_size(
access->handle, &seq_size,
plugin->world->uris().atom_Sequence, block_length);
- Raul::info(Raul::fmt("Block length: %1% frames\n") % block_length);
- Raul::info(Raul::fmt("Sequence size: %1% bytes\n") % seq_size);
+ plugin->world->log().info(
+ Raul::fmt("Block: %1% frames, Sequence: %2% bytes\n")
+ % block_length % seq_size);
} else {
- Raul::warn("Warning: No buffer size access, guessing 4096 frames.\n");
+ plugin->world->log().warn(
+ "No buffer size access, guessing 4096 frames\n");
}
SharedPtr<Server::Engine> engine(new Server::Engine(plugin->world));
@@ -559,7 +576,8 @@ ingen_connect_port(LV2_Handle instance, uint32_t port, void* data)
assert(driver->ports().at(port)->patch_port()->index() == port);
assert(driver->ports().at(port)->buffer() == data);
} else {
- Raul::warn << "Connect to non-existent port " << port << std::endl;
+ engine->log().warn(Raul::fmt("Connect to non-existent port %1%\n")
+ % port);
}
}
@@ -629,8 +647,7 @@ ingen_save(LV2_Handle instance,
LV2_State_Make_Path* make_path = NULL;
get_state_features(features, &map_path, &make_path);
if (!map_path || !make_path || !plugin->map) {
- Raul::error << "Missing state:mapPath, state:makePath, or urid:Map."
- << std::endl;
+ plugin->world->log().error("Missing state:mapPath, state:makePath, or urid:Map\n");
return LV2_STATE_ERR_NO_FEATURE;
}
@@ -668,7 +685,7 @@ ingen_restore(LV2_Handle instance,
LV2_State_Map_Path* map_path = NULL;
get_state_features(features, &map_path, NULL);
if (!map_path) {
- Raul::error << "Missing state:mapPath" << std::endl;
+ plugin->world->log().error("Missing state:mapPath\n");
return LV2_STATE_ERR_NO_FEATURE;
}
@@ -682,7 +699,7 @@ ingen_restore(LV2_Handle instance,
&size, &type, &valflags);
if (!path) {
- Raul::error << "Failed to restore ingen:file" << std::endl;
+ plugin->world->log().error("Failed to restore ingen:file\n");
return LV2_STATE_ERR_NO_PROPERTY;
}
diff --git a/src/server/internals/Delay.cpp b/src/server/internals/Delay.cpp
index d64f7a8f..26799260 100644
--- a/src/server/internals/Delay.cpp
+++ b/src/server/internals/Delay.cpp
@@ -21,7 +21,6 @@
#include "ingen/URIs.hpp"
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "Driver.hpp"
@@ -34,8 +33,6 @@
#include "internals/Delay.hpp"
#include "util.hpp"
-#define LOG(s) s << "[DelayNode] "
-
#define CALC_DELAY(delaytime) \
(f_clamp (delaytime * (float)sample_rate, 1.0f, (float)(buffer_mask + 1)))
diff --git a/src/server/internals/Note.cpp b/src/server/internals/Note.cpp
index 81562f83..25e8aee5 100644
--- a/src/server/internals/Note.cpp
+++ b/src/server/internals/Note.cpp
@@ -21,7 +21,6 @@
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
#include "raul/Array.hpp"
#include "raul/Maid.hpp"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "Driver.hpp"
@@ -34,8 +33,6 @@
#include "internals/Note.hpp"
#include "util.hpp"
-#define LOG(s) s << "[NoteNode] "
-
// #define NOTE_DEBUG 1
using namespace std;
@@ -190,9 +187,6 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F
uint32_t voice_num = 0;
if (key->state != Key::OFF) {
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "Double midi note received" << endl;
-#endif
return;
}
@@ -221,19 +215,11 @@ NoteNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity, F
assert(voice != NULL);
assert(voice == &(*_voices)[voice_num]);
-#ifdef NOTE_DEBUG
- LOG(Raul::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;
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "Stole voice " << voice_num << endl;
-#endif
}
// Store key information for later reallocation on note off
@@ -268,31 +254,15 @@ NoteNode::note_off(ProcessContext& context, uint8_t note_num, FrameTime time)
Key* key = &_keys[note_num];
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "Note " << (int)note_num << " off @ " << time << endl;
-#endif
-
if (key->state == Key::ON_ASSIGNED) {
// Assigned key, turn off voice and key
if ((*_voices)[key->voice].state == Voice::ACTIVE) {
assert((*_voices)[key->voice].note == note_num);
-
if ( ! _sustain) {
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "Free voice " << key->voice << endl;
-#endif
free_voice(context, key->voice, time);
} else {
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "Hold voice " << key->voice << endl;
-#endif
(*_voices)[key->voice].state = Voice::HOLDING;
}
-
- } else {
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "WARNING: Assigned key, but voice not active" << endl;
-#endif
}
}
@@ -331,9 +301,6 @@ 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)
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "Note off: key " << (int)(*_voices)[voice].note << " voice " << voice << endl;
-#endif
_gate_port->set_voice_value(context, voice, time, 0.0f);
(*_voices)[voice].state = Voice::FREE;
}
@@ -344,10 +311,6 @@ NoteNode::all_notes_off(ProcessContext& context, FrameTime time)
{
assert(time >= context.start() && time <= context.end());
-#ifdef NOTE_DEBUG
- LOG(Raul::debug) << "All notes off @ " << time << endl;
-#endif
-
// FIXME: set all keys to Key::OFF?
for (uint32_t i = 0; i < _polyphony; ++i) {
diff --git a/src/server/internals/Trigger.cpp b/src/server/internals/Trigger.cpp
index 81361bb8..f7bbd4c5 100644
--- a/src/server/internals/Trigger.cpp
+++ b/src/server/internals/Trigger.cpp
@@ -19,7 +19,6 @@
#include "ingen/URIs.hpp"
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "lv2/lv2plug.in/ns/ext/midi/midi.h"
-#include "raul/log.hpp"
#include "Buffer.hpp"
#include "Engine.hpp"
@@ -31,8 +30,6 @@
#include "internals/Trigger.hpp"
#include "util.hpp"
-#define LOG(s) s << "[TriggerNode] "
-
using namespace std;
namespace Ingen {
@@ -140,10 +137,6 @@ TriggerNode::note_on(ProcessContext& context, uint8_t note_num, uint8_t velocity
_learning = false;
}
-#ifdef RAUL_LOG_DEBUG
- LOG(Raul::debug) << path() << " note " << (int)note_num << " on @ " << time << endl;
-#endif
-
Sample filter_note = _note_port->buffer(0)->value_at(0);
if (filter_note >= 0.0 && filter_note < 127.0 && (note_num == (uint8_t)filter_note)) {
_gate_port->set_control_value(context, time, 1.0f);
diff --git a/src/server/mix.cpp b/src/server/mix.cpp
index 773b2aa7..c4fbbed5 100644
--- a/src/server/mix.cpp
+++ b/src/server/mix.cpp
@@ -16,8 +16,6 @@
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
-#include "raul/log.hpp"
-
#include "Buffer.hpp"
#include "Context.hpp"
#include "mix.hpp"
diff --git a/src/server/util.hpp b/src/server/util.hpp
index 8f5a39ee..106d09de 100644
--- a/src/server/util.hpp
+++ b/src/server/util.hpp
@@ -19,7 +19,7 @@
#include <cstdlib>
-#include "raul/log.hpp"
+#include "ingen/Log.hpp"
#include "raul/Path.hpp"
#include "ingen_config.h"
@@ -35,48 +35,17 @@
# define REALTIME
#endif
-#ifdef USE_ASSEMBLY
-# if SIZEOF_VOID_P==8
-# define cpuid(a, b, c, d, n) asm("xchgq %%rbx, %1; cpuid; xchgq %%rbx, %1": "=a" (a), "=r" (b), "=c" (c), "=d" (d) : "a" (n));
-# else
-# define cpuid(a, b, c, d, n) asm("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1": "=a" (a), "=r" (b), "=c" (c), "=d" (d) : "a" (n));
-# endif
-#endif
-
namespace Ingen {
namespace Server {
/** Set flags to disable denormal processing.
*/
inline void
-set_denormal_flags()
+set_denormal_flags(Ingen::Log& log)
{
-#ifdef USE_ASSEMBLY
#ifdef __SSE__
- unsigned long a, b, c, d0, d1;
- cpuid(a, b, c, d1, 1);
- if (d1 & 1<<25) { /* It has SSE support */
- _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON);
- const int family = (a >> 8) & 0xF;
- const int extfamily = (a >> 20) & 0xFF;
- const int model = (a >> 4) & 0xF;
- const int stepping = a & 0xF;
- cpuid(a, b, c, d0, 0);
- if (b == 0x756e6547) { /* It's an Intel */
- if (family == 15 && extfamily == 0 && model == 0 && stepping < 7) {
- return;
- }
- }
- if (d1 & 1<<26) { /* bit 26, SSE2 support */
- _mm_setcsr(_mm_getcsr() | 0x8040); // set DAZ and FZ bits of MXCSR
- Raul::info << "Set SSE denormal fix flag" << endl;
- }
- } else {
- 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
+ _mm_setcsr(_mm_getcsr() | 0x8040);
+ log.info("Set SSE denormal-are-zero and flush-to-zero flags\n");
#endif
}
diff --git a/src/socket/Socket.cpp b/src/socket/Socket.cpp
index 998d1cdb..d8329fef 100644
--- a/src/socket/Socket.cpp
+++ b/src/socket/Socket.cpp
@@ -24,12 +24,8 @@
#include <string>
-#include "raul/log.hpp"
-
#include "Socket.hpp"
-#define LOG(s) (s("[Socket] "))
-
namespace Ingen {
namespace Socket {
@@ -103,8 +99,6 @@ Socket::set_addr(const Raul::URI& uri)
struct addrinfo* ainfo;
int st = 0;
if ((st = getaddrinfo(host.c_str(), port.c_str(), NULL, &ainfo))) {
- LOG(Raul::error)(Raul::fmt("Error in getaddrinfo: %1%\n")
- % gai_strerror(st));
return false;
}
@@ -125,8 +119,6 @@ Socket::bind(const Raul::URI& uri)
return true;
}
- LOG(Raul::error)(Raul::fmt("Failed to bind <%1%> (%2%)\n")
- % _uri % strerror(errno));
return false;
}
@@ -137,8 +129,6 @@ Socket::connect(const Raul::URI& uri)
return true;
}
- LOG(Raul::error)(Raul::fmt("Failed to connect <%1%> (%2%)\n")
- % _uri % strerror(errno));
return false;
}
@@ -146,10 +136,8 @@ bool
Socket::listen()
{
if (::listen(_sock, 64) == -1) {
- LOG(Raul::error)(Raul::fmt("Failed to listen on %1%\n") % _uri);
return false;
} else {
- LOG(Raul::info)(Raul::fmt("Listening on %1%\n") % _uri);
return true;
}
}
@@ -163,8 +151,6 @@ Socket::accept()
int conn = ::accept(_sock, client_addr, &client_addr_len);
if (conn == -1) {
- LOG(Raul::error)(Raul::fmt("Error accepting connection: %1%\n")
- % strerror(errno));
return SharedPtr<Socket>();
}
diff --git a/src/socket/SocketListener.cpp b/src/socket/SocketListener.cpp
index f272513e..76afb4fd 100644
--- a/src/socket/SocketListener.cpp
+++ b/src/socket/SocketListener.cpp
@@ -19,9 +19,10 @@
#include <sstream>
-#include "ingen/Interface.hpp"
#include "ingen/AtomReader.hpp"
#include "ingen/Configuration.hpp"
+#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/World.hpp"
#include "sord/sordmm.hpp"
#include "sratom/sratom.h"
@@ -31,8 +32,6 @@
#include "SocketListener.hpp"
#include "SocketServer.hpp"
-#define LOG(s) s << "[SocketListener] "
-
namespace Ingen {
namespace Socket {
@@ -46,7 +45,7 @@ SocketListener::SocketListener(Ingen::World& world)
_unix_path = world.conf().option("socket").get_string();
const Raul::URI unix_uri("unix://" + _unix_path);
if (!_unix_sock.bind(unix_uri) || !_unix_sock.listen()) {
- LOG(Raul::error) << "Failed to create UNIX socket" << std::endl;
+ _world.log().error("Failed to create UNIX socket\n");
_unix_sock.close();
}
@@ -56,7 +55,7 @@ SocketListener::SocketListener(Ingen::World& world)
ss << "tcp://localhost:";
ss << port;
if (!_net_sock.bind(Raul::URI(ss.str())) || !_net_sock.listen()) {
- LOG(Raul::error) << "Failed to create TCP socket" << std::endl;
+ _world.log().error("Failed to create TCP socket\n");
_net_sock.close();
}
@@ -100,10 +99,10 @@ SocketListener::_run()
if (_exit_flag) {
break;
} else if (ret == -1) {
- LOG(Raul::error) << "Poll error: " << strerror(errno) << std::endl;
+ _world.log().error(Raul::fmt("Poll error: %1%\n") % strerror(errno));
break;
} else if (ret == 0) {
- LOG(Raul::error) << "Poll returned with no data" << std::endl;
+ _world.log().error("Poll returned with no data\n");
continue;
}
diff --git a/src/socket/SocketReader.cpp b/src/socket/SocketReader.cpp
index 8b580b18..c1e8dfd3 100644
--- a/src/socket/SocketReader.cpp
+++ b/src/socket/SocketReader.cpp
@@ -17,8 +17,9 @@
#include <errno.h>
#include <poll.h>
-#include "ingen/Interface.hpp"
#include "ingen/AtomReader.hpp"
+#include "ingen/Interface.hpp"
+#include "ingen/Log.hpp"
#include "ingen/URIMap.hpp"
#include "ingen/World.hpp"
#include "sord/sordmm.hpp"
@@ -26,8 +27,6 @@
#include "SocketReader.hpp"
-#define LOG(s) s << "[SocketReader] "
-
namespace Ingen {
namespace Socket {
@@ -121,8 +120,8 @@ SocketReader::_run()
// Read directly from the connection with serd
FILE* f = fdopen(_socket->fd(), "r");
if (!f) {
- LOG(Raul::error) << "Failed to open connection "
- << "(" << strerror(errno) << ")" << std::endl;
+ _world.log().error(Raul::fmt("Failed to open connection (%1%)\n")
+ % strerror(errno));
// Connection gone, exit
_socket.reset();
return;
@@ -131,7 +130,11 @@ SocketReader::_run()
serd_reader_start_stream(reader, f, (const uint8_t*)"(socket)", false);
// Make an AtomReader to call Ingen Interface methods based on Atom
- AtomReader ar(_world.uri_map(), _world.uris(), _world.forge(), _iface);
+ AtomReader ar(_world.uri_map(),
+ _world.uris(),
+ _world.log(),
+ _world.forge(),
+ _iface);
struct pollfd pfd;
pfd.fd = _socket->fd();
@@ -156,10 +159,11 @@ SocketReader::_run()
if (st == SERD_FAILURE) {
continue; // Read nothing, e.g. just whitespace
} else if (st) {
- LOG(Raul::error) << "Read error: " << serd_strerror(st) << std::endl;
+ _world.log().error(Raul::fmt("Read error: %1%\n")
+ % serd_strerror(st));
continue;
} else if (!_msg_node) {
- LOG(Raul::error) << "Received empty message" << std::endl;
+ _world.log().error("Received empty message\n");
continue;
}
diff --git a/src/socket/ingen_socket_client.cpp b/src/socket/ingen_socket_client.cpp
index 0e8c95bf..e835adc8 100644
--- a/src/socket/ingen_socket_client.cpp
+++ b/src/socket/ingen_socket_client.cpp
@@ -14,9 +14,11 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <errno.h>
+
+#include "ingen/Log.hpp"
#include "ingen/Module.hpp"
#include "ingen/World.hpp"
-#include "raul/log.hpp"
#include "Socket.hpp"
#include "SocketClient.hpp"
@@ -29,6 +31,8 @@ new_socket_interface(Ingen::World* world,
SharedPtr<Ingen::Socket::Socket> sock(
new Ingen::Socket::Socket(Ingen::Socket::Socket::type_from_uri(uri)));
if (!sock->connect(uri)) {
+ world->log().error(Raul::fmt("Failed to connect <%1%> (%2%)\n")
+ % sock->uri() % strerror(errno));
return SharedPtr<Ingen::Interface>();
}
Ingen::Socket::SocketClient* client = new Ingen::Socket::SocketClient(
diff --git a/src/socket/ingen_socket_server.cpp b/src/socket/ingen_socket_server.cpp
index aa13eebd..45c587ce 100644
--- a/src/socket/ingen_socket_server.cpp
+++ b/src/socket/ingen_socket_server.cpp
@@ -14,8 +14,6 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "raul/log.hpp"
-
#include "ingen/Module.hpp"
#include "ingen/World.hpp"
diff --git a/src/wscript b/src/wscript
index a65cfdbd..8ff69a91 100644
--- a/src/wscript
+++ b/src/wscript
@@ -9,6 +9,7 @@ sources = [
'Configuration.cpp',
'Forge.cpp',
'LV2Features.cpp',
+ 'Log.cpp',
'Resource.cpp',
'Store.cpp',
'URIMap.cpp',
diff --git a/wscript b/wscript
index 6fcaa628..cbf932d1 100644
--- a/wscript
+++ b/wscript
@@ -33,8 +33,6 @@ def options(opt):
help="Do not build Socket interface")
opt.add_option('--test', action='store_true', default=False, dest='build_tests',
help="Build unit tests")
- opt.add_option('--log-debug', action='store_true', default=False, dest='log_debug',
- help="Print debugging output")
def configure(conf):
conf.load('compiler_cxx')
@@ -116,9 +114,6 @@ def configure(conf):
autowaf.define(conf, 'INGEN_BUNDLE_DIR',
os.path.join(conf.env.LV2DIR, 'ingen.lv2'))
- if Options.options.log_debug:
- autowaf.define(conf, 'RAUL_LOG_DEBUG', 1)
-
conf.write_config_header('ingen_config.h', remove=False)
autowaf.display_msg(conf, "Jack", conf.is_defined('HAVE_JACK'))