Split VST2 specific functionality into Vst2Logger

This commit is contained in:
Robbert van der Helm
2020-12-01 21:42:33 +01:00
parent 2230b5099f
commit f9a1bcd7bd
11 changed files with 617 additions and 572 deletions
+4 -49
View File
@@ -20,10 +20,6 @@
#include <optional>
#include <ostream>
// TODO: Split up the plugin API specific logging functions so we don't have to
// include a bunch of stuff we don't need
#include "../serialization/vst2.h"
/**
* Super basic logging facility meant for debugging malfunctioning VST
* plugins. This is also used to redirect the output of the Wine process
@@ -97,29 +93,6 @@ class Logger {
*/
void log(const std::string& message);
// The following functions are for logging specific events, they are only
// enabled for verbosity levels higher than 1 (i.e. `Verbosity::events`)
void log_get_parameter(int index);
void log_get_parameter_response(float vlaue);
void log_set_parameter(int index, float value);
void log_set_parameter_response();
// If `is_dispatch` is `true`, then use opcode names from the plugin's
// dispatch function. Otherwise use names for the host callback function
// opcodes.
void log_event(bool is_dispatch,
int opcode,
int index,
intptr_t value,
const EventPayload& payload,
float option,
const std::optional<EventPayload>& value_payload);
void log_event_response(
bool is_dispatch,
int opcode,
intptr_t return_value,
const EventResultPayload& payload,
const std::optional<EventResultPayload>& value_payload);
/**
* Log a message that should only be printed when the `verbosity` is set to
* `all_events`. This should only be used for simple primitive messages
@@ -130,38 +103,20 @@ class Logger {
*/
void log_trace(const std::string& message);
private:
/**
* Determine whether an event should be filtered based on the current
* verbosity level.
* The verbosity level of this logger instance. Based on this certain
* messages may or may not be shown.
*/
bool should_filter_event(bool is_dispatch, int opcode) const;
const Verbosity verbosity;
private:
/**
* The output stream to write the log messages to. Typically either STDERR
* or a file stream.
*/
std::shared_ptr<std::ostream> stream;
/**
* The verbosity level of this logger instance. Based on this certain
* messages may or may not be shown.
*/
Verbosity verbosity;
/**
* A prefix that gets prepended before every message.
*/
std::string prefix;
};
/**
* Convert an event opcode to a human readable string for debugging purposes.
* See `src/include/vestige/aeffectx.h` for a complete list of these opcodes.
*
* @param is_dispatch Whether to use opcodes for the `dispatch` function. Will
* use the names from the host callback function if set to false.
* @param opcode The opcode of the event.
*
* @return Either the name from `aeffectx.h`, or a nullopt if it was not listed
* there.
*/
std::optional<std::string> opcode_to_string(bool is_dispatch, int opcode);