mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-07 12:10:09 +02:00
Wrap event result data in an std::variant
Gets a bit more complicated this way, but this avoids having to use string to manually serialize and deserialize arbitrary objects. The new options for `AEffect` and `VstTimeInfo` structs are not yet used.
This commit is contained in:
+16
-4
@@ -185,7 +185,7 @@ void Logger::log_event(bool is_dispatch,
|
||||
|
||||
void Logger::log_event_response(bool is_dispatch,
|
||||
intptr_t return_value,
|
||||
std::optional<std::string> payload) {
|
||||
const EventResposnePayload& payload) {
|
||||
if (BOOST_UNLIKELY(verbosity >= Verbosity::events)) {
|
||||
std::ostringstream message;
|
||||
if (is_dispatch) {
|
||||
@@ -195,9 +195,21 @@ void Logger::log_event_response(bool is_dispatch,
|
||||
}
|
||||
|
||||
message << return_value;
|
||||
if (payload.has_value()) {
|
||||
message << ", \"" << payload.value() << "\"";
|
||||
}
|
||||
|
||||
std::visit(
|
||||
overload{[&](const std::monostate&) {},
|
||||
[&](const std::string& s) {
|
||||
if (s.size() < 32) {
|
||||
message << ", \"" << s << "\"";
|
||||
} else {
|
||||
// Long strings contain binary data that we
|
||||
// probably don't want to print
|
||||
message << ", <" << s.size() << " bytes>";
|
||||
}
|
||||
},
|
||||
[&](const AEffect&) { message << ", <AEffect_object>"; },
|
||||
[&](const VstTimeInfo&) { message << ", <time_info>"; }},
|
||||
payload);
|
||||
|
||||
log(message.str());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user