From 532af2452bac2cdd0e2732ad145fdc2b141a4afc Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 8 Mar 2019 12:38:19 +0100 Subject: Localise dependency on boost::format and improve logging API --- src/server/BlockFactory.cpp | 19 +++++++++---------- src/server/CompiledGraph.cpp | 7 +++---- src/server/Engine.cpp | 4 ++-- src/server/JackDriver.cpp | 20 +++++++++----------- src/server/LV2Block.cpp | 23 ++++++++++++----------- src/server/LV2Plugin.cpp | 4 ++-- src/server/RunContext.cpp | 4 ++-- src/server/SocketListener.cpp | 21 +++++++++++---------- src/server/events/Delta.cpp | 4 ++-- src/server/ingen_lv2.cpp | 4 ++-- 10 files changed, 54 insertions(+), 56 deletions(-) (limited to 'src/server') diff --git a/src/server/BlockFactory.cpp b/src/server/BlockFactory.cpp index 02be5159..d5a8e2d3 100644 --- a/src/server/BlockFactory.cpp +++ b/src/server/BlockFactory.cpp @@ -165,9 +165,8 @@ BlockFactory::load_lv2_plugins() const char* feature = lilv_node_as_uri(lilv_nodes_get(features, f)); if (!_world.lv2_features().is_supported(feature)) { supported = false; - _world.log().warn( - fmt("Ignoring <%1%>; required feature <%2%>\n") - % uri % feature); + _world.log().warn("Ignoring <%1%>; required feature <%2%>\n", + uri, feature); break; } } @@ -178,8 +177,8 @@ BlockFactory::load_lv2_plugins() // Ignore plugins that are missing ports if (!lilv_plugin_get_port_by_index(lv2_plug, 0)) { - _world.log().warn( - fmt("Ignoring <%1%>; missing or corrupt ports\n") % uri); + _world.log().warn("Ignoring <%1%>; missing or corrupt ports\n", + uri); continue; } @@ -197,10 +196,10 @@ BlockFactory::load_lv2_plugins() !lilv_port_has_property(lv2_plug, port, _world.uris().lv2_connectionOptional)) { - _world.log().warn( - fmt("Ignoring <%1%>; unsupported port <%2%>\n") - % uri % lilv_node_as_string( - lilv_port_get_symbol(lv2_plug, port))); + _world.log().warn("Ignoring <%1%>; unsupported port <%2%>\n", + uri, + lilv_node_as_string( + lilv_port_get_symbol(lv2_plug, port))); break; } } @@ -217,7 +216,7 @@ BlockFactory::load_lv2_plugins() } } - _world.log().info(fmt("Loaded %1% plugins\n") % _plugins.size()); + _world.log().info("Loaded %1% plugins\n", _plugins.size()); } } // namespace server diff --git a/src/server/CompiledGraph.cpp b/src/server/CompiledGraph.cpp index 073b234e..dec5fdaf 100644 --- a/src/server/CompiledGraph.cpp +++ b/src/server/CompiledGraph.cpp @@ -67,11 +67,10 @@ CompiledGraph::compile(Raul::Maid& maid, GraphImpl& graph) } catch (const FeedbackException& e) { Log& log = graph.engine().log(); if (e.node && e.root) { - log.error(fmt("Feedback compiling %1% from %2%\n") - % e.node->path() % e.root->path()); + log.error("Feedback compiling %1% from %2%\n", + e.node->path(), e.root->path()); } else { - log.error(fmt("Feedback compiling %1%\n") - % e.node->path()); + log.error("Feedback compiling %1%\n", e.node->path()); } return MPtr(); } diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index c463e7d6..5ab5e490 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -509,14 +509,14 @@ Engine::log() const void Engine::register_client(SPtr client) { - log().info(fmt("Registering client <%1%>\n") % client->uri().c_str()); + log().info("Registering client <%1%>\n", client->uri().c_str()); _broadcaster->register_client(client); } bool Engine::unregister_client(SPtr client) { - log().info(fmt("Unregistering client <%1%>\n") % client->uri().c_str()); + log().info("Unregistering client <%1%>\n", client->uri().c_str()); return _broadcaster->unregister_client(client); } diff --git a/src/server/JackDriver.cpp b/src/server/JackDriver.cpp index 35406ec4..6e3ca9d6 100644 --- a/src/server/JackDriver.cpp +++ b/src/server/JackDriver.cpp @@ -22,7 +22,6 @@ #include #ifdef INGEN_JACK_SESSION #include -#include #include "ingen/Serialiser.hpp" #endif #ifdef HAVE_JACK_METADATA @@ -36,6 +35,7 @@ #include "ingen/URI.hpp" #include "ingen/URIMap.hpp" #include "ingen/World.hpp" +#include "ingen/fmt.hpp" #include "lv2/atom/util.h" #include "Buffer.hpp" @@ -89,8 +89,8 @@ JackDriver::attach(const std::string& server_name, _client = jack_client_open(client_name.c_str(), JackSessionID, nullptr, uuid.c_str()); - _engine.log().info(fmt("Connected to Jack as `%1%' (UUID `%2%')\n") - % client_name.c_str() % uuid); + _engine.log().info("Connected to Jack as `%1%' (UUID `%2%')\n", + client_name.c_str(), uuid); } #endif @@ -99,8 +99,7 @@ JackDriver::attach(const std::string& server_name, if ((_client = jack_client_open(client_name.c_str(), JackServerName, nullptr, server_name.c_str()))) { - _engine.log().info(fmt("Connected to Jack server `%1%'\n") - % server_name); + _engine.log().info("Connected to Jack server `%1%'\n", server_name); } } @@ -171,7 +170,7 @@ JackDriver::activate() _engine.log().error("Could not activate Jack client, aborting\n"); return false; } else { - _engine.log().info(fmt("Activated Jack client `%1%'\n") % + _engine.log().info("Activated Jack client `%1%'\n", world.conf().option("jack-name").ptr()); } return true; @@ -545,12 +544,11 @@ JackDriver::_block_length_cb(jack_nframes_t nframes) void JackDriver::_session_cb(jack_session_event_t* event) { - _engine.log().info(fmt("Jack session save to %1%\n") % event->session_dir); + _engine.log().info("Jack session save to %1%\n", event->session_dir); - const std::string cmd = ( - boost::format("ingen -eg -n %1% -u %2% -l ${SESSION_DIR}") - % jack_get_client_name(_client) - % event->client_uuid).str(); + const std::string cmd = fmt("ingen -eg -n %1% -u %2% -l ${SESSION_DIR}", + jack_get_client_name(_client), + event->client_uuid); SPtr serialiser = _engine.world().serialiser(); if (serialiser) { diff --git a/src/server/LV2Block.cpp b/src/server/LV2Block.cpp index bf6cbd60..54280b5e 100644 --- a/src/server/LV2Block.cpp +++ b/src/server/LV2Block.cpp @@ -84,8 +84,8 @@ LV2Block::make_instance(URIs& uris, lplug, rate, _features->array()); if (!inst) { - engine.log().error(fmt("Failed to instantiate <%1%>\n") - % _lv2_plugin->uri().c_str()); + engine.log().error("Failed to instantiate <%1%>\n", + _lv2_plugin->uri().c_str()); return SPtr(); } @@ -141,14 +141,15 @@ LV2Block::make_instance(URIs& uris, port->set_type(PortType::CV, 0); } else { parent_graph()->engine().log().error( - fmt("%1% auto-morphed to unknown type %2%\n") - % port->path().c_str() % type); + "%1% auto-morphed to unknown type %2%\n", + port->path().c_str(), + type); return SPtr(); } } else { parent_graph()->engine().log().error( - fmt("Failed to get auto-morphed type of %1%\n") - % port->path().c_str()); + "Failed to get auto-morphed type of %1%\n", + port->path().c_str()); } } } @@ -304,8 +305,8 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) uint32_t port_buffer_size = bufs.default_size(buffer_type); if (port_buffer_size == 0 && !optional) { parent_graph()->engine().log().error( - fmt("<%1%> port `%2%' has unknown buffer type\n") - % _lv2_plugin->uri().c_str() % port_sym.c_str()); + "<%1%> port `%2%' has unknown buffer type\n", + _lv2_plugin->uri().c_str(), port_sym.c_str()); ret = false; break; } @@ -355,8 +356,8 @@ LV2Block::instantiate(BufferFactory& bufs, const LilvState* state) if ((port_type == PortType::UNKNOWN && !optional) || direction == UNKNOWN) { parent_graph()->engine().log().error( - fmt("<%1%> port `%2%' has unknown type or direction\n") - % _lv2_plugin->uri().c_str() % port_sym.c_str()); + "<%1%> port `%2%' has unknown type or direction\n", + _lv2_plugin->uri().c_str(), port_sym.c_str()); ret = false; break; } @@ -563,7 +564,7 @@ LV2Block::work(uint32_t size, const void* data) LV2_Worker_Status st = _worker_iface->work(inst, work_respond, this, size, data); if (st) { parent_graph()->engine().log().error( - fmt("Error calling %1% work method\n") % _path); + "Error calling %1% work method\n", _path); } return st; } diff --git a/src/server/LV2Plugin.cpp b/src/server/LV2Plugin.cpp index 7012c8fd..9152ab99 100644 --- a/src/server/LV2Plugin.cpp +++ b/src/server/LV2Plugin.cpp @@ -128,8 +128,8 @@ LV2Plugin::load_presets() lilv_nodes_free(labels); } else { _world.log().error( - fmt("Preset <%1%> has no rdfs:label\n") - % lilv_node_as_string(lilv_nodes_get(presets, i))); + "Preset <%1%> has no rdfs:label\n", + lilv_node_as_string(lilv_nodes_get(presets, i))); } } diff --git a/src/server/RunContext.cpp b/src/server/RunContext.cpp index d7b96fba..7087b5ab 100644 --- a/src/server/RunContext.cpp +++ b/src/server/RunContext.cpp @@ -164,8 +164,8 @@ RunContext::set_priority(int priority) sp.sched_priority = (priority > 0) ? priority : 0; if (pthread_setschedparam(pthread, policy, &sp)) { _engine.log().error( - fmt("Failed to set real-time priority of run thread (%s)\n") - % strerror(errno)); + "Failed to set real-time priority of run thread (%s)\n", + strerror(errno)); } } } diff --git a/src/server/SocketListener.cpp b/src/server/SocketListener.cpp index bd25d351..849adcad 100644 --- a/src/server/SocketListener.cpp +++ b/src/server/SocketListener.cpp @@ -101,25 +101,26 @@ ingen_listen(Engine* engine, Raul::Socket* unix_sock, Raul::Socket* net_sock) const pid_t pid = std::stoi(suffix); if (!kill(pid, 0)) { make_link = false; - world.log().warn(fmt("Another Ingen instance is running at %1% => %2%\n") - % link_path % old_path); + world.log().warn( + "Another Ingen instance is running at %1% => %2%\n", + link_path, old_path); } else { - world.log().warn(fmt("Replacing old link %1% => %2%\n") - % link_path % old_path); + world.log().warn("Replacing old link %1% => %2%\n", + link_path, old_path); unlink(link_path.c_str()); } } if (make_link) { if (!symlink(unix_path.c_str(), link_path.c_str())) { - world.log().info(fmt("Listening on %1%\n") % + world.log().info("Listening on %1%\n", (unix_scheme + link_path)); } else { - world.log().error(fmt("Failed to link %1% => %2% (%3%)\n") - % link_path % unix_path % strerror(errno)); + world.log().error("Failed to link %1% => %2% (%3%)\n", + link_path, unix_path, strerror(errno)); } } else { - world.log().info(fmt("Listening on %1%\n") % unix_uri); + world.log().info("Listening on %1%\n", unix_uri); } } @@ -131,7 +132,7 @@ ingen_listen(Engine* engine, Raul::Socket* unix_sock, Raul::Socket* net_sock) world.log().error("Failed to create TCP socket\n"); net_sock->close(); } else { - world.log().info(fmt("Listening on TCP port %1%\n") % port); + world.log().info("Listening on TCP port %1%\n", port); } if (unix_sock->fd() == -1 && net_sock->fd() == -1) { @@ -157,7 +158,7 @@ ingen_listen(Engine* engine, Raul::Socket* unix_sock, Raul::Socket* net_sock) // Wait for input to arrive at a socket const int ret = poll(pfds, nfds, -1); if (ret == -1) { - world.log().error(fmt("Poll error: %1%\n") % strerror(errno)); + world.log().error("Poll error: %1%\n", strerror(errno)); break; } else if (ret == 0) { world.log().warn("Poll returned with no data\n"); diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp index efc50bce..982b1141 100644 --- a/src/server/events/Delta.cpp +++ b/src/server/events/Delta.cpp @@ -127,7 +127,7 @@ Delta::add_set_event(const char* port_symbol, BlockImpl* block = dynamic_cast(_object); PortImpl* port = block->port_by_symbol(port_symbol); if (!port) { - _engine.log().warn(fmt("Unknown port `%1%' in state") % port_symbol); + _engine.log().warn("Unknown port `%1%' in state", port_symbol); return; } @@ -373,7 +373,7 @@ Delta::pre_process(PreProcessContext& ctx) lilv_state_emit_port_values( _state, s_add_set_event, this); } else { - _engine.log().warn(fmt("Failed to load preset <%1%>\n") % uri); + _engine.log().warn("Failed to load preset <%1%>\n", uri); } } else { _status = Status::BAD_VALUE; diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp index 2d1769a0..25ead48e 100644 --- a/src/server/ingen_lv2.cpp +++ b/src/server/ingen_lv2.cpp @@ -538,8 +538,8 @@ ingen_instantiate(const LV2_Descriptor* descriptor, } plugin->world->log().info( - fmt("Block: %1% frames, Sequence: %2% bytes\n") - % block_length % seq_size); + "Block: %1% frames, Sequence: %2% bytes\n", + block_length, seq_size); plugin->world->conf().set( "queue-size", plugin->world->forge().make(std::max(block_length, seq_size) * 4)); -- cgit v1.2.1