Added comments on the Logger

This commit is contained in:
Paul Fd 2020-02-26 21:54:43 +01:00
parent c9baf7671e
commit 3b9683e66f

View file

@ -19,6 +19,10 @@ namespace sfz
using Duration = std::chrono::duration<double>; using Duration = std::chrono::duration<double>;
/**
* @brief Creates an RAII logger which fills or adds to a duration on destruction
*
*/
struct ScopedLogger struct ScopedLogger
{ {
using TimePoint = std::chrono::time_point<std::chrono::high_resolution_clock>; using TimePoint = std::chrono::time_point<std::chrono::high_resolution_clock>;
@ -28,6 +32,12 @@ struct ScopedLogger
replaceDuration replaceDuration
}; };
ScopedLogger() = delete; ScopedLogger() = delete;
/**
* @brief Construct a new Scoped Logger object
*
* @param targetDuration
* @param op
*/
ScopedLogger(Duration& targetDuration, Operation op = Operation::replaceDuration); ScopedLogger(Duration& targetDuration, Operation op = Operation::replaceDuration);
~ScopedLogger(); ~ScopedLogger();
Duration& targetDuration; Duration& targetDuration;
@ -65,13 +75,53 @@ class Logger
public: public:
Logger(); Logger();
~Logger(); ~Logger();
/**
* @brief Set the prefix for the output log files
*
* @param prefix
*/
void setPrefix(const std::string& prefix); void setPrefix(const std::string& prefix);
/**
* @brief Removes all logged data
*
*/
void clear(); void clear();
/**
* @brief Enables logging and writing to log files on destruction
*
*/
void enableLogging(); void enableLogging();
/**
* @brief Disables logging and writing to log files on destruction
*
*/
void disableLogging(); void disableLogging();
/**
* @brief Logs the callback duration, with breakdown per operations
*
* @param breakdown The different timings for the callback
* @param numVoices The number of active voices
* @param numSamples The number of samples in the callback
*/
void logCallbackTime(CallbackBreakdown&& breakdown, int numVoices, size_t numSamples); void logCallbackTime(CallbackBreakdown&& breakdown, int numVoices, size_t numSamples);
/**
* @brief Log a file loading and waiting duration
*
* @param waitDuration The time spent waiting before loading the file
* @param loadDuration The time it took to load the file
* @param fileSize The file size
* @param filename The file name
*/
void logFileTime(Duration waitDuration, Duration loadDuration, uint32_t fileSize, absl::string_view filename); void logFileTime(Duration waitDuration, Duration loadDuration, uint32_t fileSize, absl::string_view filename);
private: private:
/**
* @brief Move all events from the real time queues to the non-realtime vectors
*/
void moveEvents() noexcept; void moveEvents() noexcept;
bool loggingEnabled { config::loggingEnabled }; bool loggingEnabled { config::loggingEnabled };
std::string prefix { "" }; std::string prefix { "" };