From 318b37d8b556add13b3f156f31c9e72eca339a16 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 17 Aug 2012 02:14:07 +0000 Subject: Implement real logging system, LV2 log extension support, and purge evil/ugly/untranslatable C++ stream printing. Remove coloured log stuff from Raul. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4717 a436a847-0d15-0410-975c-d299462d15a1 --- ingen/AtomReader.hpp | 8 ++++- ingen/Log.hpp | 48 +++++++++++++++++++++++++++++ ingen/Resource.hpp | 2 -- ingen/URIMap.hpp | 8 +++-- ingen/URIs.hpp | 3 ++ ingen/World.hpp | 8 ++++- ingen/client/ClientStore.hpp | 6 ++-- ingen/client/PortModel.hpp | 1 - ingen/client/ThreadedSigClientInterface.hpp | 2 -- 9 files changed, 74 insertions(+), 12 deletions(-) create mode 100644 ingen/Log.hpp (limited to 'ingen') 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 + + 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 . +*/ + +#ifndef INGEN_LOG_HPP +#define INGEN_LOG_HPP + +#include + +#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 #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 #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 engine = SharedPtr(), SharedPtr emitter = SharedPtr()); @@ -127,6 +128,7 @@ private: const Raul::Path& head_path); URIs& _uris; + Log& _log; SharedPtr _engine; SharedPtr _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 #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; } } } -- cgit v1.2.1