mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-10 04:30:12 +02:00
Add logging for the VST3 plugin
This commit is contained in:
@@ -89,10 +89,7 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
|
|||||||
|
|
||||||
if (logging) {
|
if (logging) {
|
||||||
auto [logger, is_host_vst] = *logging;
|
auto [logger, is_host_vst] = *logging;
|
||||||
// TODO: Log the request
|
logger.log_request(is_host_vst, object);
|
||||||
// logger.log_event(is_dispatch, opcode, index, value, payload,
|
|
||||||
// option,
|
|
||||||
// value_payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// A socket only handles a single request at a time as to prevent
|
// A socket only handles a single request at a time as to prevent
|
||||||
@@ -111,11 +108,7 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
|
|||||||
|
|
||||||
if (logging) {
|
if (logging) {
|
||||||
auto [logger, is_host_vst] = *logging;
|
auto [logger, is_host_vst] = *logging;
|
||||||
// TODO: Log the response
|
logger.log_response(!is_host_vst, response);
|
||||||
// logger.log_event_response(is_dispatch, opcode,
|
|
||||||
// response.return_value,
|
|
||||||
// response.payload,
|
|
||||||
// response.value_payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
@@ -152,23 +145,22 @@ class Vst3MessageHandler : public AdHocSocketHandler<Thread> {
|
|||||||
[&](boost::asio::local::stream_protocol::socket& socket) {
|
[&](boost::asio::local::stream_protocol::socket& socket) {
|
||||||
auto request = read_object<Request>(socket);
|
auto request = read_object<Request>(socket);
|
||||||
if (logging) {
|
if (logging) {
|
||||||
auto [logger, is_host_vst] = *logging;
|
std::visit(
|
||||||
// TODO: Log the request, use the visitor with an auto
|
[&](const auto& object) {
|
||||||
// lambda so we can use the same overloads as we use
|
auto [logger, is_host_vst] = *logging;
|
||||||
// in `send_message()`
|
logger.log_request(is_host_vst, object);
|
||||||
// logger.log_event(is_dispatch, opcode, index, value,
|
},
|
||||||
// payload, option,
|
request);
|
||||||
// value_payload);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Response response = callback(request);
|
Response response = callback(request);
|
||||||
if (logging) {
|
if (logging) {
|
||||||
// TODO: Log the response, use the visitor with an auto
|
std::visit(
|
||||||
// lambda so we can use the same overloads as we use
|
[&](const auto& object) {
|
||||||
// in `send_message()`
|
auto [logger, is_host_vst] = *logging;
|
||||||
// logger.log_event_response(
|
logger.log_response(!is_host_vst, object);
|
||||||
// is_dispatch, event.opcode, response.return_value,
|
},
|
||||||
// response.payload, response.value_payload);
|
response);
|
||||||
}
|
}
|
||||||
|
|
||||||
write_object(socket, response);
|
write_object(socket, response);
|
||||||
|
|||||||
@@ -16,4 +16,28 @@
|
|||||||
|
|
||||||
#include "vst3.h"
|
#include "vst3.h"
|
||||||
|
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
// TODO: Reconsider the output format
|
||||||
|
// TODO: Maybe think of an alterantive that's a little less boilerplaty
|
||||||
|
|
||||||
Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {}
|
Vst3Logger::Vst3Logger(Logger& generic_logger) : logger(generic_logger) {}
|
||||||
|
|
||||||
|
void Vst3Logger::log_request(bool is_host_vst, const WantsConfiguration&) {
|
||||||
|
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) {
|
||||||
|
std::ostringstream message;
|
||||||
|
message << get_log_prefix(is_host_vst)
|
||||||
|
<< " >> Requesting <Configuration>";
|
||||||
|
|
||||||
|
log(message.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Vst3Logger::log_response(bool is_host_vst, const Configuration&) {
|
||||||
|
if (BOOST_UNLIKELY(logger.verbosity >= Logger::Verbosity::most_events)) {
|
||||||
|
std::ostringstream message;
|
||||||
|
message << get_log_prefix(is_host_vst) << " <Configuration>";
|
||||||
|
|
||||||
|
log(message.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "../serialization/vst3.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +38,24 @@ class Vst3Logger {
|
|||||||
*/
|
*/
|
||||||
inline void log_trace(const std::string& message) { logger.log(message); }
|
inline void log_trace(const std::string& message) { logger.log(message); }
|
||||||
|
|
||||||
// TODO: Logging interface for VST3 plugins
|
// For every object we send using `Vst3MessageHandler` we have overloads
|
||||||
|
// that print information about the request and the response. The boolean
|
||||||
|
// flag here indicates whether the request was initiated on the host side
|
||||||
|
// (what we'll call a control message).
|
||||||
|
|
||||||
|
void log_request(bool is_host_vst, const WantsConfiguration&);
|
||||||
|
|
||||||
|
void log_response(bool is_host_vst, const Configuration&);
|
||||||
|
|
||||||
Logger& logger;
|
Logger& logger;
|
||||||
|
|
||||||
|
private:
|
||||||
|
/**
|
||||||
|
* Get the `host -> vst` or `vst -> host` prefix based on the boolean flag
|
||||||
|
* we pass to every logging function so we don't have to repeat it
|
||||||
|
* everywhere.
|
||||||
|
*/
|
||||||
|
inline std::string get_log_prefix(bool is_host_vst) {
|
||||||
|
return is_host_vst ? "[host -> vst]" : "[vst -> host]";
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user