Add logging prefixes based on the plugin

This commit is contained in:
Robbert van der Helm
2020-03-07 15:07:01 +01:00
parent bfc0d46780
commit 4bcb77defa
2 changed files with 46 additions and 2 deletions
+21 -1
View File
@@ -29,6 +29,8 @@
// here.
namespace bp = boost::process;
// I'd rather use std::filesystem instead, but Boost.Process depends on
// boost::filesystem
namespace fs = boost::filesystem;
/**
@@ -42,6 +44,7 @@ constexpr auto yabridge_wine_host_name = "yabridge-host.exe";
constexpr char alphanumeric_characters[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
std::string create_logger_prefix(const fs::path& socket_path);
fs::path find_vst_plugin();
fs::path find_wine_vst_host();
fs::path generate_endpoint_name();
@@ -74,7 +77,8 @@ HostBridge::HostBridge(audioMasterCallback host_callback)
host_vst_process_replacing(io_context),
vst_host_aeffect(io_context),
host_callback_function(host_callback),
logger(Logger::create_from_environment()),
logger(Logger::create_from_environment(
create_logger_prefix(socket_endpoint.path()))),
vst_host(find_wine_vst_host(),
// The Wine VST host needs to know which plugin to load
// and which Unix domain socket to connect to
@@ -229,6 +233,22 @@ fs::path find_wine_vst_host() {
return vst_host_path;
}
/**
* Create a logger prefix based on the unique socket path for easy
* identification. The socket path contains both the plugin's name and a unique
* identifier.
*
* @param socket_path The path to the socket endpoint in use.
*
* @return A prefix string for log messages.
*/
std::string create_logger_prefix(const fs::path& socket_path) {
std::ostringstream prefix;
prefix << "[" << socket_path.filename() << "] ";
return prefix.str();
}
/**
* Find the VST plugin .dll file that corresponds to this copy of
* `libyabridge.so`. This should be the same as the name of this file but with a