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
+25 -1
View File
@@ -16,6 +16,10 @@
#include "plugin-bridge.h"
#include <filesystem>
namespace fs = std::filesystem;
/**
* A function pointer to what should be the entry point of a VST plugin.
*/
@@ -27,6 +31,8 @@ using VstEntryPoint = AEffect*(VST_CALL_CONV*)(audioMasterCallback);
*/
PluginBridge* current_bridge_isntance = nullptr;
std::string create_logger_prefix(const fs::path& socket_path);
intptr_t VST_CALL_CONV
host_callback_proxy(AEffect*, int32_t, int32_t, intptr_t, void*, float);
@@ -58,7 +64,8 @@ PluginBridge::PluginBridge(std::string plugin_dll_path,
host_vst_parameters(io_context),
host_vst_process_replacing(io_context),
vst_host_aeffect(io_context),
logger(Logger::create_from_environment("[WINE] ")),
logger(Logger::create_from_environment(
create_logger_prefix(socket_endpoint_path))),
process_buffer(std::make_unique<AudioBuffers::buffer_type>()) {
// Got to love these C APIs
if (plugin_handle == nullptr) {
@@ -192,6 +199,23 @@ intptr_t PluginBridge::host_callback(AEffect* /*plugin*/,
return send_event(vst_host_callback, opcode, index, value, data, option);
}
/**
* 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() << "] ";
prefix << "[WINE] ";
return prefix.str();
}
intptr_t VST_CALL_CONV host_callback_proxy(AEffect* effect,
int32_t opcode,
int32_t index,