diff options
author | David Robillard <d@drobilla.net> | 2020-11-27 18:56:29 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-11-27 21:52:17 +0100 |
commit | 320f988a5ee586235f785b15028c7ef777e981a0 (patch) | |
tree | e518cc231f1872091c3a808b93a1385957ec1214 /src | |
parent | dbe6899651ac929f59af160dd07aaf6bda079b23 (diff) | |
download | patchage-320f988a5ee586235f785b15028c7ef777e981a0.tar.gz patchage-320f988a5ee586235f785b15028c7ef777e981a0.tar.bz2 patchage-320f988a5ee586235f785b15028c7ef777e981a0.zip |
Use prettier names for log methods
Diffstat (limited to 'src')
-rw-r--r-- | src/AlsaDriver.cpp | 44 | ||||
-rw-r--r-- | src/ILog.hpp | 6 | ||||
-rw-r--r-- | src/JackDbusDriver.cpp | 4 | ||||
-rw-r--r-- | src/JackDriver.cpp | 44 | ||||
-rw-r--r-- | src/Patchage.cpp | 10 | ||||
-rw-r--r-- | src/PatchageCanvas.cpp | 9 | ||||
-rw-r--r-- | src/PatchageEvent.cpp | 12 | ||||
-rw-r--r-- | src/TextViewLog.cpp | 6 | ||||
-rw-r--r-- | src/TextViewLog.hpp | 6 |
9 files changed, 69 insertions, 72 deletions
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp index a78c6ee..87c3ea0 100644 --- a/src/AlsaDriver.cpp +++ b/src/AlsaDriver.cpp @@ -48,10 +48,10 @@ AlsaDriver::attach(bool /*launch_daemon*/) { int ret = snd_seq_open(&_seq, "default", SND_SEQ_OPEN_DUPLEX, 0); if (ret) { - _log.error_msg("Alsa: Unable to attach."); + _log.error("Alsa: Unable to attach."); _seq = nullptr; } else { - _log.info_msg("Alsa: Attached."); + _log.info("Alsa: Attached."); snd_seq_set_client_name(_seq, "Patchage"); @@ -62,7 +62,7 @@ AlsaDriver::attach(bool /*launch_daemon*/) ret = pthread_create( &_refresh_thread, &attr, &AlsaDriver::refresh_main, this); if (ret) { - _log.error_msg("Alsa: Failed to start refresh thread."); + _log.error("Alsa: Failed to start refresh thread."); } signal_attached.emit(); @@ -78,7 +78,7 @@ AlsaDriver::detach() snd_seq_close(_seq); _seq = nullptr; signal_detached.emit(); - _log.info_msg("Alsa: Detached."); + _log.info("Alsa: Detached."); } } @@ -396,7 +396,7 @@ AlsaDriver::connect(PatchagePort* src_port, PatchagePort* dst_port) PortAddrs::const_iterator d = _port_addrs.find(dst_port); if (s == _port_addrs.end() || d == _port_addrs.end()) { - _log.error_msg("Alsa: Attempt to connect port with no address."); + _log.error("Alsa: Attempt to connect port with no address."); return false; } @@ -405,7 +405,7 @@ AlsaDriver::connect(PatchagePort* src_port, PatchagePort* dst_port) if (src.id.alsa_addr.client == dst.id.alsa_addr.client && src.id.alsa_addr.port == dst.id.alsa_addr.port) { - _log.warning_msg("Alsa: Refusing to connect port to itself."); + _log.warning("Alsa: Refusing to connect port to itself."); return false; } @@ -421,23 +421,23 @@ AlsaDriver::connect(PatchagePort* src_port, PatchagePort* dst_port) // Already connected (shouldn't happen) if (!snd_seq_get_port_subscription(_seq, subs)) { - _log.error_msg("Alsa: Attempt to double subscribe ports."); + _log.error("Alsa: Attempt to double subscribe ports."); result = false; } int ret = snd_seq_subscribe_port(_seq, subs); if (ret < 0) { - _log.error_msg( + _log.error( fmt::format("Alsa: Subscription failed ({}).", snd_strerror(ret))); result = false; } if (result) { - _log.info_msg(std::string("Alsa: Connected ") + src_port->full_name() + - " => " + dst_port->full_name()); + _log.info(std::string("Alsa: Connected ") + src_port->full_name() + + " => " + dst_port->full_name()); } else { - _log.error_msg(std::string("Alsa: Unable to connect ") + - src_port->full_name() + " => " + dst_port->full_name()); + _log.error(std::string("Alsa: Unable to connect ") + + src_port->full_name() + " => " + dst_port->full_name()); } return (!result); @@ -454,7 +454,7 @@ AlsaDriver::disconnect(PatchagePort* src_port, PatchagePort* dst_port) PortAddrs::const_iterator d = _port_addrs.find(dst_port); if (s == _port_addrs.end() || d == _port_addrs.end()) { - _log.error_msg("Alsa: Attempt to connect port with no address"); + _log.error("Alsa: Attempt to connect port with no address"); return false; } @@ -471,21 +471,21 @@ AlsaDriver::disconnect(PatchagePort* src_port, PatchagePort* dst_port) // Not connected (shouldn't happen) if (snd_seq_get_port_subscription(_seq, subs) != 0) { - _log.error_msg( + _log.error( "Alsa: Attempt to unsubscribe ports that are not subscribed."); return false; } int ret = snd_seq_unsubscribe_port(_seq, subs); if (ret < 0) { - _log.error_msg(std::string("Alsa: Unable to disconnect ") + - src_port->full_name() + " => " + dst_port->full_name() + - "(" + snd_strerror(ret) + ")"); + _log.error(std::string("Alsa: Unable to disconnect ") + + src_port->full_name() + " => " + dst_port->full_name() + + "(" + snd_strerror(ret) + ")"); return false; } - _log.info_msg(std::string("Alsa: Disconnected ") + src_port->full_name() + - " => " + dst_port->full_name()); + _log.info(std::string("Alsa: Disconnected ") + src_port->full_name() + + " => " + dst_port->full_name()); return true; } @@ -504,7 +504,7 @@ AlsaDriver::create_refresh_port() int ret = snd_seq_create_port(_seq, port_info); if (ret) { - _log.error_msg( + _log.error( fmt::format("Alsa: Error creating port ({})", snd_strerror(ret))); return false; } @@ -515,7 +515,7 @@ AlsaDriver::create_refresh_port() SND_SEQ_CLIENT_SYSTEM, SND_SEQ_PORT_SYSTEM_ANNOUNCE); if (ret) { - _log.error_msg( + _log.error( fmt::format("Alsa: Failed to connect to system announce port ({})", snd_strerror(ret))); return false; @@ -536,7 +536,7 @@ void AlsaDriver::_refresh_main() { if (!create_refresh_port()) { - _log.error_msg( + _log.error( "Alsa: Could not create listen port, auto-refresh disabled."); return; } diff --git a/src/ILog.hpp b/src/ILog.hpp index a71fda2..e1ee8b4 100644 --- a/src/ILog.hpp +++ b/src/ILog.hpp @@ -33,9 +33,9 @@ public: virtual ~ILog() = default; - virtual void info_msg(const std::string& msg) = 0; - virtual void warning_msg(const std::string& msg) = 0; - virtual void error_msg(const std::string& msg) = 0; + virtual void info(const std::string& msg) = 0; + virtual void warning(const std::string& msg) = 0; + virtual void error(const std::string& msg) = 0; }; #endif // PATCHAGE_ILOG_HPP diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp index 8098410..30a4eaa 100644 --- a/src/JackDbusDriver.cpp +++ b/src/JackDbusDriver.cpp @@ -1191,11 +1191,11 @@ JackDriver::create_port_view(Patchage*, const PortID&) void JackDriver::error_msg(const std::string& msg) const { - _log.error_msg(std::string{"Jack: "} + msg); + _log.error(std::string{"Jack: "} + msg); } void JackDriver::info_msg(const std::string& msg) const { - _log.info_msg(std::string{"Jack: "} + msg); + _log.info(std::string{"Jack: "} + msg); } diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp index 8a44d93..ecb868a 100644 --- a/src/JackDriver.cpp +++ b/src/JackDriver.cpp @@ -75,7 +75,7 @@ JackDriver::attach(bool launch_daemon) (!launch_daemon) ? JackNoStartServer : JackNullOption; _client = jack_client_open("Patchage", options, nullptr); if (_client == nullptr) { - _log.error_msg("Jack: Unable to create client."); + _log.error("Jack: Unable to create client."); _is_activated = false; } else { jack_client_t* const client = _client; @@ -94,9 +94,9 @@ JackDriver::attach(bool launch_daemon) _is_activated = true; signal_attached.emit(); std::stringstream ss; - _log.info_msg("Jack: Attached."); + _log.info("Jack: Attached."); } else { - _log.error_msg("Jack: Client activation failed."); + _log.error("Jack: Client activation failed."); _is_activated = false; } } @@ -114,7 +114,7 @@ JackDriver::detach() } _is_activated = false; signal_detached.emit(); - _log.info_msg("Jack: Detached."); + _log.info("Jack: Detached."); } static bool @@ -143,8 +143,8 @@ JackDriver::create_port_view(Patchage* patchage, const PortID& id) jack_port_t* jack_port = jack_port_by_id(_client, id.id.jack_id); if (!jack_port) { - _log.error_msg(fmt::format("Jack: Failed to find port with ID `{}'.", - id.id.jack_id)); + _log.error(fmt::format("Jack: Failed to find port with ID `{}'.", + id.id.jack_id)); return nullptr; } @@ -172,9 +172,9 @@ JackDriver::create_port_view(Patchage* patchage, const PortID& id) } if (parent->get_port(port_name)) { - _log.error_msg(fmt::format("Jack: Module `{}' already has port `{}'.", - module_name, - port_name)); + _log.error(fmt::format("Jack: Module `{}' already has port `{}'.", + module_name, + port_name)); return nullptr; } @@ -245,9 +245,9 @@ JackDriver::create_port(PatchageModule& parent, } #endif } else { - _log.warning_msg(fmt::format("Jack: Port `{}' has unknown type `{}'.", - jack_port_name(port), - type_str)); + _log.warning(fmt::format("Jack: Port `{}' has unknown type `{}'.", + jack_port_name(port), + type_str)); return nullptr; } @@ -438,11 +438,11 @@ JackDriver::connect(PatchagePort* src_port, PatchagePort* dst_port) _client, src_port->full_name().c_str(), dst_port->full_name().c_str()); if (result == 0) { - _log.info_msg(std::string("Jack: Connected ") + src_port->full_name() + - " => " + dst_port->full_name()); + _log.info(std::string("Jack: Connected ") + src_port->full_name() + + " => " + dst_port->full_name()); } else { - _log.error_msg(std::string("Jack: Unable to connect ") + - src_port->full_name() + " => " + dst_port->full_name()); + _log.error(std::string("Jack: Unable to connect ") + + src_port->full_name() + " => " + dst_port->full_name()); } return (!result); @@ -464,11 +464,11 @@ JackDriver::disconnect(PatchagePort* const src_port, _client, src_port->full_name().c_str(), dst_port->full_name().c_str()); if (result == 0) { - _log.info_msg(std::string("Jack: Disconnected ") + - src_port->full_name() + " => " + dst_port->full_name()); + _log.info(std::string("Jack: Disconnected ") + src_port->full_name() + + " => " + dst_port->full_name()); } else { - _log.error_msg(std::string("Jack: Unable to disconnect ") + - src_port->full_name() + " => " + dst_port->full_name()); + _log.error(std::string("Jack: Unable to disconnect ") + + src_port->full_name() + " => " + dst_port->full_name()); } return (!result); @@ -545,7 +545,7 @@ JackDriver::jack_shutdown_cb(void* jack_driver) { assert(jack_driver); auto* me = static_cast<JackDriver*>(jack_driver); - me->_log.info_msg("Jack: Shutdown."); + me->_log.info("Jack: Shutdown."); std::lock_guard<std::mutex> lock{me->_shutdown_mutex}; @@ -612,7 +612,7 @@ JackDriver::set_buffer_size(jack_nframes_t size) } if (jack_set_buffer_size(_client, size)) { - _log.error_msg("[JACK] Unable to set buffer size"); + _log.error("[JACK] Unable to set buffer size"); return false; } diff --git a/src/Patchage.cpp b/src/Patchage.cpp index 7fbc434..5d38444 100644 --- a/src/Patchage.cpp +++ b/src/Patchage.cpp @@ -332,7 +332,7 @@ Patchage::Patchage(int argc, char** argv) _about_win->set_logo(Gdk::Pixbuf::create_from_file( bundle_location() + "/Resources/Patchage.icns")); } catch (const Glib::Exception& e) { - _log.error_msg(fmt::format("failed to set logo ({})", e.what())); + _log.error(fmt::format("failed to set logo ({})", e.what())); } #endif @@ -654,14 +654,14 @@ Patchage::show_open_session_dialog() const std::string dir = dialog.get_filename(); if (g_chdir(dir.c_str())) { - _log.error_msg("Failed to switch to session directory " + dir); + _log.error("Failed to switch to session directory " + dir); return; } if (system("./jack-session") < 0) { - _log.error_msg("Error executing `./jack-session' in " + dir); + _log.error("Error executing `./jack-session' in " + dir); } else { - _log.info_msg("Loaded session " + dir); + _log.info("Loaded session " + dir); } } @@ -699,7 +699,7 @@ Patchage::save_session(bool close) std::string path = dialog.get_filename(); if (g_mkdir_with_parents(path.c_str(), 0740)) { - _log.error_msg("Failed to create session directory " + path); + _log.error("Failed to create session directory " + path); return; } diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp index 13eb0f4..f38ccca 100644 --- a/src/PatchageCanvas.cpp +++ b/src/PatchageCanvas.cpp @@ -246,8 +246,7 @@ PatchageCanvas::connect(Ganv::Node* port1, Ganv::Node* port2) _app->alsa_driver()->connect(p1, p2); #endif } else { - _app->log().warning_msg( - "Cannot make connection, incompatible port types."); + _app->log().warning("Cannot make connection, incompatible port types."); } } @@ -268,8 +267,7 @@ PatchageCanvas::disconnect(Ganv::Node* port1, Ganv::Node* port2) } if (!input || !output || input->is_output() || output->is_input()) { - _app->log().error_msg( - "Attempt to disconnect mismatched/unknown ports."); + _app->log().error("Attempt to disconnect mismatched/unknown ports."); return; } @@ -285,8 +283,7 @@ PatchageCanvas::disconnect(Ganv::Node* port1, Ganv::Node* port2) _app->alsa_driver()->disconnect(output, input); #endif } else { - _app->log().error_msg( - "Attempt to disconnect ports with strange types."); + _app->log().error("Attempt to disconnect ports with strange types."); } } diff --git a/src/PatchageEvent.cpp b/src/PatchageEvent.cpp index 0f5645a..af3ed61 100644 --- a/src/PatchageEvent.cpp +++ b/src/PatchageEvent.cpp @@ -69,11 +69,11 @@ PatchageEvent::execute(Patchage* patchage) if (driver) { PatchagePort* port = driver->create_port_view(patchage, _port_1); if (!port) { - patchage->log().error_msg(fmt::format( + patchage->log().error(fmt::format( "Unable to create view for port `{}'", _port_1)); } } else { - patchage->log().error_msg( + patchage->log().error( fmt::format("Unknown type for port `{}'", _port_1)); } @@ -87,10 +87,10 @@ PatchageEvent::execute(Patchage* patchage) PatchagePort* port_2 = patchage->canvas()->find_port(_port_2); if (!port_1) { - patchage->log().error_msg( + patchage->log().error( fmt::format("Unable to find port `{}' to connect", _port_1)); } else if (!port_2) { - patchage->log().error_msg( + patchage->log().error( fmt::format("Unable to find port `{}' to connect", _port_2)); } else { patchage->canvas()->make_connection(port_1, port_2); @@ -102,10 +102,10 @@ PatchageEvent::execute(Patchage* patchage) PatchagePort* port_2 = patchage->canvas()->find_port(_port_2); if (!port_1) { - patchage->log().error_msg( + patchage->log().error( fmt::format("Unable to find port `{}' to disconnect", _port_1)); } else if (!port_2) { - patchage->log().error_msg( + patchage->log().error( fmt::format("Unable to find port `{}' to disconnect", _port_2)); } else { patchage->canvas()->remove_edge_between(port_1, port_2); diff --git a/src/TextViewLog.cpp b/src/TextViewLog.cpp index b5e7a59..0e37420 100644 --- a/src/TextViewLog.cpp +++ b/src/TextViewLog.cpp @@ -46,7 +46,7 @@ TextViewLog::TextViewLog(Widget<Gtk::TextView>& text_view) } void -TextViewLog::info_msg(const std::string& msg) +TextViewLog::info(const std::string& msg) { Glib::RefPtr<Gtk::TextBuffer> buffer = _text_view->get_buffer(); buffer->insert(buffer->end(), std::string("\n") + msg); @@ -54,7 +54,7 @@ TextViewLog::info_msg(const std::string& msg) } void -TextViewLog::warning_msg(const std::string& msg) +TextViewLog::warning(const std::string& msg) { Glib::RefPtr<Gtk::TextBuffer> buffer = _text_view->get_buffer(); buffer->insert_with_tag( @@ -63,7 +63,7 @@ TextViewLog::warning_msg(const std::string& msg) } void -TextViewLog::error_msg(const std::string& msg) +TextViewLog::error(const std::string& msg) { Glib::RefPtr<Gtk::TextBuffer> buffer = _text_view->get_buffer(); buffer->insert_with_tag(buffer->end(), std::string("\n") + msg, _error_tag); diff --git a/src/TextViewLog.hpp b/src/TextViewLog.hpp index eb44407..1165cdf 100644 --- a/src/TextViewLog.hpp +++ b/src/TextViewLog.hpp @@ -38,9 +38,9 @@ public: ~TextViewLog() override = default; - void info_msg(const std::string& msg) override; - void error_msg(const std::string& msg) override; - void warning_msg(const std::string& msg) override; + void info(const std::string& msg) override; + void error(const std::string& msg) override; + void warning(const std::string& msg) override; int min_height() const; |