diff options
author | David Robillard <d@drobilla.net> | 2012-05-10 06:24:07 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2012-05-10 06:24:07 +0000 |
commit | 0c9e861caa8b1eed5068942edc35d5f91bac816e (patch) | |
tree | b241856ddf49e1b1192f8ea442d1733d9d31b2f2 /src/shared | |
parent | 8ec295a0f2a40086ed83e8d2ad8ad38c8125bcb4 (diff) | |
download | ingen-0c9e861caa8b1eed5068942edc35d5f91bac816e.tar.gz ingen-0c9e861caa8b1eed5068942edc35d5f91bac816e.tar.bz2 ingen-0c9e861caa8b1eed5068942edc35d5f91bac816e.zip |
Work towards translatable strings and a cleaner log interface.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4338 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/Builder.cpp | 1 | ||||
-rw-r--r-- | src/shared/ClashAvoider.cpp | 35 | ||||
-rw-r--r-- | src/shared/Configuration.cpp | 2 | ||||
-rw-r--r-- | src/shared/Module.cpp | 2 | ||||
-rw-r--r-- | src/shared/ResourceImpl.cpp | 5 | ||||
-rw-r--r-- | src/shared/Store.cpp | 3 | ||||
-rw-r--r-- | src/shared/URIMap.cpp | 1 | ||||
-rw-r--r-- | src/shared/URIs.cpp | 1 | ||||
-rw-r--r-- | src/shared/World.cpp | 29 | ||||
-rw-r--r-- | src/shared/runtime_paths.cpp | 2 |
10 files changed, 36 insertions, 45 deletions
diff --git a/src/shared/Builder.cpp b/src/shared/Builder.cpp index b0f095ca..68d7ab08 100644 --- a/src/shared/Builder.cpp +++ b/src/shared/Builder.cpp @@ -26,7 +26,6 @@ #include "raul/Path.hpp" using namespace std; -using namespace Raul; namespace Ingen { namespace Shared { diff --git a/src/shared/ClashAvoider.cpp b/src/shared/ClashAvoider.cpp index 3859ef76..89771b0f 100644 --- a/src/shared/ClashAvoider.cpp +++ b/src/shared/ClashAvoider.cpp @@ -23,24 +23,23 @@ #include "ingen/shared/Store.hpp" using namespace std; -using namespace Raul; namespace Ingen { namespace Shared { -const URI +const Raul::URI ClashAvoider::map_uri(const Raul::URI& in) { - if (Path::is_path(in)) + if (Raul::Path::is_path(in)) return map_path(in.str()); else return in; } -const Path +const Raul::Path ClashAvoider::map_path(const Raul::Path& in) { - debug << "MAP PATH: " << in; + Raul::debug << "MAP PATH: " << in; unsigned offset = 0; bool has_offset = false; @@ -50,31 +49,31 @@ ClashAvoider::map_path(const Raul::Path& in) has_offset = (sscanf(trailing.c_str(), "%u", &offset) > 0); } - debug << "OFFSET: " << offset << endl; + Raul::debug << "OFFSET: " << offset << endl; // Path without _n suffix - Path base_path = in; + Raul::Path base_path = in; if (has_offset) base_path = base_path.substr(0, base_path.find_last_of('_')); - debug << "BASE: " << base_path << endl; + Raul::debug << "BASE: " << base_path << endl; SymbolMap::iterator m = _symbol_map.find(in); if (m != _symbol_map.end()) { - debug << " (1) " << m->second << endl; + Raul::debug << " (1) " << m->second << endl; return m->second; } else { typedef std::pair<SymbolMap::iterator, bool> InsertRecord; // See if parent is mapped - Path parent = in.parent(); + Raul::Path parent = in.parent(); do { - debug << "CHECK: " << parent << endl; + Raul::debug << "CHECK: " << parent << endl; SymbolMap::iterator p = _symbol_map.find(parent); if (p != _symbol_map.end()) { - const Path mapped = p->second.base() + in.substr(parent.base().length()); + const Raul::Path mapped = p->second.base() + in.substr(parent.base().length()); InsertRecord i = _symbol_map.insert(make_pair(in, mapped)); - debug << " (2) " << i.first->second << endl; + Raul::debug << " (2) " << i.first->second << endl; return i.first->second; } parent = parent.parent(); @@ -84,7 +83,7 @@ ClashAvoider::map_path(const Raul::Path& in) if (!exists(in) && _symbol_map.find(in) == _symbol_map.end()) { InsertRecord i = _symbol_map.insert(make_pair(in, in)); assert(i.second); - debug << " (3) " << i.first->second << endl; + Raul::debug << " (3) " << i.first->second << endl; return i.first->second; // Append _2 _3 etc until an unused symbol is found @@ -98,7 +97,7 @@ ClashAvoider::map_path(const Raul::Path& in) parent_str = parent_str.substr(0, parent_str.find_last_of("/")); if (parent_str.empty()) parent_str = "/"; - debug << "PARENT: " << parent_str << endl; + Raul::debug << "PARENT: " << parent_str << endl; } if (offset == 0) @@ -112,13 +111,13 @@ ClashAvoider::map_path(const Raul::Path& in) name = "_"; string str = ss.str(); InsertRecord i = _symbol_map.insert(make_pair(in, str)); - debug << "HIT: offset = " << offset << ", str = " << str << endl; + Raul::debug << "HIT: offset = " << offset << ", str = " << str << endl; offset = _store.child_name_offset(in.parent(), name, false); _offsets.insert(make_pair(base_path, offset)); - debug << " (4) " << i.first->second << endl; + Raul::debug << " (4) " << i.first->second << endl; return i.first->second; } else { - debug << "MISSED OFFSET: " << in << " => " << ss.str() << endl; + Raul::debug << "MISSED OFFSET: " << in << " => " << ss.str() << endl; if (o != _offsets.end()) offset = ++o->second; else diff --git a/src/shared/Configuration.cpp b/src/shared/Configuration.cpp index aecf0e5b..28038466 100644 --- a/src/shared/Configuration.cpp +++ b/src/shared/Configuration.cpp @@ -16,8 +16,6 @@ #include "ingen/shared/Configuration.hpp" -using namespace Raul; - namespace Ingen { namespace Shared { diff --git a/src/shared/Module.cpp b/src/shared/Module.cpp index 8ec733aa..9ef8f0d6 100644 --- a/src/shared/Module.cpp +++ b/src/shared/Module.cpp @@ -26,7 +26,7 @@ namespace Shared { Module::~Module() { - Raul::info << "[Module] Unloading " << library->get_name() << std::endl; + Raul::info("[Module] ")(Raul::fmt("Unloading %1%\n") % library->get_name()); } } // namespace Shared diff --git a/src/shared/ResourceImpl.cpp b/src/shared/ResourceImpl.cpp index 9bf7384e..9d97d5df 100644 --- a/src/shared/ResourceImpl.cpp +++ b/src/shared/ResourceImpl.cpp @@ -20,7 +20,6 @@ #include "raul/log.hpp" using namespace std; -using namespace Raul; namespace Ingen { namespace Shared { @@ -120,9 +119,9 @@ ResourceImpl::type(const URIs& uris, patch = node = port = is_output = false; for (iterator i = types_range.first; i != types_range.second; ++i) { - const Atom& atom = i->second; + const Raul::Atom& atom = i->second; if (atom.type() != uris.forge.URI) { - warn << "[ResourceImpl] Non-URI type " << uris.forge.str(atom) << endl; + Raul::warn << "[ResourceImpl] Non-URI type " << uris.forge.str(atom) << endl; continue; } diff --git a/src/shared/Store.cpp b/src/shared/Store.cpp index c3d427a9..c0d373d6 100644 --- a/src/shared/Store.cpp +++ b/src/shared/Store.cpp @@ -23,7 +23,6 @@ #include "ingen/shared/Store.hpp" using namespace std; -using namespace Raul; namespace Ingen { namespace Shared { @@ -32,7 +31,7 @@ void Store::add(GraphObject* o) { if (find(o->path()) != end()) { - error << "[Store] Attempt to add duplicate object " << o->path() << endl; + Raul::error << "[Store] Attempt to add duplicate object " << o->path() << endl; return; } diff --git a/src/shared/URIMap.cpp b/src/shared/URIMap.cpp index 144941e9..e8c7fbbc 100644 --- a/src/shared/URIMap.cpp +++ b/src/shared/URIMap.cpp @@ -28,7 +28,6 @@ #include "raul/log.hpp" using namespace std; -using namespace Raul; namespace Ingen { namespace Shared { diff --git a/src/shared/URIs.cpp b/src/shared/URIs.cpp index 56189ed5..712a0cb2 100644 --- a/src/shared/URIs.cpp +++ b/src/shared/URIs.cpp @@ -32,7 +32,6 @@ #include "raul/log.hpp" using namespace std; -using namespace Raul; namespace Ingen { namespace Shared { diff --git a/src/shared/World.cpp b/src/shared/World.cpp index 1d47100a..28ad1a34 100644 --- a/src/shared/World.cpp +++ b/src/shared/World.cpp @@ -34,10 +34,9 @@ #include "ingen/shared/URIMap.hpp" #include "ingen/shared/URIs.hpp" -#define LOG(s) s << "[Module] " +#define LOG(s) (s("[World] ")) using namespace std; -using namespace Raul; namespace Ingen { namespace Shared { @@ -66,11 +65,11 @@ ingen_load_module(const string& name) if (Glib::file_test(filename, Glib::FILE_TEST_EXISTS)) { module = new Glib::Module(filename, Glib::MODULE_BIND_LAZY); if (*module) { - LOG(info) << "Loading " << filename << endl; + LOG(Raul::info)(Raul::fmt("Loading %1%\n") % filename); return SharedPtr<Glib::Module>(module); } else { delete module; - error << Glib::Module::get_last_error() << endl; + Raul::error << Glib::Module::get_last_error() << endl; } } } @@ -83,16 +82,16 @@ ingen_load_module(const string& name) module->make_resident(); if (*module) { - LOG(info) << "Loading " << Shared::module_path(name) << endl; + LOG(Raul::info)(Raul::fmt("Loading %1%\n") % Shared::module_path(name)); return SharedPtr<Glib::Module>(module); } else if (!module_path_found) { - LOG(error) << "Unable to find " << name - << " (" << Glib::Module::get_last_error() << ")" << endl; + LOG(Raul::error)(Raul::fmt("Unable to find %1% (%2%)\n") + % name % Glib::Module::get_last_error()); return SharedPtr<Glib::Module>(); } else { - LOG(error) << "Unable to load " << name << " from " << module_path - << " (" << Glib::Module::get_last_error() << ")" << endl; - LOG(error) << "Is Ingen installed?" << endl; + 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"); return SharedPtr<Glib::Module>(); } } @@ -231,7 +230,7 @@ World::load_module(const char* name) { Pimpl::Modules::iterator i = _impl->modules.find(name); if (i != _impl->modules.end()) { - LOG(info) << "Module `" << name << "' already loaded" << endl; + LOG(Raul::info)(Raul::fmt("Module `%1%' already loaded\n") % name); return true; } SharedPtr<Glib::Module> lib = ingen_load_module(name); @@ -243,7 +242,7 @@ World::load_module(const char* name) _impl->modules.insert(make_pair(string(name), module)); return true; } else { - LOG(error) << "Failed to load module `" << name << "'" << endl; + LOG(Raul::error)(Raul::fmt("Failed to load module `%1%'\n") % name); return false; } } @@ -253,7 +252,7 @@ World::run_module(const char* name) { Pimpl::Modules::iterator i = _impl->modules.find(name); if (i == _impl->modules.end()) { - LOG(error) << "Attempt to run unloaded module `" << name << "'" << endl; + LOG(Raul::error) << "Attempt to run unloaded module `" << name << "'" << endl; return false; } @@ -278,7 +277,7 @@ World::interface(const std::string& engine_url, const string scheme = engine_url.substr(0, engine_url.find(":")); const Pimpl::InterfaceFactories::const_iterator i = _impl->interface_factories.find(scheme); if (i == _impl->interface_factories.end()) { - warn << "Unknown URI scheme `" << scheme << "'" << endl; + Raul::warn << "Unknown URI scheme `" << scheme << "'" << endl; return SharedPtr<Interface>(); } @@ -291,7 +290,7 @@ World::run(const std::string& mime_type, const std::string& filename) { const Pimpl::ScriptRunners::const_iterator i = _impl->script_runners.find(mime_type); if (i == _impl->script_runners.end()) { - warn << "Unknown script MIME type `" << mime_type << "'" << endl; + Raul::warn << "Unknown script MIME type `" << mime_type << "'" << endl; return false; } diff --git a/src/shared/runtime_paths.cpp b/src/shared/runtime_paths.cpp index 9a5b4cdf..48b670bc 100644 --- a/src/shared/runtime_paths.cpp +++ b/src/shared/runtime_paths.cpp @@ -52,7 +52,7 @@ set_bundle_path_from_code(void* function) const char* bin_loc = dli.dli_fname; #endif - Raul::info << "[Module] Binary location: " << bin_loc << std::endl; + 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)); |