summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-27 19:09:21 +0100
committerDavid Robillard <d@drobilla.net>2020-11-27 21:52:29 +0100
commitb512f9a27b3538fdde7999ee5d3f40a480b0d361 (patch)
tree0c3ee4f61eaddae4510e47d28b9e85a7de41aa95
parent320f988a5ee586235f785b15028c7ef777e981a0 (diff)
downloadpatchage-b512f9a27b3538fdde7999ee5d3f40a480b0d361.tar.gz
patchage-b512f9a27b3538fdde7999ee5d3f40a480b0d361.tar.bz2
patchage-b512f9a27b3538fdde7999ee5d3f40a480b0d361.zip
Use a consistent style for log messages
-rw-r--r--.clang-tidy1
-rw-r--r--src/AlsaDriver.cpp45
-rw-r--r--src/JackDbusDriver.cpp26
-rw-r--r--src/JackDriver.cpp36
-rw-r--r--src/Patchage.cpp12
-rw-r--r--src/PatchageCanvas.cpp6
-rw-r--r--src/PatchageEvent.cpp16
7 files changed, 76 insertions, 66 deletions
diff --git a/.clang-tidy b/.clang-tidy
index 576443f..790a3bc 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -34,6 +34,7 @@ Checks: >
-hicpp-signed-bitwise,
-llvm-header-guard,
-llvmlibc-*,
+ -modernize-raw-string-literal,
-modernize-use-trailing-return-type,
-readability-convert-member-functions-to-static,
-readability-implicit-bool-conversion,
diff --git a/src/AlsaDriver.cpp b/src/AlsaDriver.cpp
index 87c3ea0..fdda5e7 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("Alsa: Unable to attach.");
+ _log.error("[ALSA] Unable to attach");
_seq = nullptr;
} else {
- _log.info("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("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("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("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("Alsa: Refusing to connect port to itself.");
+ _log.warning("[ALSA] Refusing to connect port to itself");
return false;
}
@@ -421,23 +421,25 @@ AlsaDriver::connect(PatchagePort* src_port, PatchagePort* dst_port)
// Already connected (shouldn't happen)
if (!snd_seq_get_port_subscription(_seq, subs)) {
- _log.error("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(
- fmt::format("Alsa: Subscription failed ({}).", snd_strerror(ret)));
+ fmt::format("[ALSA] Subscription failed ({})", snd_strerror(ret)));
result = false;
}
if (result) {
- _log.info(std::string("Alsa: Connected ") + src_port->full_name() +
- " => " + dst_port->full_name());
+ _log.info(fmt::format("[ALSA] Connected {} => {}",
+ src_port->full_name(),
+ dst_port->full_name()));
} else {
- _log.error(std::string("Alsa: Unable to connect ") +
- src_port->full_name() + " => " + dst_port->full_name());
+ _log.error(fmt::format("[ALSA] Unable to connect {} => {}",
+ src_port->full_name(),
+ dst_port->full_name()));
}
return (!result);
@@ -454,7 +456,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("Alsa: Attempt to connect port with no address");
+ _log.error("[ALSA] Attempt to connect port with no address");
return false;
}
@@ -472,19 +474,20 @@ AlsaDriver::disconnect(PatchagePort* src_port, PatchagePort* dst_port)
// Not connected (shouldn't happen)
if (snd_seq_get_port_subscription(_seq, subs) != 0) {
_log.error(
- "Alsa: Attempt to unsubscribe ports that are not subscribed.");
+ "[ALSA] Attempt to unsubscribe ports that are not subscribed");
return false;
}
int ret = snd_seq_unsubscribe_port(_seq, subs);
if (ret < 0) {
- _log.error(std::string("Alsa: Unable to disconnect ") +
- src_port->full_name() + " => " + dst_port->full_name() +
- "(" + snd_strerror(ret) + ")");
+ _log.error(fmt::format("[ALSA] Unable to disconnect {} => {} ({})",
+ src_port->full_name(),
+ dst_port->full_name(),
+ snd_strerror(ret)));
return false;
}
- _log.info(std::string("Alsa: Disconnected ") + src_port->full_name() +
+ _log.info(std::string("[ALSA] Disconnected ") + src_port->full_name() +
" => " + dst_port->full_name());
return true;
@@ -505,7 +508,7 @@ AlsaDriver::create_refresh_port()
int ret = snd_seq_create_port(_seq, port_info);
if (ret) {
_log.error(
- fmt::format("Alsa: Error creating port ({})", snd_strerror(ret)));
+ fmt::format("[ALSA] Error creating port ({})", snd_strerror(ret)));
return false;
}
@@ -516,7 +519,7 @@ AlsaDriver::create_refresh_port()
SND_SEQ_PORT_SYSTEM_ANNOUNCE);
if (ret) {
_log.error(
- fmt::format("Alsa: Failed to connect to system announce port ({})",
+ fmt::format("[ALSA] Failed to connect to system announce port ({})",
snd_strerror(ret)));
return false;
}
@@ -537,7 +540,7 @@ AlsaDriver::_refresh_main()
{
if (!create_refresh_port()) {
_log.error(
- "Alsa: Could not create listen port, auto-refresh disabled.");
+ "[ALSA] Could not create listen port, auto-refresh disabled");
return;
}
diff --git a/src/JackDbusDriver.cpp b/src/JackDbusDriver.cpp
index 30a4eaa..382ec3b 100644
--- a/src/JackDbusDriver.cpp
+++ b/src/JackDbusDriver.cpp
@@ -120,14 +120,14 @@ JackDriver::update_attached()
void
JackDriver::on_jack_appeared()
{
- info_msg("JACK appeared.");
+ info_msg("Server appeared");
update_attached();
}
void
JackDriver::on_jack_disappeared()
{
- info_msg("JACK disappeared.");
+ info_msg("Server disappeared");
// we are not calling update_attached() here, because it will activate
// jackdbus
@@ -470,7 +470,7 @@ JackDriver::is_started()
DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
- error_msg("decoding reply of IsStarted failed.");
+ error_msg("Decoding reply of IsStarted failed");
return false;
}
@@ -787,7 +787,7 @@ JackDriver::refresh_internal(bool force)
DBUS_TYPE_UINT64,
&version,
DBUS_TYPE_INVALID)) {
- error_msg("GetGraph() failed.");
+ error_msg("GetGraph() failed");
return;
}
@@ -931,7 +931,7 @@ JackDriver::connect(PatchagePort* src, PatchagePort* dst)
DBUS_TYPE_STRING,
&port2_name,
DBUS_TYPE_INVALID)) {
- error_msg("ConnectPortsByName() failed.");
+ error_msg("ConnectPortsByName() failed");
return false;
}
@@ -960,7 +960,7 @@ JackDriver::disconnect(PatchagePort* src, PatchagePort* dst)
DBUS_TYPE_STRING,
&port2_name,
DBUS_TYPE_INVALID)) {
- error_msg("DisconnectPortsByName() failed.");
+ error_msg("DisconnectPortsByName() failed");
return false;
}
@@ -992,7 +992,7 @@ JackDriver::buffer_size()
DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
- error_msg("decoding reply of GetBufferSize failed.");
+ error_msg("Decoding reply of GetBufferSize failed");
return 4096;
}
@@ -1045,7 +1045,7 @@ JackDriver::sample_rate()
DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
- error_msg("decoding reply of GetSampleRate failed.");
+ error_msg("Decoding reply of GetSampleRate failed");
return false;
}
@@ -1076,7 +1076,7 @@ JackDriver::is_realtime() const
DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&me->_dbus_error);
- error_msg("decoding reply of IsRealtime failed.");
+ error_msg("Decoding reply of IsRealtime failed");
return false;
}
@@ -1110,7 +1110,7 @@ JackDriver::get_xruns()
DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
- error_msg("decoding reply of GetXruns failed.");
+ error_msg("Decoding reply of GetXruns failed");
return 0;
}
@@ -1160,7 +1160,7 @@ JackDriver::get_max_dsp_load()
DBUS_TYPE_INVALID)) {
dbus_message_unref(reply_ptr);
dbus_error_free(&_dbus_error);
- error_msg("decoding reply of GetLoad failed.");
+ error_msg("Decoding reply of GetLoad failed");
return 0.0;
}
@@ -1191,11 +1191,11 @@ JackDriver::create_port_view(Patchage*, const PortID&)
void
JackDriver::error_msg(const std::string& msg) const
{
- _log.error(std::string{"Jack: "} + msg);
+ _log.error(std::string{"[JACK] "} + msg);
}
void
JackDriver::info_msg(const std::string& msg) const
{
- _log.info(std::string{"Jack: "} + msg);
+ _log.info(std::string{"[JACK] "} + msg);
}
diff --git a/src/JackDriver.cpp b/src/JackDriver.cpp
index ecb868a..a75aff4 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("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("Jack: Attached.");
+ _log.info("[JACK] Attached");
} else {
- _log.error("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("Jack: Detached.");
+ _log.info("[JACK] Detached");
}
static bool
@@ -143,7 +143,7 @@ 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(fmt::format("Jack: Failed to find port with ID `{}'.",
+ _log.error(fmt::format("[JACK] Failed to find port with ID \"{}\"",
id.id.jack_id));
return nullptr;
}
@@ -172,7 +172,7 @@ JackDriver::create_port_view(Patchage* patchage, const PortID& id)
}
if (parent->get_port(port_name)) {
- _log.error(fmt::format("Jack: Module `{}' already has port `{}'.",
+ _log.error(fmt::format("[JACK] Module \"{}\" already has port \"{}\"",
module_name,
port_name));
return nullptr;
@@ -245,7 +245,7 @@ JackDriver::create_port(PatchageModule& parent,
}
#endif
} else {
- _log.warning(fmt::format("Jack: Port `{}' has unknown type `{}'.",
+ _log.warning(fmt::format("[JACK] Port \"{}\" has unknown type \"{}\"",
jack_port_name(port),
type_str));
return nullptr;
@@ -438,11 +438,13 @@ 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(std::string("Jack: Connected ") + src_port->full_name() +
- " => " + dst_port->full_name());
+ _log.info(fmt::format("[JACK] Connected {} => {}",
+ src_port->full_name(),
+ dst_port->full_name()));
} else {
- _log.error(std::string("Jack: Unable to connect ") +
- src_port->full_name() + " => " + dst_port->full_name());
+ _log.error(fmt::format("[JACK] Unable to connect {} => {}",
+ src_port->full_name(),
+ dst_port->full_name()));
}
return (!result);
@@ -464,11 +466,13 @@ JackDriver::disconnect(PatchagePort* const src_port,
_client, src_port->full_name().c_str(), dst_port->full_name().c_str());
if (result == 0) {
- _log.info(std::string("Jack: Disconnected ") + src_port->full_name() +
- " => " + dst_port->full_name());
+ _log.info(fmt::format("[JACK] Disconnected {} => {}",
+ src_port->full_name(),
+ dst_port->full_name()));
} else {
- _log.error(std::string("Jack: Unable to disconnect ") +
- src_port->full_name() + " => " + dst_port->full_name());
+ _log.error(fmt::format("[JACK] Unable to disconnect {} => {}",
+ src_port->full_name(),
+ dst_port->full_name()));
}
return (!result);
@@ -545,7 +549,7 @@ JackDriver::jack_shutdown_cb(void* jack_driver)
{
assert(jack_driver);
auto* me = static_cast<JackDriver*>(jack_driver);
- me->_log.info("Jack: Shutdown.");
+ me->_log.info("[JACK] Shutdown");
std::lock_guard<std::mutex> lock{me->_shutdown_mutex};
diff --git a/src/Patchage.cpp b/src/Patchage.cpp
index 5d38444..1703d8b 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(fmt::format("failed to set logo ({})", e.what()));
+ _log.error(fmt::format("Failed to set logo ({})", e.what()));
}
#endif
@@ -654,14 +654,16 @@ Patchage::show_open_session_dialog()
const std::string dir = dialog.get_filename();
if (g_chdir(dir.c_str())) {
- _log.error("Failed to switch to session directory " + dir);
+ _log.error(
+ fmt::format("Failed to switch to session directory \"{}\"", dir));
return;
}
if (system("./jack-session") < 0) {
- _log.error("Error executing `./jack-session' in " + dir);
+ _log.error(
+ fmt::format("Error executing \"./jack-session\" in {}", dir));
} else {
- _log.info("Loaded session " + dir);
+ _log.info(fmt::format("Loaded session {}", dir));
}
}
@@ -699,7 +701,7 @@ Patchage::save_session(bool close)
std::string path = dialog.get_filename();
if (g_mkdir_with_parents(path.c_str(), 0740)) {
- _log.error("Failed to create session directory " + path);
+ _log.error(fmt::format("Failed to create session directory {}", path));
return;
}
diff --git a/src/PatchageCanvas.cpp b/src/PatchageCanvas.cpp
index f38ccca..fb48bff 100644
--- a/src/PatchageCanvas.cpp
+++ b/src/PatchageCanvas.cpp
@@ -246,7 +246,7 @@ PatchageCanvas::connect(Ganv::Node* port1, Ganv::Node* port2)
_app->alsa_driver()->connect(p1, p2);
#endif
} else {
- _app->log().warning("Cannot make connection, incompatible port types.");
+ _app->log().warning("Cannot make connection, incompatible port types");
}
}
@@ -267,7 +267,7 @@ PatchageCanvas::disconnect(Ganv::Node* port1, Ganv::Node* port2)
}
if (!input || !output || input->is_output() || output->is_input()) {
- _app->log().error("Attempt to disconnect mismatched/unknown ports.");
+ _app->log().error("Attempt to disconnect mismatched/unknown ports");
return;
}
@@ -283,7 +283,7 @@ PatchageCanvas::disconnect(Ganv::Node* port1, Ganv::Node* port2)
_app->alsa_driver()->disconnect(output, input);
#endif
} else {
- _app->log().error("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 af3ed61..ce9cd48 100644
--- a/src/PatchageEvent.cpp
+++ b/src/PatchageEvent.cpp
@@ -70,11 +70,11 @@ PatchageEvent::execute(Patchage* patchage)
PatchagePort* port = driver->create_port_view(patchage, _port_1);
if (!port) {
patchage->log().error(fmt::format(
- "Unable to create view for port `{}'", _port_1));
+ "Unable to create view for port \"{}\"", _port_1));
}
} else {
patchage->log().error(
- fmt::format("Unknown type for port `{}'", _port_1));
+ fmt::format("Unknown type for port \"{}\"", _port_1));
}
} else if (_type == Type::port_destruction) {
@@ -88,10 +88,10 @@ PatchageEvent::execute(Patchage* patchage)
if (!port_1) {
patchage->log().error(
- fmt::format("Unable to find port `{}' to connect", _port_1));
+ fmt::format("Unable to find port \"{}\" to connect", _port_1));
} else if (!port_2) {
patchage->log().error(
- fmt::format("Unable to find port `{}' to connect", _port_2));
+ fmt::format("Unable to find port \"{}\" to connect", _port_2));
} else {
patchage->canvas()->make_connection(port_1, port_2);
}
@@ -102,11 +102,11 @@ PatchageEvent::execute(Patchage* patchage)
PatchagePort* port_2 = patchage->canvas()->find_port(_port_2);
if (!port_1) {
- patchage->log().error(
- fmt::format("Unable to find port `{}' to disconnect", _port_1));
+ patchage->log().error(fmt::format(
+ "Unable to find port \"{}\" to disconnect", _port_1));
} else if (!port_2) {
- patchage->log().error(
- fmt::format("Unable to find port `{}' to disconnect", _port_2));
+ patchage->log().error(fmt::format(
+ "Unable to find port \"{}\" to disconnect", _port_2));
} else {
patchage->canvas()->remove_edge_between(port_1, port_2);
}