diff --git a/Libs/Common/Logging.h b/Libs/Common/Logging.h index 9d44f4e6af..3b69f80f07 100644 --- a/Libs/Common/Logging.h +++ b/Libs/Common/Logging.h @@ -187,4 +187,13 @@ class Logging { //! Close session macro #define SW_CLOSE_LOG() shapeworks::Logging::Instance().close_log(); +//! Log once macro, will only log the message once +#define SW_LOG_ONCE(message, ...) \ +{ \ + static bool logged = false; \ + if (!logged) { \ + SW_LOG(message, ##__VA_ARGS__); \ + logged = true; \ + } \ +} } // namespace shapeworks diff --git a/Studio/Data/Telemetry.cpp b/Studio/Data/Telemetry.cpp index 21a931a8f6..081c48d83b 100644 --- a/Studio/Data/Telemetry.cpp +++ b/Studio/Data/Telemetry.cpp @@ -43,12 +43,12 @@ void Telemetry::record_event(const QString& name, const QVariantMap& params) { QString api_secret{GA_API_SECRET}; if (measurement_id.isEmpty() || api_secret.isEmpty()) { - SW_LOG("Telemetry disabled, no measurement id or api secret"); + SW_LOG_ONCE("Telemetry disabled, no measurement id or api secret"); return; } if (!prefs_.get_telemetry_enabled()) { - SW_LOG("Telemetry disabled by preferences"); + SW_LOG_ONCE("Telemetry disabled by preferences"); return; }