diff options
author | David Robillard <d@drobilla.net> | 2010-01-06 23:49:17 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2010-01-06 23:49:17 +0000 |
commit | cb5e934666e128e27faa95587fbdecf01f0e324d (patch) | |
tree | 1e694e2812381efbb3eb4b5ace2cdecc118b29f6 /src/serialisation | |
parent | 092eb35edb999a9dd809e197d7dd9a4ebb0d6bd5 (diff) | |
download | ingen-cb5e934666e128e27faa95587fbdecf01f0e324d.tar.gz ingen-cb5e934666e128e27faa95587fbdecf01f0e324d.tar.bz2 ingen-cb5e934666e128e27faa95587fbdecf01f0e324d.zip |
Do all logging output via Raul streams.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@2349 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/serialisation')
-rw-r--r-- | src/serialisation/Parser.cpp | 50 | ||||
-rw-r--r-- | src/serialisation/Serialiser.cpp | 16 |
2 files changed, 34 insertions, 32 deletions
diff --git a/src/serialisation/Parser.cpp b/src/serialisation/Parser.cpp index c3137e05..cee4d656 100644 --- a/src/serialisation/Parser.cpp +++ b/src/serialisation/Parser.cpp @@ -15,10 +15,10 @@ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include <iostream> #include <set> #include <locale.h> #include <glibmm/ustring.h> +#include "raul/log.hpp" #include "redlandmm/Model.hpp" #include "redlandmm/Node.hpp" #include "redlandmm/Query.hpp" @@ -28,6 +28,8 @@ #include "interface/EngineInterface.hpp" #include "Parser.hpp" +#define LOG(s) s << "[Parser] " + using namespace std; using namespace Raul; using namespace Ingen::Shared; @@ -97,13 +99,13 @@ Parser::parse_document( Redland::Model model(*world->rdf_world, document_uri, document_uri); - cout << "[Parser] Parsing document " << document_uri << endl; + LOG(info) << "Parsing document " << document_uri << endl; if (data_path) - cout << "[Parser] Document path: " << *data_path << endl; + LOG(info) << "Document path: " << *data_path << endl; if (parent) - cout << "[Parser] Parent: " << *parent << endl; + LOG(info) << "Parent: " << *parent << endl; if (symbol) - cout << "[Parser] Symbol: " << *symbol << endl; + LOG(info) << "Symbol: " << *symbol << endl; boost::optional<Path> parsed_path = parse(world, target, model, document_uri, data_path, parent, symbol, data); @@ -111,7 +113,7 @@ Parser::parse_document( if (parsed_path) { target->set_property(*parsed_path, "ingen:document", Atom(Atom::URI, document_uri.c_str())); } else { - cerr << "WARNING: document URI lost" << endl; + LOG(warn) << "Document URI lost" << endl; } return parsed_path; @@ -131,10 +133,10 @@ Parser::parse_string( { Redland::Model model(*world->rdf_world, str.c_str(), str.length(), base_uri); - cout << "Parsing " << (data_path ? data_path->str() : "*") << " from string"; + LOG(info) << "Parsing " << (data_path ? data_path->str() : "*") << " from string"; if (base_uri != "") - cout << " (base " << base_uri << ")"; - cout << endl; + LOG(info) << " (base " << base_uri << ")"; + LOG(info) << endl; bool ret = parse(world, target, model, base_uri, data_path, parent, symbol, data); Redland::Resource subject(*world->rdf_world, base_uri); @@ -272,7 +274,7 @@ Parser::parse( path_str = "/" + path_str; if (!Path::is_valid(path_str)) { - cerr << "WARNING: Invalid path '" << path_str << "', object skipped" << endl; + LOG(warn) << "Invalid path '" << path_str << "', object skipped" << endl; continue; } @@ -281,7 +283,7 @@ Parser::parse( : (parent ? parent->base() : "/") + path_str.substr(path_str.find("/")+1); if (!Path::is_valid(path)) { - cerr << "WARNING: Invalid path '" << path << "' transformed to /" << endl; + LOG(warn) << "Invalid path '" << path << "' transformed to /" << endl; path = "/"; } @@ -294,7 +296,7 @@ Parser::parse( } if (!ret) { - cerr << "Failed to parse object " << path << endl; + LOG(error) << "Failed to parse object " << path << endl; return boost::optional<Path>(); } @@ -339,8 +341,6 @@ Parser::parse_patch( const Glib::ustring subject = subject_node.to_turtle_token(); - //cout << "**** Parse patch " << subject << endl; - /* Load polyphony from file if necessary */ if (patch_poly == 0) { Redland::Query query(*world->rdf_world, Glib::ustring( @@ -352,7 +352,7 @@ Parser::parse_patch( if (poly_node.is_int()) patch_poly = poly_node.to_int(); else - cerr << "WARNING: Patch has non-integer polyphony, assuming 1" << endl; + LOG(warn) << "Patch has non-integer polyphony, assuming 1" << endl; } } @@ -374,7 +374,7 @@ Parser::parse_patch( string patch_path_str = relative_uri(base_uri, subject_node.to_string(), true); if (!Path::is_valid(patch_path_str)) { - cerr << "ERROR: Patch has invalid path: " << patch_path_str << endl; + LOG(error) << "Patch has invalid path: " << patch_path_str << endl; return boost::optional<Raul::Path>(); } @@ -454,7 +454,7 @@ Parser::parse_patch( } else if (plug_i != plugin_nodes.end()) { plug_i->second.insert(make_pair(key, AtomRDF::node_to_atom(object))); } else { - cerr << "WARNING: Unrecognized node: " << node.to_string() << endl; + LOG(warn) << "Unrecognized node: " << node.to_string() << endl; } } } @@ -501,7 +501,7 @@ Parser::parse_patch( const string node_uri = (*i)["node"].to_string(); const string port_uri = (*i)["port"].to_string(); if (port_uri.length() <= node_uri.length()) { - cerr << "WARNING: Port on " << node_uri << " has bad URI: " << port_uri << endl; + LOG(warn) << "Port on " << node_uri << " has bad URI: " << port_uri << endl; continue; } @@ -565,7 +565,7 @@ Parser::parse_patch( std::pair<Properties::iterator,Properties::iterator> types_range = i->second.equal_range("rdf:type"); if (types_range.first == i->second.end()) { - cerr << "WARNING: Patch port has no types" << endl; + LOG(warn) << "Patch port has no types" << endl; continue; } bool is_input = false; @@ -581,12 +581,12 @@ Parser::parse_patch( } else if (!type) { type = &t->second; } else { - cerr << "ERROR: Port has several data types" << endl; + LOG(error) << "Port has several data types" << endl; continue; } } if ((is_input && is_output) || !type) { - cerr << "ERROR: Corrupt patch port" << endl; + LOG(error) << "Corrupt patch port" << endl; continue; } @@ -611,7 +611,7 @@ Parser::parse_patch( target->set_property(patch_path, "ingen:enabled", (bool)true); break; } else { - cerr << "WARNING: Unknown type for ingen:enabled" << endl; + LOG(warn) << "Unknown type for ingen:enabled" << endl; } } @@ -637,13 +637,13 @@ Parser::parse_node( Redland::Query::Results results = query.run(*world->rdf_world, model); if (results.size() == 0) { - cerr << "[Parser] ERROR: Node missing mandatory rdf:instanceOf property" << endl; + LOG(error) << "Node missing mandatory rdf:instanceOf property" << endl; return boost::optional<Path>(); } const Redland::Node& plugin_node = (*results.begin())["plug"]; if (plugin_node.type() != Redland::Node::RESOURCE) { - cerr << "[Parser] ERROR: node's rdf:instanceOf property is not a resource" << endl; + LOG(error) << "Node's rdf:instanceOf property is not a resource" << endl; return boost::optional<Path>(); } @@ -683,7 +683,7 @@ Parser::parse_connections( if (Path::is_valid(src_path) && Path::is_valid(dst_path)) { target->connect(src_path, dst_path); } else { - cerr << "ERROR: Invalid path in connection " + LOG(error) << "Invalid path in connection " << src_path << " => " << dst_path << endl; } } diff --git a/src/serialisation/Serialiser.cpp b/src/serialisation/Serialiser.cpp index 5dd9b045..18a6d9d9 100644 --- a/src/serialisation/Serialiser.cpp +++ b/src/serialisation/Serialiser.cpp @@ -21,7 +21,6 @@ #include <cstdlib> // atof #include <cstring> #include <fstream> -#include <iostream> #include <locale.h> #include <stdexcept> #include <string> @@ -30,6 +29,7 @@ #include <glib.h> #include <glib/gstdio.h> #include <glibmm/convert.h> +#include "raul/log.hpp" #include "raul/Atom.hpp" #include "raul/AtomRDF.hpp" #include "raul/Path.hpp" @@ -46,6 +46,8 @@ #include "interface/Connection.hpp" #include "Serialiser.hpp" +#define LOG(s) s << "[Serialiser] " + using namespace std; using namespace Raul; using namespace Redland; @@ -151,7 +153,7 @@ Serialiser::to_string(SharedPtr<GraphObject> object, _model->add_statement(base_rdf_node, v->first.str(), AtomRDF::atom_to_node(_model->world(), v->second)); } else { - cerr << "Warning: not serialising extra RDF with key '" << v->first << "'" << endl; + LOG(warn) << "Not serialising extra RDF with key '" << v->first << "'" << endl; } } @@ -287,7 +289,7 @@ Serialiser::serialise(SharedPtr<GraphObject> object) throw (std::logic_error) return; } - cerr << "[Serialiser] WARNING: Unsupported object type, " + LOG(warn) << "Unsupported object type, " << object->path() << " not serialised." << endl; } @@ -313,7 +315,7 @@ Serialiser::serialise_patch(SharedPtr<Shared::Patch> patch, const Redland::Node& _model->add_statement(patch_id, "lv2:symbol", Redland::Literal(_model->world(), patch->path().name())); } else { - cerr << "WARNING: Patch has no lv2:symbol" << endl; + LOG(warn) << "Patch has no lv2:symbol" << endl; } serialise_properties(patch_id, patch->meta().properties()); @@ -449,7 +451,7 @@ Serialiser::serialise_port_meta(const Port* port, const Redland::Node& port_id) _model->add_statement(port_id, "lv2:default", AtomRDF::atom_to_node(_model->world(), Atom(port->value()))); } else if (port->type() == PortType::CONTROL) { - cerr << "WARNING: Port " << port->path() << " has no lv2:default" << endl; + LOG(warn) << "Port " << port->path() << " has no lv2:default" << endl; } } } @@ -498,11 +500,11 @@ Serialiser::serialise_properties( if (value.is_valid()) { _model->add_statement(subject, key, value); } else { - cerr << "WARNING: can not serialise variable '" << v->first << "' :: " + LOG(warn) << "Can not serialise variable '" << v->first << "' :: " << (int)v->second.type() << endl; } } else { - cerr << "WARNING: property '" << v->first << "' has no value" << endl; + LOG(warn) << "Property '" << v->first << "' has no value" << endl; } } } |