From 3b9683e66f46b41229f090dc0996e9950898f196 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Wed, 26 Feb 2020 21:54:43 +0100 Subject: [PATCH] Added comments on the Logger --- src/sfizz/Logger.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/sfizz/Logger.h b/src/sfizz/Logger.h index f14f8438..5f777812 100644 --- a/src/sfizz/Logger.h +++ b/src/sfizz/Logger.h @@ -19,6 +19,10 @@ namespace sfz using Duration = std::chrono::duration; +/** + * @brief Creates an RAII logger which fills or adds to a duration on destruction + * + */ struct ScopedLogger { using TimePoint = std::chrono::time_point; @@ -28,6 +32,12 @@ struct ScopedLogger replaceDuration }; ScopedLogger() = delete; + /** + * @brief Construct a new Scoped Logger object + * + * @param targetDuration + * @param op + */ ScopedLogger(Duration& targetDuration, Operation op = Operation::replaceDuration); ~ScopedLogger(); Duration& targetDuration; @@ -65,13 +75,53 @@ class Logger public: Logger(); ~Logger(); + /** + * @brief Set the prefix for the output log files + * + * @param prefix + */ void setPrefix(const std::string& prefix); + + /** + * @brief Removes all logged data + * + */ void clear(); + + /** + * @brief Enables logging and writing to log files on destruction + * + */ void enableLogging(); + + /** + * @brief Disables logging and writing to log files on destruction + * + */ 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); + + /** + * @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); private: + /** + * @brief Move all events from the real time queues to the non-realtime vectors + */ void moveEvents() noexcept; bool loggingEnabled { config::loggingEnabled }; std::string prefix { "" };