From ba393fd990c41584ba3d548f7f3c43db1491c93d Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Tue, 21 Jul 2026 11:27:49 +0500 Subject: [PATCH 1/6] change itrap api --- .../details/safe_stream_recv_action.h | 6 +- aether/tele/collectors.h | 220 ++++++++---------- aether/tele/compile_option.h | 4 - aether/tele/defines.h | 26 +-- aether/tele/env_collectors.h | 20 +- aether/tele/itrap.h | 77 +++--- aether/tele/levels.h | 14 +- aether/tele/modules.h | 5 - aether/tele/sink.h | 6 +- aether/tele/tags.h | 10 +- aether/tele/traps/io_stream_traps.cpp | 138 ++++++----- aether/tele/traps/io_stream_traps.h | 31 +-- aether/tele/traps/proxy_trap.h | 43 +--- aether/tele/traps/statistics_trap.cpp | 91 +++----- aether/tele/traps/statistics_trap.h | 36 +-- tests/test-tele/test-tele.cpp | 200 ++++++++-------- 16 files changed, 435 insertions(+), 492 deletions(-) diff --git a/aether/safe_stream/details/safe_stream_recv_action.h b/aether/safe_stream/details/safe_stream_recv_action.h index bb06eca5..509f314a 100644 --- a/aether/safe_stream/details/safe_stream_recv_action.h +++ b/aether/safe_stream/details/safe_stream_recv_action.h @@ -19,13 +19,13 @@ #include -#include "aether/common.h" #include "aether/ae_context.h" +#include "aether/common.h" #include "aether/events/events.h" -#include "aether/safe_stream/safe_stream_config.h" #include "aether/safe_stream/details/circular_buffer.h" #include "aether/safe_stream/details/receiving_chunk_list.h" #include "aether/safe_stream/details/safe_stream_data_message.h" +#include "aether/safe_stream/safe_stream_config.h" #include "aether/tele/tele.h" @@ -141,7 +141,7 @@ class SafeStreamRecvAction { } AE_TELED_DEBUG("Received packet index: {}, size: {}, repeat_count: {}", received_range.left, data_span.size(), - static_cast(repeat_count)) + static_cast(repeat_count)); EnqueueRecv(); break; } diff --git a/aether/tele/collectors.h b/aether/tele/collectors.h index 92a6f88a..2b0c38f1 100644 --- a/aether/tele/collectors.h +++ b/aether/tele/collectors.h @@ -17,10 +17,6 @@ #ifndef AETHER_TELE_COLLECTORS_H_ #define AETHER_TELE_COLLECTORS_H_ -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif - #include #include #include @@ -29,25 +25,40 @@ #include #include "aether-miscpp/format/format.h" -#include "aether/clock.h" #include "aether/tele/itrap.h" #include "aether/tele/levels.h" -#include "aether/tele/modules.h" +#include "aether/tele/modules.h" // IWYU pragma: keep #include "aether/tele/tags.h" namespace ae::tele { +namespace collectors_internal { +struct EmptyNull { + template + constexpr explicit EmptyNull(Args&&...) noexcept {} +}; + +template +struct OrEmpty { + using type = std::conditional_t; +}; + +static constexpr inline auto kEmptyFormat = FormatScheme{""}; +} // namespace collectors_internal + +template +using OrEmpty_t = + typename collectors_internal::OrEmpty::type; + struct Timer { Duration elapsed() const { - auto d = std::chrono::duration{Now() - start}; + auto d = TimePoint::clock::now() - start; return std::chrono::duration_cast(d); } - TimePoint const start{Now()}; + TimePoint const start{TimePoint::clock::now()}; }; -struct EmptyNull {}; - struct TimedTele { Timer timer; Tag const& tag; @@ -55,148 +66,125 @@ struct TimedTele { }; template -constexpr bool IsAnyLogs() { - return TConfig::kIndexLogs || TConfig::kStartTimeLogs || - TConfig::kLevelModuleLogs || TConfig::kLocationLogs || - TConfig::kNameLogs || TConfig::kBlobLogs; -} +static constexpr inline bool kIsAnyLogs = + TConfig::kIndexLogs || TConfig::kStartTimeLogs || + TConfig::kLevelModuleLogs || TConfig::kLocationLogs || TConfig::kNameLogs || + TConfig::kBlobLogs; template -constexpr bool IsAnyMetrics() { - return TConfig::kCountMetrics || TConfig::kTimeMetrics; -} +static constexpr inline bool kIsAnyMetrics = + TConfig::kCountMetrics || TConfig::kTimeMetrics; template -constexpr bool IsAnyTele() { - return IsAnyLogs() || IsAnyMetrics(); -} +static constexpr inline bool kIsAnyTele = + kIsAnyLogs || kIsAnyMetrics; template struct TeleLogCollector; +// Specialization for disabled Logs template -struct TeleLogCollector()>> { +struct TeleLogCollector>> + final : public ILogCollector { template - explicit TeleLogCollector(TArgs&&...) {} + constexpr explicit TeleLogCollector(TArgs&&...) noexcept {} - void InvokeTime() {} - void LevelModule([[maybe_unused]] Level) {} - void Location([[maybe_unused]] char const*, int) {} - void TagName(std::string_view) {} - template - void Blob(std::string_view, TArgs&&...) {} - void Blob() {} + void WriteLine(ILogLine&) override {} }; +// Specialization for enabled Logs template -struct TeleLogCollector()>> { - TeleLogCollector(std::shared_ptr const& trap, Tag const& tag) - : trap_(trap.get()), tag_(&tag) { - if (trap_ == nullptr) { - return; - } - trap_->OpenLogLine(*tag_); - } +struct TeleLogCollector>> + final : public ILogCollector { + using SinkConfig = TSinkConfig; - ~TeleLogCollector() { - if (trap_ == nullptr) { - return; - } - trap_->CloseLogLine(*tag_); - } + template + constexpr explicit TeleLogCollector(Tag const& t, Level l, std::string_view f, + std::uint32_t f_l, + std::span b) noexcept + : tag{t}, level{l}, file{f}, line{f_l}, blob{b} {} - void InvokeTime() { - if constexpr (TSinkConfig::kStartTimeLogs) { - if (trap_ == nullptr) { - return; - } - trap_->InvokeTime(Now()); + void WriteLine([[maybe_unused]] ILogLine& log_line) override { + if constexpr (SinkConfig::kStartTimeLogs) { + log_line.InvokeTime(TimePoint::clock::now()); } - } - - void LevelModule([[maybe_unused]] Level level) { - if constexpr (TSinkConfig::kLevelModuleLogs) { - if (trap_ == nullptr) { - return; - } - trap_->WriteLevel(level); - trap_->WriteModule(tag_->module); + if constexpr (SinkConfig::kLevelModuleLogs) { + log_line.WriteLevel(level); + log_line.WriteModule(tag.module); } - } - - void Location([[maybe_unused]] char const* file, int line) { - if constexpr (TSinkConfig::kLocationLogs) { - if (trap_ == nullptr) { - return; - } - trap_->Location(file, static_cast(line)); + if constexpr (SinkConfig::kLocationLogs) { + log_line.Location(file, line); } - } - - void TagName(std::string_view name) { - if constexpr (TSinkConfig::kNameLogs) { - if (trap_ == nullptr) { - return; - } - trap_->TagName(name); + if constexpr (SinkConfig::kNameLogs) { + log_line.TagName(tag.name); } - } - - template - void Blob([[maybe_unused]] FormatScheme const& format, - [[maybe_unused]] TArgs&&... args) { - if constexpr (TSinkConfig::kBlobLogs) { - if (trap_ == nullptr) { - return; - } - auto blob_string = Format(format, std::forward(args)...); - trap_->Blob(reinterpret_cast(blob_string.data()), - blob_string.size()); + if constexpr (SinkConfig::kBlobLogs) { + log_line.Blob(blob); } } - void Blob() {} - - ITrap* trap_; - Tag const* tag_; + [[no_unique_address]] OrEmpty_t< + SinkConfig::kLevelModuleLogs || SinkConfig::kNameLogs, Tag const&> tag; + [[no_unique_address]] OrEmpty_t level; + [[no_unique_address]] OrEmpty_t + file; + [[no_unique_address]] OrEmpty_t + line; + [[no_unique_address]] OrEmpty_t> blob; }; +// Dummy Tele if telemetry is disabled template struct Tele { - // Dummy tele template constexpr explicit Tele(TArgs&&... /* args */) {} - - [[nodiscard]] auto LogCollector() const noexcept { - return TeleLogCollector{}; - } }; +// Tele for enabled telemetry template -struct Tele(), void>> { +struct Tele>> { using Sink = TSink; using SinkConfig = TSinkConfig; - using TimedTele = std::conditional_t; - - constexpr Tele(Sink& sink, Tag const& tag) - : sink_{&sink}, tag_{&tag}, timed_tele_{std::invoke([&]() -> TimedTele { - if constexpr (std::is_same_v) { - return {{}, tag, sink.trap()}; + using TimedTele = OrEmpty_t; + + template + constexpr Tele(Sink& sink, Tag const& tag, [[maybe_unused]] Level level, + [[maybe_unused]] std::string_view file, + [[maybe_unused]] int line, + [[maybe_unused]] FormatScheme const format = + collectors_internal::kEmptyFormat, + [[maybe_unused]] BlobArgs&&... args) noexcept + : timed_tele_{std::invoke([&]() -> TimedTele { + if constexpr (SinkConfig::kTimeMetrics) { + return TimedTele{.timer = {}, .tag = tag, .trap = sink.trap()}; } else { - return {}; + return TimedTele{}; } })} { + auto trap = sink.trap(); + if (!trap) { + return; + } if constexpr (SinkConfig::kCountMetrics) { - auto const& trap = sink.trap(); - if (!trap) { - return; - } trap->AddInvoke(tag, 1); } + + if constexpr (kIsAnyLogs) { + // TODO: more effective way to make blob + std::string blob_str; + std::span blob{}; + if constexpr (SinkConfig::kBlobLogs) { + if (format.source != collectors_internal::kEmptyFormat.source) { + FormatTo(blob_str, format, std::forward(args)...); + blob = {reinterpret_cast(blob_str.data()), + blob_str.size()}; + } + } + auto collector = TeleLogCollector{ + tag, level, file, static_cast(line), blob}; + trap->LogLine(tag, collector); + } } ~Tele() { @@ -209,14 +197,8 @@ struct Tele{sink_->trap(), *tag_}; - } - private: - Sink* sink_; - Tag const* tag_; - TimedTele timed_tele_; + [[no_unique_address]] TimedTele timed_tele_; }; } // namespace ae::tele diff --git a/aether/tele/compile_option.h b/aether/tele/compile_option.h index 937a1a7c..263534dc 100644 --- a/aether/tele/compile_option.h +++ b/aether/tele/compile_option.h @@ -17,10 +17,6 @@ #ifndef AETHER_TELE_COMPILE_OPTION_H_ #define AETHER_TELE_COMPILE_OPTION_H_ -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif - #include #include diff --git a/aether/tele/defines.h b/aether/tele/defines.h index f9ccfcf0..3e43c6c9 100644 --- a/aether/tele/defines.h +++ b/aether/tele/defines.h @@ -19,14 +19,10 @@ #include "aether/common.h" -#include "aether/tele/tags.h" -#include "aether/tele/modules.h" #include "aether/tele/collectors.h" #include "aether/tele/env_collectors.h" - -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif +#include "aether/tele/modules.h" +#include "aether/tele/tags.h" #ifndef UTM_ID # define UTM_ID 0 @@ -42,18 +38,12 @@ using ae::tele::Tele; AE_TELE_MODULE(MLog, AE_LOG_MODULE, AE_LOG_MODULE, AE_LOG_MODULE); AE_TAG(kLog, MLog) -#define AE_TELE_(TAG_NAME, TAG, LEVEL, ...) \ - [[maybe_unused]] auto TAG_NAME = \ - ::ae::tele::Tele>{ \ - TELE_SINK::Instance(), TAG}; \ - { \ - auto log_collector = TAG_NAME.LogCollector(); \ - log_collector.InvokeTime(); \ - log_collector.LevelModule(::ae::tele::Level{LEVEL}); \ - log_collector.Location(__FILE__, __LINE__); \ - log_collector.TagName(TAG.name); \ - log_collector.Blob(__VA_ARGS__); \ +#define AE_TELE_(TAG_NAME, TAG, LEVEL, ...) \ + [[maybe_unused]] auto TAG_NAME = \ + ::ae::tele::Tele> { \ + TELE_SINK::Instance(), TAG, ::ae::tele::Level{LEVEL}, __FILE__, __LINE__, \ + __VA_ARGS__ \ } #define AE_TELE_DEBUG(TAG, ...) \ diff --git a/aether/tele/env_collectors.h b/aether/tele/env_collectors.h index bda92b07..e18cfaed 100644 --- a/aether/tele/env_collectors.h +++ b/aether/tele/env_collectors.h @@ -17,10 +17,6 @@ #ifndef AETHER_TELE_ENV_COLLECTORS_H_ #define AETHER_TELE_ENV_COLLECTORS_H_ -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif - #include #include #include @@ -88,7 +84,9 @@ constexpr auto ApiVersion() { return "0.0.0"; } -constexpr auto PlatformEndianness() { return AE_ENDIANNESS; } +constexpr Endianness PlatformEndianness() { + return static_cast(AE_ENDIANNESS); +} constexpr auto CpuType() { return AE_CPU_TYPE; } template &&... args) { + std::vector compile_options; + std::vector custom_options; auto env_data = EnvData{}; if constexpr (SinkConfig::kPlatformType) { env_data.platform_type = PlatformType(); @@ -111,8 +111,9 @@ struct EnvTele { } if constexpr (SinkConfig::kCompilationOptions) { auto opts = CompilationOptions(); - env_data.compile_options.insert(std::end(env_data.compile_options), - std::begin(opts), std::end(opts)); + compile_options.insert(std::end(compile_options), std::begin(opts), + std::end(opts)); + env_data.compile_options = std::span{compile_options}; } if constexpr (SinkConfig::kLibraryVersion) { env_data.library_version = LibraryVersion(); @@ -122,13 +123,14 @@ struct EnvTele { } if constexpr (SinkConfig::kCpuType) { env_data.cpu_arch = CpuType(); - env_data.endianness = static_cast(PlatformEndianness()); + env_data.endianness = PlatformEndianness(); } if constexpr (SinkConfig::kUtmId) { env_data.utm_id = utm_id; } if constexpr (SinkConfig::kCustomData) { - env_data.custom_options = {CustomOption{args.first, args.second}...}; + custom_options = {CustomOption{args.first, args.second}...}; + env_data.custom_options = std::span{custom_options}; } auto& trap = sink.trap(); if (!trap) { diff --git a/aether/tele/itrap.h b/aether/tele/itrap.h index 951f9812..dac4252a 100644 --- a/aether/tele/itrap.h +++ b/aether/tele/itrap.h @@ -17,22 +17,23 @@ #ifndef AETHER_TELE_ITRAP_H_ #define AETHER_TELE_ITRAP_H_ -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif - -#include +#include #include +#include #include -#include "aether/clock.h" -#include "aether/tele/tags.h" +#include "aether/tele/compile_option.h" #include "aether/tele/levels.h" #include "aether/tele/modules.h" -#include "aether/tele/compile_option.h" +#include "aether/tele/tags.h" namespace ae::tele { +using TimePoint = std::chrono::system_clock::time_point; +using Duration = std::chrono::microseconds; + +enum class Endianness : std::uint8_t { Little = 1, Big }; + struct EnvData { std::string_view platform_type; std::string_view compiler; @@ -40,30 +41,17 @@ struct EnvData { std::string_view library_version; std::string_view api_version; std::string_view cpu_arch; - std::uint8_t endianness; + Endianness endianness; std::uint32_t utm_id; - std::vector compile_options; - std::vector custom_options; + std::span compile_options; + std::span custom_options; }; -/** - * \brief Telemetry trap interaface. - */ -class ITrap { - public: - virtual ~ITrap() = default; - /** - * \brief Invoke count for metrics - */ - virtual void AddInvoke(Tag const& tag, std::uint32_t count) = 0; - /** - * \brief Invoke duration for metrics - */ - virtual void AddInvokeDuration(Tag const& tag, Duration duration) = 0; - /** - * \brief Open the log line to write. - */ - virtual void OpenLogLine(Tag const& tag) = 0; +class ILogLine { + protected: + ~ILogLine() = default; + + public: /** * \brief Telemetry invoke time. */ @@ -87,11 +75,36 @@ class ITrap { /** * \brief Get stream to write telemetry blob data. */ - virtual void Blob(std::uint8_t const* data, std::size_t size) = 0; + virtual void Blob(std::span blob) = 0; +}; + +// Collects logs and write them to the LogLine +class ILogCollector { + protected: + ~ILogCollector() = default; + + public: + virtual void WriteLine(ILogLine& log_line) = 0; +}; + +/** + * \brief Telemetry trap interaface. + */ +class ITrap { + public: + virtual ~ITrap() = default; + /** + * \brief Invoke count for metrics + */ + virtual void AddInvoke(Tag const& tag, std::uint32_t count) = 0; + /** + * \brief Invoke duration for metrics + */ + virtual void AddInvokeDuration(Tag const& tag, Duration duration) = 0; /** - * \brief Close the log line + * \brief Write collected log. */ - virtual void CloseLogLine(Tag const& tag) = 0; + virtual void LogLine(Tag const& tag, ILogCollector& log_collector) = 0; /** * \brief Write an environment data */ diff --git a/aether/tele/levels.h b/aether/tele/levels.h index 1e8184eb..deb0d142 100644 --- a/aether/tele/levels.h +++ b/aether/tele/levels.h @@ -18,12 +18,12 @@ #define AETHER_TELE_LEVELS_H_ #include -#include +#include namespace ae::tele { struct Level { using underlined_t = std::uint8_t; - enum _ : std::uint8_t { + enum LevelVariant : std::uint8_t { // NOLINT(*use-enum-class*) kInfo = 1 << 0, kWarning = 1 << 1, kError = 1 << 2, @@ -31,8 +31,8 @@ struct Level { kAll = 0xFF, }; - static std::string text(underlined_t v) { - switch (v) { + std::string_view Text() const { + switch (value_) { case kInfo: return "kInfo"; case kWarning: @@ -41,11 +41,15 @@ struct Level { return "kError"; case kDebug: return "kDebug"; + default: + break; } return ""; } - operator underlined_t() const noexcept { return value_; } + operator underlined_t() const noexcept { // NOLINT(*explicit*) + return value_; + } underlined_t value_; }; diff --git a/aether/tele/modules.h b/aether/tele/modules.h index f49e5dd3..b90d2c3b 100644 --- a/aether/tele/modules.h +++ b/aether/tele/modules.h @@ -17,12 +17,7 @@ #ifndef AETHER_TELE_MODULES_H_ #define AETHER_TELE_MODULES_H_ -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif - #include -#include #include namespace ae::tele { diff --git a/aether/tele/sink.h b/aether/tele/sink.h index 22db5f01..e58122ed 100644 --- a/aether/tele/sink.h +++ b/aether/tele/sink.h @@ -17,12 +17,8 @@ #ifndef AETHER_TELE_SINK_H_ #define AETHER_TELE_SINK_H_ -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif - -#include #include +#include #include "aether/tele/itrap.h" #include "aether/tele/levels.h" diff --git a/aether/tele/tags.h b/aether/tele/tags.h index 8b1b9814..857bfb82 100644 --- a/aether/tele/tags.h +++ b/aether/tele/tags.h @@ -17,15 +17,10 @@ #ifndef AETHER_TELE_TAGS_H_ #define AETHER_TELE_TAGS_H_ -#ifndef AETHER_TELE_TELE_H_ -# error "Include tele.h instead" -#endif - #include -#include #include -#include "aether-miscpp/crc.h" +#include "aether-miscpp/crc.h" // IWYU pragma: keep #include "aether/tele/modules.h" namespace ae::tele { @@ -48,6 +43,7 @@ struct Tag { }; } // namespace ae::tele +// NOLINTBEGIN #define _AE_CRC(LITERAL) ::crc32::checksum_from_literal(LITERAL) #define _AE_FILE_TAG(MODULE) _AE_CRC(__FILE__ #MODULE) @@ -71,6 +67,8 @@ struct Tag { static_assert(((MODULE).index_start + (NAME).offset) <= (MODULE).index_end, \ "Tag index out of range"); +// NOLINTEND + /** * \brief Register Tag with index automatically incremented from previous * AE_TAG* call diff --git a/aether/tele/traps/io_stream_traps.cpp b/aether/tele/traps/io_stream_traps.cpp index 3ea5b807..b4257b68 100644 --- a/aether/tele/traps/io_stream_traps.cpp +++ b/aether/tele/traps/io_stream_traps.cpp @@ -19,6 +19,7 @@ #include "aether/tele/traps/io_stream_traps.h" #include +#include #include "aether-miscpp/format/format.h" @@ -29,19 +30,78 @@ void WriteUnformatted(std::ostream& stream, std::string_view value) { stream.write(value.data(), static_cast(value.size())); } +void WritePaddedIndex(std::ostream& stream, std::uint32_t index) { + static constexpr auto kPaddings = " "; + static constexpr auto kSteps = 3; + + auto decs = std::invoke([&]() noexcept { + std::uint32_t delim = 10; + for (auto i = 0; i < kSteps; ++i) { + auto d = index / delim; + if (d == 0) { + return i; + } + delim = delim * delim; + } + return kSteps; + }); + stream.write(kPaddings, kSteps - decs); + Format(stream, "{}", index); +} + } // namespace +IoStreamTrap::LogLineWriter::LogLineWriter(std::ostream& s, Tag const& tag) + : stream_{s} { + WritePaddedIndex(stream_, tag.index()); +} + +void IoStreamTrap::LogLineWriter::InvokeTime(TimePoint time) { + Format(stream_, ":[{:time}]", time); +} +void IoStreamTrap::LogLineWriter::WriteLevel(Level level) { + stream_.put(':'); + WriteUnformatted(stream_, level.Text()); +} +void IoStreamTrap::LogLineWriter::WriteModule(Module const& module) { + stream_.put(':'); + WriteUnformatted(stream_, module.name); +} +void IoStreamTrap::LogLineWriter::Location(std::string_view file, + std::uint32_t line) { + auto pos = file.find_last_of("/\\"); + if (pos != std::string_view::npos) { + file = file.substr(pos + 1, file.size() - pos); + } else { + file = "UNKNOWN FILE"; + } + Format(stream_, ":{}:{}", file, line); +} +void IoStreamTrap::LogLineWriter::TagName(std::string_view name) { + stream_.put(':'); + WriteUnformatted(stream_, name); +} +void IoStreamTrap::LogLineWriter::Blob(std::span blob) { + if (blob.empty()) { + return; + } + stream_.put(':'); + stream_.write(reinterpret_cast(blob.data()), + static_cast(blob.size())); +} + IoStreamTrap::IoStreamTrap(std::ostream& stream) : stream_{stream} {} IoStreamTrap::~IoStreamTrap() { auto lock = std::scoped_lock{sync_lock_}; - stream_ << "Metrics:\n"; - stream_ << "Index,Invocations,Max Duration,Sum Duration,Min Duration\n"; + WriteUnformatted(stream_, "Metrics:\n"); + WriteUnformatted( + stream_, "Index,Invocations,Max Duration,Sum Duration,Min Duration\n"); for (auto const& [index, ms] : metrics_) { Format(stream_, "{},{},{},{},{}\n", index, ms.invocations_count, ms.max_duration, ms.sum_duration, ms.min_duration); } - stream_ << '\n'; + stream_.put('\n'); stream_.flush(); } @@ -53,58 +113,23 @@ void IoStreamTrap::AddInvoke(Tag const& tag, std::uint32_t count) { void IoStreamTrap::AddInvokeDuration(Tag const& tag, Duration duration) { auto lock = std::scoped_lock{sync_lock_}; auto& metric = metrics_[tag.index()]; - metric.max_duration = std::max(metric.max_duration, duration.count()); + metric.max_duration = std::max(metric.max_duration, + static_cast(duration.count())); metric.sum_duration += duration.count(); if (metric.min_duration == 0) { - metric.min_duration = duration.count(); - } else { - metric.min_duration = std::min(metric.min_duration, duration.count()); - } -} - -void IoStreamTrap::OpenLogLine(Tag const& tag) { - sync_lock_.lock(); - WritePaddedIndex(tag.index()); -} - -void IoStreamTrap::InvokeTime(TimePoint time) { - Format(stream_, ":[{:time}]", time); -} - -void IoStreamTrap::WriteLevel(Level level) { - stream_.put(':'); - WriteUnformatted(stream_, Level::text(level.value_)); -} - -void IoStreamTrap::WriteModule(Module const& module) { - stream_.put(':'); - WriteUnformatted(stream_, module.name); -} - -void IoStreamTrap::Location(std::string_view file, std::uint32_t line) { - auto pos = file.find_last_of("/\\"); - if (pos != std::string_view::npos) { - file = file.substr(pos + 1, file.size() - pos); + metric.min_duration = static_cast(duration.count()); } else { - file = "UNKNOWN FILE"; + metric.min_duration = std::min( + metric.min_duration, static_cast(duration.count())); } - Format(stream_, ":{}:{}", file, line); -} - -void IoStreamTrap::TagName(std::string_view name) { - stream_.put(':'); - WriteUnformatted(stream_, name); } -void IoStreamTrap::Blob(std::uint8_t const* data, std::size_t size) { - stream_.put(':'); - stream_.write(reinterpret_cast(data), - static_cast(size)); -} - -void IoStreamTrap::CloseLogLine(Tag const&) { - stream_ << std::endl; - sync_lock_.unlock(); +void IoStreamTrap::LogLine(Tag const& tag, ILogCollector& log_collector) { + auto lock = std::scoped_lock{sync_lock_}; + auto log_line = LogLineWriter(stream_, tag); + log_collector.WriteLine(log_line); + stream_.put('\n'); + stream_.flush(); } void IoStreamTrap::WriteEnvData(EnvData const& env_data) { @@ -115,9 +140,8 @@ void IoStreamTrap::WriteEnvData(EnvData const& env_data) { "version:{}\nCPU arch:{}\nEndianness:{}\nUTMid:{}\n", env_data.platform_type, env_data.compiler, env_data.compiler_version, env_data.library_version, env_data.api_version, env_data.cpu_arch, - (env_data.endianness == static_cast(AE_LITTLE_ENDIAN) - ? "LittleEndian" - : "BigEndian"), + (env_data.endianness == Endianness::Little ? "LittleEndian" + : "BigEndian"), env_data.utm_id); constexpr auto option_format = FormatScheme{"{}:{}\n"}; for (auto const& opt : env_data.compile_options) { @@ -126,16 +150,8 @@ void IoStreamTrap::WriteEnvData(EnvData const& env_data) { for (auto const& opt : env_data.custom_options) { Format(stream_, option_format, opt.name, opt.value); } - stream_ << '\n'; + stream_.put('\n'); stream_.flush(); } -void IoStreamTrap::WritePaddedIndex(std::uint32_t index) { - if (index < 10) { - stream_ << " "; - } else if (index < 100) { - stream_ << ' '; - } - Format(stream_, "{}", index); -} } // namespace ae::tele diff --git a/aether/tele/traps/io_stream_traps.h b/aether/tele/traps/io_stream_traps.h index 41a33675..e99d554e 100644 --- a/aether/tele/traps/io_stream_traps.h +++ b/aether/tele/traps/io_stream_traps.h @@ -17,15 +17,12 @@ #ifndef AETHER_TELE_TRAPS_IO_STREAM_TRAPS_H_ #define AETHER_TELE_TRAPS_IO_STREAM_TRAPS_H_ -#include #include #include #include #include #include -#include "aether/common.h" - #include "aether/tele/itrap.h" namespace ae::tele { @@ -39,19 +36,29 @@ struct Metric { class IoStreamTrap final : public ITrap { public: + class LogLineWriter final : public ILogLine { + public: + LogLineWriter(std::ostream& s, Tag const& tag); + + void InvokeTime(TimePoint time) override; + void WriteLevel(Level level) override; + void WriteModule(Module const& module) override; + void Location(std::string_view file, std::uint32_t line) override; + void TagName(std::string_view name) override; + void Blob(std::span) override; + + private: + std::ostream& stream_; + }; + explicit IoStreamTrap(std::ostream& stream); ~IoStreamTrap() override; void AddInvoke(Tag const& tag, std::uint32_t count) override; void AddInvokeDuration(Tag const& tag, Duration duration) override; - void OpenLogLine(Tag const& tag) override; - void InvokeTime(TimePoint time) override; - void WriteLevel(Level level) override; - void WriteModule(Module const& module) override; - void Location(std::string_view file, std::uint32_t line) override; - void TagName(std::string_view name) override; - void Blob(std::uint8_t const* data, std::size_t size) override; - void CloseLogLine(Tag const& tag) override; + + void LogLine(Tag const& tag, ILogCollector& log_collector) override; + void WriteEnvData(EnvData const& env_data) override; std::unordered_map const& metrics() const { @@ -59,8 +66,6 @@ class IoStreamTrap final : public ITrap { } private: - void WritePaddedIndex(std::uint32_t index); - std::mutex sync_lock_; std::ostream& stream_; std::unordered_map metrics_; diff --git a/aether/tele/traps/proxy_trap.h b/aether/tele/traps/proxy_trap.h index 00083611..6d32a4e0 100644 --- a/aether/tele/traps/proxy_trap.h +++ b/aether/tele/traps/proxy_trap.h @@ -19,8 +19,6 @@ #include -#include "aether/clock.h" - #include "aether/tele/itrap.h" namespace ae::tele { @@ -44,44 +42,9 @@ class ProxyTrap final : public ITrap { second->AddInvokeDuration(tag, duration); } - void OpenLogLine(Tag const& tag) override { - first->OpenLogLine(tag); - second->OpenLogLine(tag); - } - - void InvokeTime(TimePoint time) override { - first->InvokeTime(time); - second->InvokeTime(time); - } - - void WriteLevel(Level level) override { - first->WriteLevel(level); - second->WriteLevel(level); - } - - void WriteModule(Module const& module) override { - first->WriteModule(module); - second->WriteModule(module); - } - - void Location(std::string_view file, std::uint32_t line) override { - first->Location(file, line); - second->Location(file, line); - } - - void TagName(std::string_view name) override { - first->TagName(name); - second->TagName(name); - } - - void Blob(std::uint8_t const* data, std::size_t size) override { - first->Blob(data, size); - second->Blob(data, size); - } - - void CloseLogLine(Tag const& tag) override { - first->CloseLogLine(tag); - second->CloseLogLine(tag); + void LogLine(Tag const& tag, ILogCollector& log_collector) override { + first->LogLine(tag, log_collector); + second->LogLine(tag, log_collector); } void WriteEnvData(EnvData const& env_data) override { diff --git a/aether/tele/traps/statistics_trap.cpp b/aether/tele/traps/statistics_trap.cpp index 71ab5067..16a7d925 100644 --- a/aether/tele/traps/statistics_trap.cpp +++ b/aether/tele/traps/statistics_trap.cpp @@ -100,27 +100,49 @@ void StatisticsStore::SetSizeLimit(std::size_t limit) { StatisticsTrap::StatisticsTrap() = default; StatisticsTrap::~StatisticsTrap() = default; -StatisticsTrap::LogLine::LogLine(std::unique_lock l, - RcPtr log, - std::vector& d) - : lock{std::move(l)}, - log_storage{std::move(log)}, - vector_writer{d}, - log_writer{vector_writer} {} - -StatisticsTrap::LogLine::~LogLine() { +StatisticsTrap::LogLineWriter::LogLineWriter(Tag const& tag, + RcPtr log, + std::vector& d) + : log_storage{std::move(log)}, vector_writer{d}, log_writer{vector_writer} { + log_writer << PackedIndex{tag.index()}; +} + +StatisticsTrap::LogLineWriter::~LogLineWriter() { // update log size std::get(*log_storage).size += vector_writer.data_.size(); } +void StatisticsTrap::LogLineWriter::InvokeTime(TimePoint time) { + log_writer << time; +} +void StatisticsTrap::LogLineWriter::WriteLevel(Level level) { + log_writer << level.value_; +} +void StatisticsTrap::LogLineWriter::WriteModule(Module const& module) { + log_writer << module.id; +} +void StatisticsTrap::LogLineWriter::Location(std::string_view file, + std::uint32_t line) { + log_writer << file << line; +} +void StatisticsTrap::LogLineWriter::TagName(std::string_view name) { + log_writer << name; +} +void StatisticsTrap::LogLineWriter::Blob(std::span blob) { + if (blob.empty()) { + return; + } + log_writer.write(static_cast(blob.data()), blob.size()); +} + void StatisticsTrap::AddInvoke(Tag const& tag, std::uint32_t count) { - auto lock = std::lock_guard(sync_lock_); + auto lock = std::scoped_lock(sync_lock_); statistics_store.metrics_store().metrics[tag.index()].invocations_count += count; } void StatisticsTrap::AddInvokeDuration(Tag const& tag, Duration duration) { - auto lock = std::lock_guard(sync_lock_); + auto lock = std::scoped_lock(sync_lock_); auto& metr = statistics_store.metrics_store().metrics[tag.index()]; metr.sum_duration += static_cast(duration.count()); @@ -135,51 +157,14 @@ void StatisticsTrap::AddInvokeDuration(Tag const& tag, Duration duration) { } } -void StatisticsTrap::OpenLogLine(Tag const& tag) { - auto lock = std::unique_lock{sync_lock_}; +void StatisticsTrap::LogLine(Tag const& tag, ILogCollector& log_collector) { + auto lock = std::scoped_lock{sync_lock_}; auto log_store = statistics_store.log_store(); auto& runtime_log = std::get(*log_store); auto& data = runtime_log.logs.emplace_back(); - log_line_.emplace(std::move(lock), log_store, data); - // always write an index - log_line_->log_writer << PackedIndex{tag.index()}; -} - -void StatisticsTrap::InvokeTime(TimePoint time) { - assert(log_line_); - log_line_->log_writer << time; -} - -void StatisticsTrap::WriteLevel(Level level) { - assert(log_line_); - log_line_->log_writer << level.value_; -} - -void StatisticsTrap::WriteModule(Module const& module) { - assert(log_line_); - log_line_->log_writer << module.id; -} - -void StatisticsTrap::Location(std::string_view file, std::uint32_t line) { - assert(log_line_); - log_line_->log_writer << file << line; -} - -void StatisticsTrap::TagName(std::string_view name) { - assert(log_line_); - log_line_->log_writer << name; -} - -void StatisticsTrap::Blob(std::uint8_t const* data, std::size_t size) { - assert(log_line_); - log_line_->log_writer.write(static_cast(data), size); -} - -void StatisticsTrap::CloseLogLine(Tag const& /*tag*/) { - assert(log_line_); - auto lock = std::move(log_line_->lock); - log_line_.reset(); + auto log_line = LogLineWriter{tag, log_store, data}; + log_collector.WriteLine(log_line); } void StatisticsTrap::WriteEnvData(EnvData const& env_data) { @@ -190,7 +175,7 @@ void StatisticsTrap::WriteEnvData(EnvData const& env_data) { env_store.library_version = env_data.library_version; env_store.api_version = env_data.api_version; env_store.cpu_arch = env_data.cpu_arch; - env_store.endianness = env_data.endianness; + env_store.endianness = static_cast(env_data.endianness); env_store.utm_id = env_data.utm_id; for (auto const& opt : env_data.compile_options) { env_store.compile_options.emplace_back(PackedIndex{opt.index}, diff --git a/aether/tele/traps/statistics_trap.h b/aether/tele/traps/statistics_trap.h index 48f093cf..98783ce7 100644 --- a/aether/tele/traps/statistics_trap.h +++ b/aether/tele/traps/statistics_trap.h @@ -17,23 +17,23 @@ #ifndef AETHER_TELE_TRAPS_STATISTICS_TRAP_H_ #define AETHER_TELE_TRAPS_STATISTICS_TRAP_H_ -#include #include +#include #include #include -#include #include #include +#include #include +#include "aether-miscpp/reflect/reflect.h" #include "aether/clock.h" #include "aether/config.h" #include "aether/mstream.h" +#include "aether/mstream_buffers.h" #include "aether/ptr/rc_ptr.h" #include "aether/tele/itrap.h" -#include "aether/mstream_buffers.h" -#include "aether-miscpp/reflect/reflect.h" namespace ae::tele { namespace statistics { @@ -186,12 +186,20 @@ class StatisticsTrap final : public ITrap { using PackedIndex = TieredInt; using PackedLine = TieredInt; - struct LogLine { - LogLine(std::unique_lock l, RcPtr log, - std::vector& d); - ~LogLine(); + class LogLineWriter final : public ILogLine { + public: + LogLineWriter(Tag const& tag, RcPtr log, + std::vector& d); + ~LogLineWriter(); + + void InvokeTime(TimePoint time) override; + void WriteLevel(Level level) override; + void WriteModule(Module const& module) override; + void Location(std::string_view file, std::uint32_t line) override; + void TagName(std::string_view name) override; + void Blob(std::span blob) override; - std::unique_lock lock; + private: RcPtr log_storage; VectorWriter vector_writer; omstream> log_writer; @@ -202,14 +210,7 @@ class StatisticsTrap final : public ITrap { void AddInvoke(Tag const& tag, std::uint32_t count) override; void AddInvokeDuration(Tag const& tag, Duration duration) override; - void OpenLogLine(Tag const& tag) override; - void InvokeTime(TimePoint time) override; - void WriteLevel(Level level) override; - void WriteModule(Module const& module) override; - void Location(std::string_view file, std::uint32_t line) override; - void TagName(std::string_view name) override; - void Blob(std::uint8_t const* data, std::size_t size) override; - void CloseLogLine(Tag const& tag) override; + void LogLine(Tag const& tag, ILogCollector& log_collector) override; void WriteEnvData(EnvData const& env_data) override; /** @@ -223,7 +224,6 @@ class StatisticsTrap final : public ITrap { private: std::mutex sync_lock_; - std::optional log_line_; }; } // namespace statistics } // namespace ae::tele diff --git a/tests/test-tele/test-tele.cpp b/tests/test-tele/test-tele.cpp index 6c6110a0..94942373 100644 --- a/tests/test-tele/test-tele.cpp +++ b/tests/test-tele/test-tele.cpp @@ -48,17 +48,17 @@ #include "aether-miscpp/meta/type_list.h" -#include "aether/tele/sink.h" -#include "aether/tele/tags.h" -#include "aether/tele/modules.h" -#include "aether/tele/defines.h" #include "aether/tele/collectors.h" +#include "aether/tele/defines.h" #include "aether/tele/env_collectors.h" +#include "aether/tele/modules.h" +#include "aether/tele/sink.h" +#include "aether/tele/tags.h" #include "aether/tele/configs/config_provider.h" -#include "aether/tele/traps/proxy_trap.h" #include "aether/tele/traps/io_stream_traps.h" +#include "aether/tele/traps/proxy_trap.h" #include "aether/tele/traps/statistics_trap.h" using SinkType = ae::tele::TeleSink; @@ -134,6 +134,49 @@ struct TeleTrap final : public ITrap { std::uint32_t duration_{}; }; + class LogLineWriter final : public ILogLine { + public: + explicit LogLineWriter(std::vector& line) : log_line{line} {} + /** + * \brief Telemetry invoke time. + */ + void InvokeTime(TimePoint time) override { + log_line.emplace_back(Format("{:time}", time)); + }; + /** + * \brief Telemetry tag level + */ + void WriteLevel(Level level) override { + log_line.emplace_back(level.Text()); + }; + /** + * \brief Tag module + */ + void WriteModule(Module const& module) override { + log_line.emplace_back(module.name); + }; + /** + * \brief Tag location + */ + void Location(std::string_view file, std::uint32_t line) override { + log_line.emplace_back(Format("{file}:{line}", file, line)); + }; + /** + * \brief Tag name + */ + void TagName(std::string_view name) override { + log_line.emplace_back(name); + }; + /** + * \brief Get stream to write telemetry blob data. + */ + void Blob(std::span blob) override { + log_line.emplace_back(reinterpret_cast(blob.data()), + blob.size()); + }; + std::vector& log_line; + }; + void AddInvoke(Tag const& tag, std::uint32_t count) override { metric_data_[tag.index()].count_ += count; } @@ -141,35 +184,13 @@ struct TeleTrap final : public ITrap { metric_data_[tag.index()].duration_ += static_cast(duration.count()); } - void OpenLogLine(Tag const& tag) override { - log_lines_.emplace_back(); - log_lines_.front().emplace_back(std::to_string(tag.index())); - } - void InvokeTime(TimePoint time) override { - log_lines_.front().emplace_back(Format("{:time}", time)); + void LogLine(Tag const& tag, ILogCollector& log_collector) override { + auto& line = log_lines_.emplace_back(); + line.emplace_back(std::to_string(tag.index())); + auto writer = LogLineWriter{line}; + log_collector.WriteLine(writer); } - void WriteLevel(Level level) override { - log_lines_.front().emplace_back(Level::text(level.value_)); - } - void WriteModule(Module const& module) override { - log_lines_.front().emplace_back(module.name); - } - void Location(std::string_view file, std::uint32_t line) override { - auto pos = file.find_last_of("/\\"); - if (pos == std::string_view::npos) { - file = "UNKNOWN FILE"; - } - file = file.substr(pos + 1, file.size() - pos); - log_lines_.front().emplace_back(Format("{file}:{line}", file, line)); - } - void TagName(std::string_view name) override { - log_lines_.front().emplace_back(name); - } - void Blob(std::uint8_t const* data, std::size_t size) override { - log_lines_.front().emplace_back( - std::string(reinterpret_cast(data), size)); - } - void CloseLogLine(Tag const& /*tag*/) override {} + void WriteEnvData(EnvData const& /*env_data*/) override {} std::list> log_lines_; @@ -218,18 +239,11 @@ void test_TeleConfigurations() { auto tele_trap = std::make_shared(); Sink::Instance().SetTrap(tele_trap); - int remember_line = __LINE__ + 8; { auto t = Tele>{ - Sink::Instance(), TestTag}; - { - auto lc = t.LogCollector(); - lc.InvokeTime(); - lc.LevelModule(Level{Level::kDebug}); - lc.Location(__FILE__, __LINE__); - lc.TagName(TestTag.name); - lc.Blob("message {}", 12); - } + Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, + "message {}", 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT_EQUAL(1, tele_trap->metric_data_.size()); @@ -243,8 +257,7 @@ void test_TeleConfigurations() { AssertTimestampShape(log_line[1]); TEST_ASSERT_EQUAL_STRING("kDebug", log_line[2].c_str()); TEST_ASSERT_EQUAL_STRING("TestObj", log_line[3].c_str()); - TEST_ASSERT_EQUAL_STRING(Format("test-tele.cpp:{}", remember_line).c_str(), - log_line[4].c_str()); + TEST_ASSERT_EQUAL_STRING("test-tele.cpp:8", log_line[4].c_str()); TEST_ASSERT_EQUAL_STRING("Test", log_line[5].c_str()); TEST_ASSERT_EQUAL_STRING("message 12", log_line[6].c_str()); } @@ -258,15 +271,9 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { auto t = Tele>{ - Sink::Instance(), TestTag}; - { - auto lc = t.LogCollector(); - lc.InvokeTime(); - lc.LevelModule(Level{Level::kDebug}); - lc.Location(__FILE__, __LINE__); - lc.TagName(TestTag.name); - lc.Blob("message {}", 12); - } + Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, + "message {}", 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT_EQUAL(1, tele_trap->metric_data_.size()); @@ -283,15 +290,9 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { auto t = Tele>{ - Sink::Instance(), TestTag}; - { - auto lc = t.LogCollector(); - lc.InvokeTime(); - lc.LevelModule(Level{Level::kDebug}); - lc.Location(__FILE__, __LINE__); - lc.TagName(TestTag.name); - lc.Blob("message {}", 12); - } + Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, + "message {}", 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT_EQUAL(1, tele_trap->metric_data_.size()); @@ -317,16 +318,9 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { auto t = Tele>{ - Sink::Instance(), TestTag}; - { - auto lc = t.LogCollector(); - lc.InvokeTime(); - lc.LevelModule(Level{Level::kDebug}); - lc.Location(__FILE__, __LINE__); - lc.TagName(TestTag.name); - lc.Blob("message {}", 12); - } - + Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, + "message {}", 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT(tele_trap->metric_data_.empty()); @@ -342,16 +336,9 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { auto t = Tele>{ - Sink::Instance(), TestTag}; - { - auto lc = t.LogCollector(); - lc.InvokeTime(); - lc.LevelModule(Level{Level::kDebug}); - lc.Location(__FILE__, __LINE__); - lc.TagName(TestTag.name); - lc.Blob("message {}", 12); - } - + Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, + "message {}", 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } @@ -468,27 +455,36 @@ void test_MergeStatisticsTrap() { #define TELE_SINK SinkType } +template +struct LambdaLogCollector final : public ILogCollector { + explicit LambdaLogCollector(WriteFn&& wf) : write_fn{std::move(wf)} {} + void WriteLine(ILogLine& log_line) override { write_fn(log_line); } + WriteFn write_fn; +}; + void test_IoStreamTrapFullOutput() { auto stream = std::ostringstream{}; auto trap = IoStreamTrap{stream}; - auto const fixed_time = TimePoint{std::chrono::hours{3} + - std::chrono::minutes{4} + - std::chrono::seconds{5} + - std::chrono::microseconds{123456}}; + auto const fixed_time = + TimePoint{std::chrono::hours{3} + std::chrono::minutes{4} + + std::chrono::seconds{5} + std::chrono::microseconds{123456}}; auto const tag = Tag{11, TestObj, "Test"}; - trap.OpenLogLine(tag); - trap.InvokeTime(fixed_time); - trap.WriteLevel(Level{Level::kDebug}); - trap.WriteModule(TestObj); - trap.Location("src/test-tele.cpp", 42); - trap.TagName(tag.name); - trap.Blob(reinterpret_cast("message 12"), 10); - trap.CloseLogLine(tag); + auto log_collector = LambdaLogCollector{[&](ILogLine& log_line) { + log_line.InvokeTime(fixed_time); + log_line.WriteLevel(Level{Level::kDebug}); + log_line.WriteModule(TestObj); + log_line.Location("src/test-tele.cpp", 42); + log_line.TagName(tag.name); + log_line.Blob( + std::span{reinterpret_cast("message 12"), 10}); + }}; + + trap.LogLine(tag, log_collector); auto const output = stream.str(); TEST_ASSERT_EQUAL_STRING( - " 12:[03:04:05.123456]:kDebug:TestObj:test-tele.cpp:42:Test:message " + " 12:[03:04:05.123456]:kDebug:TestObj:test-tele.cpp:42:Test:message " "12\n", output.c_str()); } @@ -498,12 +494,13 @@ void test_IoStreamTrapLocationWithoutSeparatorUsesUnknownFile() { auto trap = IoStreamTrap{stream}; auto const tag = Tag{11, TestObj, "Test"}; - trap.OpenLogLine(tag); - trap.Location("test-tele.cpp", 42); - trap.CloseLogLine(tag); + auto log_collector = LambdaLogCollector{ + [&](ILogLine& log_line) { log_line.Location("test-tele.cpp", 42); }}; + + trap.LogLine(tag, log_collector); auto const output = stream.str(); - TEST_ASSERT_EQUAL_STRING(" 12:UNKNOWN FILE:42\n", output.c_str()); + TEST_ASSERT_EQUAL_STRING(" 12:UNKNOWN FILE:42\n", output.c_str()); } void test_EnvTele() { AE_TELE_ENV(); } } // namespace ae::tele::test_tele @@ -517,7 +514,8 @@ int main() { RUN_TEST(ae::tele::test_tele::test_TeleProxyTrap); RUN_TEST(ae::tele::test_tele::test_MergeStatisticsTrap); RUN_TEST(ae::tele::test_tele::test_IoStreamTrapFullOutput); - RUN_TEST(ae::tele::test_tele::test_IoStreamTrapLocationWithoutSeparatorUsesUnknownFile); + RUN_TEST(ae::tele::test_tele:: + test_IoStreamTrapLocationWithoutSeparatorUsesUnknownFile); RUN_TEST(ae::tele::test_tele::test_EnvTele); return UNITY_END(); From 5700156a029a9e6cada7f37606db83a734ae8a68 Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Tue, 21 Jul 2026 18:49:08 +0500 Subject: [PATCH 2/6] rewrite statistics_trap to store logs on ring buffer --- aether/ae_actions/telemetry.cpp | 12 +- aether/common.h | 7 - aether/tele/env/compilation_options.h | 76 +++--- aether/tele/env/compiler.h | 17 +- aether/tele/tele_init.cpp | 15 +- aether/tele/traps/statistics_trap.cpp | 217 +++++++--------- aether/tele/traps/statistics_trap.h | 243 +++++++++--------- aether/tele/traps/tele_statistics.cpp | 4 +- aether/tele/traps/tele_statistics.h | 10 +- tests/CMakeLists.txt | 1 - tests/test-tele-statistics/CMakeLists.txt | 32 --- .../test-tele-statistics.cpp | 160 ------------ tests/test-tele/test-tele.cpp | 105 ++++++-- 13 files changed, 373 insertions(+), 526 deletions(-) delete mode 100644 tests/test-tele-statistics/CMakeLists.txt delete mode 100644 tests/test-tele-statistics/test-tele-statistics.cpp diff --git a/aether/ae_actions/telemetry.cpp b/aether/ae_actions/telemetry.cpp index 3c7d0d35..22f0b531 100644 --- a/aether/ae_actions/telemetry.cpp +++ b/aether/ae_actions/telemetry.cpp @@ -18,8 +18,8 @@ #if defined TELEMETRY_ENABLED -# include "aether/aether.h" # include "aether-miscpp/format/format.h" +# include "aether/aether.h" # include "aether/tele/tele.h" # include "aether/tele/traps/tele_statistics.h" @@ -79,11 +79,9 @@ void Telemetry::OnRequestTelemetry(std::size_t server_priority) { std::optional Telemetry::CollectTelemetry( StreamInfo const& stream_info) { - auto& statistics_storage = - tele::TeleStatistics::ptr{ae_context_.aether().tele_statistics} - ->trap() - ->statistics_store; - auto& env_storage = statistics_storage.env_store(); + auto& statistics_trap = + *tele::TeleStatistics::ptr{ae_context_.aether().tele_statistics}->trap(); + auto const& env_storage = statistics_trap.env_store(); Telemetric res{}; res.cpp.utm_id = env_storage.utm_id; res.cpp.lib_version = env_storage.library_version; @@ -99,7 +97,7 @@ std::optional Telemetry::CollectTelemetry( auto vector_writer = LimitVectorWriter<>{res.cpp.blob, res.cpp.blob.capacity()}; auto os = omstream{vector_writer}; - os << statistics_storage; + os << statistics_trap; // TODO: should we reset stored statistics? return res; diff --git a/aether/common.h b/aether/common.h index 71557931..824080b0 100644 --- a/aether/common.h +++ b/aether/common.h @@ -31,13 +31,6 @@ namespace ae { #define AE_CAT(A, B) AE_CAT_(A, B) #define AE_UNIQUE_NAME(P) AE_CAT(P, AE_CAT(__LINE__, __COUNTER__)) -#define _AE_CONCAT_0(A, B, ...) A##B -#define _AE_CONCAT_1(A, ...) _AE_CONCAT_0(A##__VA_ARGS__) -#define _AE_CONCAT_2(A, ...) _AE_CONCAT_1(A##__VA_ARGS__) -#define _AE_CONCAT_3(A, ...) _AE_CONCAT_2(A##__VA_ARGS__) -#define _AE_CONCAT_N(_3, _2, _1, _0, X, ...) _AE_CONCAT##X(_3, _2, _1, _0) -#define AE_CONCAT(...) _AE_CONCAT_N(__VA_ARGS__, _2, _1, _0) - // remove () around X #define AE_DEPAREN(X) AE_ESC(AE_ISH X) #define AE_ISH(...) AE_ISH __VA_ARGS__ diff --git a/aether/tele/env/compilation_options.h b/aether/tele/env/compilation_options.h index 81e991b0..60961103 100644 --- a/aether/tele/env/compilation_options.h +++ b/aether/tele/env/compilation_options.h @@ -35,47 +35,47 @@ std::pair { std::string_view{#option}, std::string_view{VA_STR(option)}, } namespace ae { -template -constexpr auto str_to_ui64(char const (&str)[N]) { - std::uint64_t result = 0; - std::uint64_t base = 10; - std::size_t i = 0; +// template +// constexpr auto str_to_ui64(char const (&str)[N]) { +// std::uint64_t result = 0; +// std::uint64_t base = 10; +// std::size_t i = 0; - if constexpr (N > 2) { - if (N > 3 && str[0] == '0' && str[1] == 'x') { - base = 16; - i = 2; - } else if (str[0] == '0') { - base = 8; - i = 1; - } else if (str[0] == 'b') { - base = 2; - i = 1; - } - } +// if constexpr (N > 2) { +// if (N > 3 && str[0] == '0' && str[1] == 'x') { +// base = 16; +// i = 2; +// } else if (str[0] == '0') { +// base = 8; +// i = 1; +// } else if (str[0] == 'b') { +// base = 2; +// i = 1; +// } +// } - for (; i < N; ++i) { - if ((str[i] >= '0') && (str[i] <= '9')) { - result = result * base + static_cast(str[i] - '0'); - } - if ((base > 10) && (str[i] >= 'a') && (str[i] <= 'f')) { - result = result * base + static_cast(str[i] - 'a' + 10); - } - if ((base > 10) && (str[i] >= 'A') && (str[i] <= 'F')) { - result = result * base + static_cast(str[i] - 'A' + 10); - } - } - return result; -} +// for (; i < N; ++i) { +// if ((str[i] >= '0') && (str[i] <= '9')) { +// result = result * base + static_cast(str[i] - '0'); +// } +// if ((base > 10) && (str[i] >= 'a') && (str[i] <= 'f')) { +// result = result * base + static_cast(str[i] - 'a' + 10); +// } +// if ((base > 10) && (str[i] >= 'A') && (str[i] <= 'F')) { +// result = result * base + static_cast(str[i] - 'A' + 10); +// } +// } +// return result; +// } -// some tests -static_assert(str_to_ui64("0") == 0); -static_assert(str_to_ui64("1") == 1); -static_assert(str_to_ui64("112") == 112); -static_assert(str_to_ui64("0xffff") == 65535); -static_assert(str_to_ui64("0xAaCb") == 0xaacb); -static_assert(str_to_ui64("042") == 34); -static_assert(str_to_ui64("b110") == 6); +// // some tests +// static_assert(str_to_ui64("0") == 0); +// static_assert(str_to_ui64("1") == 1); +// static_assert(str_to_ui64("112") == 112); +// static_assert(str_to_ui64("0xffff") == 65535); +// static_assert(str_to_ui64("0xAaCb") == 0xaacb); +// static_assert(str_to_ui64("042") == 34); +// static_assert(str_to_ui64("b110") == 6); constexpr inline auto _compile_options_list = std::array{ _OPTION(AE_TASK_MAX_COUNT), diff --git a/aether/tele/env/compiler.h b/aether/tele/env/compiler.h index a43e3266..c434a915 100644 --- a/aether/tele/env/compiler.h +++ b/aether/tele/env/compiler.h @@ -17,7 +17,14 @@ #ifndef AETHER_TELE_ENV_COMPILER_H_ #define AETHER_TELE_ENV_COMPILER_H_ -#include "aether/common.h" +#define _STR(x) _QUOTE(x) + +#define _AE_CONCAT_0(A, B, ...) A##B +#define _AE_CONCAT_1(A, ...) _AE_CONCAT_0(A##__VA_ARGS__) +#define _AE_CONCAT_2(A, ...) _AE_CONCAT_1(A##__VA_ARGS__) +#define _AE_CONCAT_3(A, ...) _AE_CONCAT_2(A##__VA_ARGS__) +#define _AE_CONCAT_N(_3, _2, _1, _0, X, ...) _AE_CONCAT##X(_3, _2, _1, _0) +#define AETE_CONCAT(...) _AE_CONCAT_N(__VA_ARGS__, _2, _1, _0) #if defined __clang__ # if defined __MINGW32__ @@ -26,8 +33,8 @@ # define COMPILER "clang" # endif # define COMPILER_VERSION \ - STR(__clang_major__) \ - "." STR(__clang_minor__) "." STR(__clang_patchlevel__) + _STR(__clang_major__) \ + "." _STR(__clang_minor__) "." _STR(__clang_patchlevel__) # define COMPILER_VERSION_NUM \ AE_CONCAT(__clang_major__, __clang_minor__, __clang_patchlevel__) #elif defined __GNUC__ @@ -37,12 +44,12 @@ # define COMPILER "gcc" # endif # define COMPILER_VERSION \ - STR(__GNUC__) "." STR(__GNUC_MINOR__) "." STR(__GNUC_PATCHLEVEL__) + _STR(__GNUC__) "." _STR(__GNUC_MINOR__) "." _STR(__GNUC_PATCHLEVEL__) # define COMPILER_VERSION_NUM \ AE_CONCAT(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) #elif defined _MSC_VER # define COMPILER "msvc" -# define COMPILER_VERSION STR(_MSC_FULL_VER) +# define COMPILER_VERSION _STR(_MSC_FULL_VER) # define COMPILER_VERSION_NUM _MSC_FULL_VER #else # warning "unknown compiler" diff --git a/aether/tele/tele_init.cpp b/aether/tele/tele_init.cpp index 862dbf42..159d535f 100644 --- a/aether/tele/tele_init.cpp +++ b/aether/tele/tele_init.cpp @@ -29,15 +29,14 @@ static void TeleSinkInit() { # if AE_TELE_LOG_CONSOLE // create statistics and console traps and combine them into one by proxy trap auto console_trap = std::make_shared(std::cout); - auto statistics_trap = std::make_shared(); + auto statistics_trap = std::make_shared(); SelectedSink::Instance().SetTrap( - std::make_shared>( + std::make_shared>( std::move(console_trap), std::move(statistics_trap))); # else // use just statistics trap - SelectedSink::Instance().SetTrap( - std::make_shared()); + SelectedSink::Instance().SetTrap(std::make_shared()); # endif #endif } @@ -48,16 +47,16 @@ static void TeleSinkReInit( #if AE_TELE_ENABLED # if AE_TELE_LOG_CONSOLE // statistics trap + print logs to iostream - auto proxy_trap = std::static_pointer_cast< - ProxyTrap>( - SelectedSink::Instance().trap()); + auto proxy_trap = + std::static_pointer_cast>( + SelectedSink::Instance().trap()); auto new_tele_trap = tele_statistics->trap(); new_tele_trap->MergeStatistics(*proxy_trap->second); proxy_trap->second = new_tele_trap; SelectedSink::Instance().SetTrap(std::move(proxy_trap)); # else // just statistics trap - auto old_trap = std::static_pointer_cast( + auto old_trap = std::static_pointer_cast( SelectedSink::Instance().trap()); auto new_tele_trap = tele_statistics->trap(); new_tele_trap->MergeStatistics(*old_trap); diff --git a/aether/tele/traps/statistics_trap.cpp b/aether/tele/traps/statistics_trap.cpp index 16a7d925..fa947954 100644 --- a/aether/tele/traps/statistics_trap.cpp +++ b/aether/tele/traps/statistics_trap.cpp @@ -22,128 +22,87 @@ #include #include -#include "aether/mstream.h" -#include "aether/mstream_buffers.h" - namespace ae::tele::statistics { -RuntimeLog::RuntimeLog(SavedLog&& saved) : size{saved.data.size()} { - logs.push_back(std::move(std::move(saved).data)); -} - -void RuntimeLog::Append(RuntimeLog&& newer) { - size += newer.size; - logs.splice(std::end(logs), std::move(std::move(newer).logs)); -} - -StatisticsStore::StatisticsStore() - : logs_{MakeRcPtr(RuntimeLog{})} {}; -StatisticsStore::~StatisticsStore() = default; - -EnvStore& StatisticsStore::env_store() { return env_store_; } - -MetricsStore& StatisticsStore::metrics_store() { return metrics_store_; } - -RcPtr StatisticsStore::log_store() { - // current log must be a RuntimeLog - if (logs_->index() != 1) { - // in case current logs is not a RuntimeLog - logs_ = MakeRcPtr( - RuntimeLog{std::move(std::get(*logs_))}); - } - // make rotation - auto r_logs = std::get(*logs_); - if (r_logs.size >= statistics_size_limit_) { - prev_logs_ = std::move(logs_); - logs_ = MakeRcPtr(RuntimeLog{}); - } - - return logs_; -} - -void StatisticsStore::Merge(StatisticsStore const& newer) { - // just steal env_store_ - env_store_ = newer.env_store_; - - // merge logs - // logs_ always should be - assert(newer.logs_); - // access through log_store, to make rotation if needed - auto current = log_store(); - std::get(*current).Append( - std::move(std::get(*newer.logs_))); - - if (newer.prev_logs_) { - prev_logs_ = newer.prev_logs_; - } - - // merge metrics - for (auto const& [index, metric] : newer.metrics_store_.metrics) { - auto it = metrics_store_.metrics.find(index); - if (it == std::end(metrics_store_.metrics)) { - metrics_store_.metrics[index] = metric; - continue; - } - it->second.invocations_count += metric.invocations_count; - it->second.max_duration = - std::max(it->second.max_duration, metric.max_duration); - it->second.min_duration = - std::min(it->second.min_duration, metric.min_duration); - it->second.sum_duration += metric.sum_duration; +// print any integral to LogStorage +template + requires(std::is_integral_v) +ILogStorage& operator<<(ILogStorage& out, T v) { + out.Write(reinterpret_cast(&v), sizeof(T)); + return out; +} + +template +concept IndexSerializable = requires(ILogStorage& log_storage, T const t) { + { t.Serialize(log_storage) }; +}; + +template +concept IndexBuffSerializable = requires(std::uint8_t* buf, T const t) { + { t.Serialize(buf) } -> std::same_as; +}; + +template + requires(IndexSerializable || IndexBuffSerializable) +void WriteIndex(ILogStorage& log_storage, T const& v) { + if constexpr (IndexSerializable) { + v.Serialize(log_storage); + } else { + std::array buff; + auto s = v.Serialize(buff.data()); + log_storage.Write(buff.data(), s); } } -void StatisticsStore::SetSizeLimit(std::size_t limit) { - statistics_size_limit_ = static_cast(limit); -} - -StatisticsTrap::StatisticsTrap() = default; -StatisticsTrap::~StatisticsTrap() = default; - -StatisticsTrap::LogLineWriter::LogLineWriter(Tag const& tag, - RcPtr log, - std::vector& d) - : log_storage{std::move(log)}, vector_writer{d}, log_writer{vector_writer} { - log_writer << PackedIndex{tag.index()}; -} - -StatisticsTrap::LogLineWriter::~LogLineWriter() { - // update log size - std::get(*log_storage).size += vector_writer.data_.size(); +StatisticsTrapBasic::LogLineWriter::LogLineWriter(Tag const& tag, + ILogStorage& log_storage) + : log_storage_{log_storage} { + auto tag_index = MetricsStore::PackedIndex{tag.index()}; + WriteIndex(log_storage_, tag_index); } -void StatisticsTrap::LogLineWriter::InvokeTime(TimePoint time) { - log_writer << time; +void StatisticsTrapBasic::LogLineWriter::InvokeTime(TimePoint time) { + auto epoch_ms = static_cast( + std::chrono::duration_cast( + time.time_since_epoch()) + .count()); + log_storage_ << epoch_ms; } -void StatisticsTrap::LogLineWriter::WriteLevel(Level level) { - log_writer << level.value_; +void StatisticsTrapBasic::LogLineWriter::WriteLevel(Level level) { + log_storage_ << level.value_; } -void StatisticsTrap::LogLineWriter::WriteModule(Module const& module) { - log_writer << module.id; +void StatisticsTrapBasic::LogLineWriter::WriteModule(Module const& module) { + log_storage_ << module.id; } -void StatisticsTrap::LogLineWriter::Location(std::string_view file, - std::uint32_t line) { - log_writer << file << line; +void StatisticsTrapBasic::LogLineWriter::Location(std::string_view file, + std::uint32_t line) { + log_storage_.Write(reinterpret_cast(file.data()), + file.size()); + log_storage_ << line; } -void StatisticsTrap::LogLineWriter::TagName(std::string_view name) { - log_writer << name; +void StatisticsTrapBasic::LogLineWriter::TagName(std::string_view name) { + log_storage_.Write(reinterpret_cast(name.data()), + name.size()); } -void StatisticsTrap::LogLineWriter::Blob(std::span blob) { +void StatisticsTrapBasic::LogLineWriter::Blob( + std::span blob) { if (blob.empty()) { return; } - log_writer.write(static_cast(blob.data()), blob.size()); + log_storage_.Write(blob.data(), blob.size()); } -void StatisticsTrap::AddInvoke(Tag const& tag, std::uint32_t count) { +StatisticsTrapBasic::StatisticsTrapBasic() = default; +StatisticsTrapBasic::~StatisticsTrapBasic() = default; + +void StatisticsTrapBasic::AddInvoke(Tag const& tag, std::uint32_t count) { auto lock = std::scoped_lock(sync_lock_); - statistics_store.metrics_store().metrics[tag.index()].invocations_count += - count; + metrics_store_.metrics[tag.index()].invocations_count += count; } -void StatisticsTrap::AddInvokeDuration(Tag const& tag, Duration duration) { +void StatisticsTrapBasic::AddInvokeDuration(Tag const& tag, Duration duration) { auto lock = std::scoped_lock(sync_lock_); - auto& metr = statistics_store.metrics_store().metrics[tag.index()]; + auto& metr = metrics_store_.metrics[tag.index()]; metr.sum_duration += static_cast(duration.count()); metr.max_duration = std::max(static_cast(metr.max_duration), @@ -157,34 +116,44 @@ void StatisticsTrap::AddInvokeDuration(Tag const& tag, Duration duration) { } } -void StatisticsTrap::LogLine(Tag const& tag, ILogCollector& log_collector) { - auto lock = std::scoped_lock{sync_lock_}; - auto log_store = statistics_store.log_store(); - auto& runtime_log = std::get(*log_store); - auto& data = runtime_log.logs.emplace_back(); - - auto log_line = LogLineWriter{tag, log_store, data}; - log_collector.WriteLine(log_line); +void StatisticsTrapBasic::WriteEnvData(EnvData const& env_data) { + env_store_.platform = env_data.platform_type; + env_store_.compiler = env_data.compiler; + env_store_.compiler_version = env_data.compiler_version; + env_store_.library_version = env_data.library_version; + env_store_.api_version = env_data.api_version; + env_store_.cpu_arch = env_data.cpu_arch; + env_store_.endianness = static_cast(env_data.endianness); + env_store_.utm_id = env_data.utm_id; + for (auto const& opt : env_data.compile_options) { + env_store_.compile_options.emplace_back(EnvStore::PackedIndex{opt.index}, + std::string{opt.value}); + } } -void StatisticsTrap::WriteEnvData(EnvData const& env_data) { - auto& env_store = statistics_store.env_store(); - env_store.platform = env_data.platform_type; - env_store.compiler = env_data.compiler; - env_store.compiler_version = env_data.compiler_version; - env_store.library_version = env_data.library_version; - env_store.api_version = env_data.api_version; - env_store.cpu_arch = env_data.cpu_arch; - env_store.endianness = static_cast(env_data.endianness); - env_store.utm_id = env_data.utm_id; - for (auto const& opt : env_data.compile_options) { - env_store.compile_options.emplace_back(PackedIndex{opt.index}, - std::string{opt.value}); +void StatisticsTrapBasic::MergeStatistics(StatisticsTrapBasic const& newer) { + // just steal env_store_ + env_store_ = newer.env_store_; + + // merge metrics + for (auto const& [index, metric] : newer.metrics_store_.metrics) { + auto it = metrics_store_.metrics.find(index); + if (it == std::end(metrics_store_.metrics)) { + metrics_store_.metrics[index] = metric; + continue; + } + it->second.invocations_count += metric.invocations_count; + it->second.max_duration = + std::max(it->second.max_duration, metric.max_duration); + it->second.min_duration = + std::min(it->second.min_duration, metric.min_duration); + it->second.sum_duration += metric.sum_duration; } } -void StatisticsTrap::MergeStatistics(StatisticsTrap const& newer) { - statistics_store.Merge(newer.statistics_store); +EnvStore const& StatisticsTrapBasic::env_store() const { return env_store_; } +MetricsStore const& StatisticsTrapBasic::metrics_store() const { + return metrics_store_; } } // namespace ae::tele::statistics diff --git a/aether/tele/traps/statistics_trap.h b/aether/tele/traps/statistics_trap.h index 98783ce7..d1d66086 100644 --- a/aether/tele/traps/statistics_trap.h +++ b/aether/tele/traps/statistics_trap.h @@ -17,97 +17,35 @@ #ifndef AETHER_TELE_TRAPS_STATISTICS_TRAP_H_ #define AETHER_TELE_TRAPS_STATISTICS_TRAP_H_ -#include +#include +#include +#include +#include +#include #include #include #include #include -#include #include -#include - #include "aether-miscpp/reflect/reflect.h" -#include "aether/clock.h" -#include "aether/config.h" -#include "aether/mstream.h" -#include "aether/mstream_buffers.h" -#include "aether/ptr/rc_ptr.h" +#include "numeric/tiered_int.h" + #include "aether/tele/itrap.h" namespace ae::tele { namespace statistics { -/** - * \brief Storage for old saved logs - */ -struct SavedLog { - AE_REFLECT_MEMBERS(data) - - std::vector data; -}; - -/** - * \brief Stores serialized lines of logs in bunch of buffers - */ -struct RuntimeLog { - using log_entry = std::vector; - using list_type = std::list; - using size_type = list_type::size_type; - - RuntimeLog() = default; - explicit RuntimeLog(SavedLog&& saved); - void Append(RuntimeLog&& newer); - - std::size_t size{}; - list_type logs; -}; - -// Convert RuntimeLog to SavedLog and write -template -omstream& operator<<(omstream& stream, RuntimeLog const& log) { - auto saved = SavedLog{}; - saved.data.reserve(log.size); - for (auto const& e : log.logs) { - saved.data.insert(saved.data.end(), e.begin(), e.end()); - } - stream << saved; - return stream; -} - -/** - * \brief Storage for logs - */ -using LogStorage = std::variant; - -/** - * \brief Save and load LogStorage. - * It always saved as SavedLog. - */ -template -omstream& operator<<(omstream& stream, LogStorage const& log) { - // all variants saved as SavedLog - std::visit([&](auto const& v) { stream << v; }, log); - return stream; -} -template -imstream& operator>>(imstream& stream, LogStorage& log) { - // all variants saved as SavedLog - log = SavedLog{}; - stream >> std::get(log); - return stream; -} - /** * \brief Map of telemetry metrics. */ struct MetricsStore { using PackedIndex = TieredInt; - using PackedValue = TieredInt; + using PackedCount = TieredInt; struct Metric { - PackedValue invocations_count; - PackedValue max_duration; - PackedValue sum_duration; - PackedValue min_duration; + PackedCount invocations_count; + std::uint32_t max_duration; + std::uint32_t sum_duration; + std::uint32_t min_duration; AE_REFLECT_MEMBERS(invocations_count, max_duration, sum_duration, min_duration) @@ -141,56 +79,80 @@ struct EnvStore { api_version, cpu_arch, endianness, utm_id, compile_options) }; -/** - * \brief Storage for telemetry statistics with rotation - */ -class StatisticsStore { - static constexpr std::size_t kMaxSize = AE_STATISTICS_MAX_SIZE / 2; +class ILogStorage { + protected: + ~ILogStorage() = default; public: - StatisticsStore(); - ~StatisticsStore(); - - EnvStore& env_store(); - MetricsStore& metrics_store(); - RcPtr log_store(); + virtual void Write(std::uint8_t const* data, std::size_t size) = 0; +}; - /** - * \brief Merge storage into this - * \param[in] newer - another storage with newer data - */ - void Merge(StatisticsStore const& newer); +// LogStorage with circular buffer and fixed capacity +template +struct LogStorage final : public ILogStorage { + void Write(std::uint8_t const* data, std::size_t count) override { + count = std::min(count, LogCapacity - 1); + + if (count > LogCapacity - 1 - size()) { + auto overwrite = count - (LogCapacity - 1 - size()); + start = (start + overwrite) % LogCapacity; + } + + while (count > 0) { + auto n = (LogCapacity - pos) > count ? count : LogCapacity - pos; + std::memcpy(buffer.data() + pos, data, n); + pos = (pos + n) % LogCapacity; + data += n; + count -= n; + } + } - void SetSizeLimit(std::size_t limit); + std::size_t size() const { + if (pos >= start) { + return pos - start; + } + return LogCapacity - start + pos; + } - AE_REFLECT_MEMBERS(statistics_size_limit_, env_store_, metrics_store_, - prev_logs_, logs_) + // read from stream + template + friend TStream& operator>>(TStream& in, LogStorage& v) { + std::uint32_t size; // NOLINT(*init-variables) + in >> size; + assert(size < LogCapacity && "Saved buffer bigger than capacity"); + v.start = 0; + v.pos = static_cast(size); + in.read(v.buffer.data(), static_cast(size)); + + return in; + } - private: - bool IsCurrentFull() const; - void Rotate(); + // write to stream + template + friend TStream& operator<<(TStream& out, LogStorage const& v) { + auto size = v.size(); + out << static_cast(size); + auto s = v.start; + while (size > 0) { + auto to_write = (LogCapacity - s) > size ? size : LogCapacity - s; + out.write(v.buffer.data() + s, to_write); + s = (s + to_write) % LogCapacity; + size = size - to_write; + } + + return out; + } - std::uint32_t statistics_size_limit_{kMaxSize}; - EnvStore env_store_{}; - MetricsStore metrics_store_{}; - RcPtr prev_logs_; - RcPtr logs_; + std::size_t start{}; + std::size_t pos{}; + std::array buffer; }; -/** - * \brief Access to statistics storage through telemetry trap - */ -class StatisticsTrap final : public ITrap { +class StatisticsTrapBasic : public ITrap { public: - using PackedSize = TieredInt; - using PackedIndex = TieredInt; - using PackedLine = TieredInt; - class LogLineWriter final : public ILogLine { public: - LogLineWriter(Tag const& tag, RcPtr log, - std::vector& d); - ~LogLineWriter(); + LogLineWriter(Tag const& tag, ILogStorage& log_storage); void InvokeTime(TimePoint time) override; void WriteLevel(Level level) override; @@ -200,30 +162,67 @@ class StatisticsTrap final : public ITrap { void Blob(std::span blob) override; private: - RcPtr log_storage; - VectorWriter vector_writer; - omstream> log_writer; + ILogStorage& log_storage_; }; - StatisticsTrap(); - ~StatisticsTrap() override; + StatisticsTrapBasic(); + ~StatisticsTrapBasic() override; void AddInvoke(Tag const& tag, std::uint32_t count) override; void AddInvokeDuration(Tag const& tag, Duration duration) override; - void LogLine(Tag const& tag, ILogCollector& log_collector) override; + // LogLine implemented not here + void WriteEnvData(EnvData const& env_data) override; + void MergeStatistics(StatisticsTrapBasic const& newer); + + EnvStore const& env_store() const; + MetricsStore const& metrics_store() const; + + AE_REFLECT_MEMBERS(metrics_store_, env_store_) + + protected: + std::mutex sync_lock_; + MetricsStore metrics_store_{}; + EnvStore env_store_{}; +}; + +/** + * \brief Access to statistics storage through telemetry trap + */ +template +class StatisticsTrap final : public StatisticsTrapBasic { + public: + StatisticsTrap() = default; + + void LogLine(Tag const& tag, ILogCollector& log_collector) override { + auto lock = std::scoped_lock{sync_lock_}; + auto log_writer = StatisticsTrapBasic ::LogLineWriter{tag, log_storage_}; + log_collector.WriteLine(log_writer); + } + /** * \brief Merge newer statistics storage into this */ - void MergeStatistics(StatisticsTrap const& newer); + void MergeStatistics(StatisticsTrap const& newer) { + StatisticsTrapBasic::MergeStatistics(newer); + // write newer logs on top of current + auto size = newer.log_storage_.size(); + auto s = newer.log_storage_.start; + while (size > 0) { + auto to_write = (LogCapacity - s) > size ? size : LogCapacity - s; + log_storage_.Write(newer.log_storage_.buffer.data() + s, to_write); + s = (s + to_write) % LogCapacity; + size = size - to_write; + } + } - AE_REFLECT_MEMBERS(statistics_store) + LogStorage const& log_storage() const { return log_storage_; } - StatisticsStore statistics_store; + AE_REFLECT(AE_REF_BASE(StatisticsTrapBasic), AE_MMBRS(log_storage_)) private: - std::mutex sync_lock_; + LogStorage log_storage_; }; } // namespace statistics } // namespace ae::tele diff --git a/aether/tele/traps/tele_statistics.cpp b/aether/tele/traps/tele_statistics.cpp index f1b3a978..f9018e2f 100644 --- a/aether/tele/traps/tele_statistics.cpp +++ b/aether/tele/traps/tele_statistics.cpp @@ -22,8 +22,6 @@ TeleStatistics::TeleStatistics(ObjProp prop) : Obj{prop} {} #endif #if AE_TELE_ENABLED -std::shared_ptr const& TeleStatistics::trap() { - return trap_; -} +auto TeleStatistics::trap() -> std::shared_ptr const& { return trap_; } #endif } // namespace ae::tele diff --git a/aether/tele/traps/tele_statistics.h b/aether/tele/traps/tele_statistics.h index e449f00a..eb132fdf 100644 --- a/aether/tele/traps/tele_statistics.h +++ b/aether/tele/traps/tele_statistics.h @@ -17,9 +17,10 @@ #ifndef AETHER_TELE_TRAPS_TELE_STATISTICS_H_ #define AETHER_TELE_TRAPS_TELE_STATISTICS_H_ +#include "aether-miscpp/reflect/reflect.h" +#include "aether/config.h" #include "aether/obj/obj.h" #include "aether/ptr/rc_ptr.h" -#include "aether-miscpp/reflect/reflect.h" #include "aether/tele/tele.h" #include "aether/tele/traps/statistics_trap.h" @@ -31,6 +32,8 @@ class TeleStatistics : public Obj { TeleStatistics() = default; public: + using Trap = statistics::StatisticsTrap; + #ifdef AE_DISTILLATION explicit TeleStatistics(ObjProp prop); #endif // AE_DISTILLATION @@ -51,11 +54,10 @@ class TeleStatistics : public Obj { #endif #if AE_TELE_ENABLED - std::shared_ptr const& trap(); + std::shared_ptr const& trap(); private: - std::shared_ptr trap_ = - std::make_shared(); + std::shared_ptr trap_ = std::make_shared(); #endif }; } // namespace ae::tele diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 21fae1e6..f9307dc5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -32,7 +32,6 @@ generate_inline_tests(${CMAKE_CURRENT_LIST_DIR}/../aether aether) #tests add_subdirectory(test-tele) -add_subdirectory(test-tele-statistics) add_subdirectory(test-types) add_subdirectory(test-object-system) add_subdirectory(test-api-protocol) diff --git a/tests/test-tele-statistics/CMakeLists.txt b/tests/test-tele-statistics/CMakeLists.txt deleted file mode 100644 index a500fd94..00000000 --- a/tests/test-tele-statistics/CMakeLists.txt +++ /dev/null @@ -1,32 +0,0 @@ -# Copyright 2024 Aethernet Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -cmake_minimum_required( VERSION 3.16 ) - -list(APPEND test_srcs - test-tele-statistics.cpp -) - -if(NOT CM_PLATFORM) - - project(test-tele-statistics LANGUAGES CXX) - - add_executable(${PROJECT_NAME}) - target_sources(${PROJECT_NAME} PRIVATE ${test_srcs}) - target_link_libraries(${PROJECT_NAME} PRIVATE aether unity) - - add_test(NAME ${PROJECT_NAME} COMMAND $) -else() - message(WARNING "Not implemented for ${CM_PLATFORM}") -endif() diff --git a/tests/test-tele-statistics/test-tele-statistics.cpp b/tests/test-tele-statistics/test-tele-statistics.cpp deleted file mode 100644 index c444af90..00000000 --- a/tests/test-tele-statistics/test-tele-statistics.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * Copyright 2024 Aethernet Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include - -#include "aether/config.h" - -#if defined AE_DISTILLATION && (AE_TELE_ENABLED == 1) - -# include "aether/common.h" -# include "aether/tele/tele.h" -# include "aether/tele/sink.h" -# include "aether/ptr/rc_ptr.h" -# include "aether/tele/traps/statistics_trap.h" - -# include "aether/tele/traps/tele_statistics.h" -# include "aether/domain_storage/ram_domain_storage.h" - -static std::shared_ptr statistics_trap; - -void InitTeleSink( - std::shared_ptr const& st) { - TELE_SINK::Instance().SetTrap(st); - - AE_TELED_DEBUG("Tele sink initialized"); -} - -void setUp() { - statistics_trap = std::make_shared(); - InitTeleSink(statistics_trap); -} - -void tearDown() {} - -namespace ae::tele::test { - -void test_StatisticsRotation() { - auto ram_ds = RamDomainStorage{}; - ram_ds.CleanUp(); - auto domain = ae::Domain{ae::Now(), ram_ds}; - - TeleStatistics::ptr tele_statistics = - TeleStatistics::ptr::Create(CreateWith{domain}.with_id(1)); - tele_statistics->trap()->MergeStatistics(*statistics_trap); - // set 100 byte - tele_statistics->trap()->statistics_store.SetSizeLimit(100); - - InitTeleSink(tele_statistics->trap()); - { - AE_TELED_DEBUG("12"); - } - auto statistics_size = - std::get( - *tele_statistics->trap()->statistics_store.log_store()) - .size; - TEST_ASSERT_LESS_THAN(100, statistics_size); - tele_statistics->trap()->statistics_store.SetSizeLimit(1); - // rotation happened - auto zero_size = std::get( - *tele_statistics->trap()->statistics_store.log_store()) - .size; - TEST_ASSERT_EQUAL(0, zero_size); -} - -void test_SaveLoadTeleStatistics() { - auto ram_ds = RamDomainStorage{}; - ram_ds.CleanUp(); - auto domain = ae::Domain{ae::Now(), ram_ds}; - - AE_TELE_ENV(); - - TeleStatistics::ptr tele_statistics = - TeleStatistics::ptr::Create(CreateWith{domain}.with_id(1)); - tele_statistics->trap()->MergeStatistics(*statistics_trap); - InitTeleSink(tele_statistics->trap()); - { - AE_TELED_DEBUG("12"); - } - auto statistics_size = - std::get( - *tele_statistics->trap()->statistics_store.log_store()) - .size; - - // use new trap to prevent statistics change while save - auto temp_trap = std::make_shared(); - InitTeleSink(temp_trap); - tele_statistics.Save(); - - // load stored object in new instance - auto domain2 = ae::Domain{ae::Now(), ram_ds}; - auto tele_statistics2 = - TeleStatistics::ptr::Declare(CreateWith{domain2}.with_id(1)); - tele_statistics2.Load(); - TEST_ASSERT(static_cast(tele_statistics2)); - - auto statistics_size2 = - std::get( - *tele_statistics2->trap()->statistics_store.log_store()) - .size; - TEST_ASSERT_EQUAL(statistics_size, statistics_size2); - - auto& metrics1 = - tele_statistics->trap()->statistics_store.metrics_store().metrics; - auto& metrics2 = - tele_statistics2->trap()->statistics_store.metrics_store().metrics; - TEST_ASSERT_EQUAL(metrics1.size(), metrics2.size()); - - // simple check with _AE_MODULE_CONFIG leads here to AST broken error for - // cppcheck - constexpr bool all_and_not_excluded_duration = - IsAll(AE_TELE_METRICS_DURATION) && - !IsEnabled(AE_TELE_METRICS_DURATION_EXCLUDE); - - constexpr bool duration_enabled = - all_and_not_excluded_duration || - IsEnabled(AE_TELE_METRICS_DURATION); - - constexpr bool all_and_not_excluded_metrics = - (IsAll(AE_TELE_METRICS_MODULES) && - !IsEnabled(AE_TELE_METRICS_MODULES_EXCLUDE)); - - constexpr bool metrics_enabled = all_and_not_excluded_metrics || - IsEnabled(AE_TELE_METRICS_MODULES); - - if constexpr (duration_enabled && metrics_enabled) { - auto log_index = kLog.offset; - TEST_ASSERT_EQUAL(metrics1[log_index].invocations_count, - metrics2[log_index].invocations_count); - TEST_ASSERT_EQUAL(metrics1[log_index].sum_duration, - metrics2[log_index].sum_duration); - } -} -} // namespace ae::tele::test -#else -void setUp() {} -void tearDown() {} -#endif - -int main() { - UNITY_BEGIN(); -#if defined AE_DISTILLATION && (AE_TELE_ENABLED == 1) && \ - (AE_TELE_LOG_CONSOLE == 1) - RUN_TEST(ae::tele::test::test_StatisticsRotation); - RUN_TEST(ae::tele::test::test_SaveLoadTeleStatistics); -#endif - return UNITY_END(); -} diff --git a/tests/test-tele/test-tele.cpp b/tests/test-tele/test-tele.cpp index 94942373..90ff41dc 100644 --- a/tests/test-tele/test-tele.cpp +++ b/tests/test-tele/test-tele.cpp @@ -26,6 +26,8 @@ #include #include +#include "aether-miscpp/meta/arg_at.h" + #include "aether/config.h" // force to enable telemetry for this test @@ -386,7 +388,8 @@ void test_MergeStatisticsTrap() { false, false, false, false>>; #undef TELE_SINK #define TELE_SINK Sink - auto statistics_trap1 = std::make_shared(); + using Trap = statistics::StatisticsTrap<1024>; + auto statistics_trap1 = std::make_shared(); Sink::Instance().SetTrap(statistics_trap1); { @@ -398,26 +401,19 @@ void test_MergeStatisticsTrap() { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } - auto logs1 = std::get( - *statistics_trap1->statistics_store.log_store()) - .logs; + auto const& logs1 = statistics_trap1->log_storage(); - auto statistics_trap2 = std::make_shared(); + auto statistics_trap2 = std::make_shared(); statistics_trap2->MergeStatistics(*statistics_trap1); - auto& logs2 = std::get( - *statistics_trap2->statistics_store.log_store()) - .logs; + auto const& logs2 = statistics_trap2->log_storage(); TEST_ASSERT_EQUAL(logs1.size(), logs2.size()); - auto it1 = std::begin(logs1); - auto it2 = std::begin(logs2); - for (; it1 != std::end(logs1); ++it1, ++it2) { - TEST_ASSERT_EQUAL_CHAR_ARRAY(it1->data(), it2->data(), it1->size()); - } + TEST_ASSERT_EQUAL_CHAR_ARRAY(logs1.buffer.data(), logs2.buffer.data(), + logs2.buffer.size()); - auto& metrics1 = statistics_trap1->statistics_store.metrics_store().metrics; - auto& metrics2 = statistics_trap2->statistics_store.metrics_store().metrics; + auto const& metrics1 = statistics_trap1->metrics_store().metrics; + auto const& metrics2 = statistics_trap2->metrics_store().metrics; TEST_ASSERT_EQUAL(metrics1.size(), metrics2.size()); auto mit1 = std::begin(metrics1); @@ -455,6 +451,80 @@ void test_MergeStatisticsTrap() { #define TELE_SINK SinkType } +void test_StatisticsRotation() { + using Trap = ae::tele::statistics::StatisticsTrap<1024>; + + auto ts = std::make_shared(); + SinkType::Instance().SetTrap(ts); + // check if ts is empty + TEST_ASSERT_EQUAL(0, ts->log_storage().size()); + // add some logs + { + AE_TELE_DEBUG(Test1, "12"); + } + // something was added + TEST_ASSERT_GREATER_THAN(0, ts->log_storage().size()); + + // write too many + std::array garbage{}; + { + AE_TELE_DEBUG(Test1, "13 {}", garbage); + } + TEST_ASSERT_EQUAL(1023, ts->log_storage().size()); +} + +void test_SaveLoadTeleStatistics() { + using Trap = ae::tele::statistics::StatisticsTrap<1024>; + + auto ts_0 = std::make_shared(); + auto ts_1 = std::make_shared(); + + // first set ts_0 and write some logs + SinkType::Instance().SetTrap(ts_0); + { + AE_TELE_DEBUG(Test1, "12"); + } + auto size_before = ts_0->log_storage().size(); + + // merge 1 and 0 + ts_1->MergeStatistics(*ts_0); + auto size_after_merge = ts_1->log_storage().size(); + TEST_ASSERT_EQUAL(size_before, size_after_merge); + + auto const& metrics1 = ts_0->metrics_store().metrics; + auto const& metrics2 = ts_1->metrics_store().metrics; + TEST_ASSERT_EQUAL(metrics1.size(), metrics2.size()); + + auto log_index = ae::tele::statistics::MetricsStore::PackedIndex{ + TestObj.index_start + Test1.offset}; + // simple check with _AE_MODULE_CONFIG leads here to AST broken error for + // cppcheck + constexpr bool time_metrics_enabled = + TELE_SINK::ConfigProviderType::StaticTeleConfig::kTimeMetrics; + if constexpr (time_metrics_enabled) { + TEST_ASSERT_EQUAL(metrics1.at(log_index).sum_duration, + metrics2.at(log_index).sum_duration); + } + + constexpr bool count_metrics_enabled = + TELE_SINK::ConfigProviderType::StaticTeleConfig::kCountMetrics; + + if constexpr (count_metrics_enabled) { + TEST_ASSERT_EQUAL(metrics1.at(log_index).invocations_count, + metrics2.at(log_index).invocations_count); + } + + SinkType::Instance().SetTrap(ts_1); + { + AE_TELE_DEBUG(Test1, "13"); + } + + // check if new log added + TEST_ASSERT_GREATER_THAN(size_before, ts_1->log_storage().size()); +} + template struct LambdaLogCollector final : public ILogCollector { explicit LambdaLogCollector(WriteFn&& wf) : write_fn{std::move(wf)} {} @@ -503,6 +573,7 @@ void test_IoStreamTrapLocationWithoutSeparatorUsesUnknownFile() { TEST_ASSERT_EQUAL_STRING(" 12:UNKNOWN FILE:42\n", output.c_str()); } void test_EnvTele() { AE_TELE_ENV(); } + } // namespace ae::tele::test_tele int main() { @@ -513,10 +584,14 @@ int main() { RUN_TEST(ae::tele::test_tele::test_TeleConfigurations); RUN_TEST(ae::tele::test_tele::test_TeleProxyTrap); RUN_TEST(ae::tele::test_tele::test_MergeStatisticsTrap); + RUN_TEST(ae::tele::test_tele::test_StatisticsRotation); + RUN_TEST(ae::tele::test_tele::test_SaveLoadTeleStatistics); RUN_TEST(ae::tele::test_tele::test_IoStreamTrapFullOutput); RUN_TEST(ae::tele::test_tele:: test_IoStreamTrapLocationWithoutSeparatorUsesUnknownFile); RUN_TEST(ae::tele::test_tele::test_EnvTele); + RUN_TEST(ae::tele::test_tele::test_EnvTele); + RUN_TEST(ae::tele::test_tele::test_EnvTele); return UNITY_END(); } From 192253545282ff861e4e1ed6d307f62ad9014db2 Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Thu, 23 Jul 2026 10:02:27 +0500 Subject: [PATCH 3/6] remove common.h/concepts --- aether/common.h | 11 ----------- aether/events/event_handler.h | 9 ++++----- aether/events/event_list.h | 12 ++++++------ aether/obj/obj_ptr.h | 13 +++++++------ aether/types/statistic_counter.h | 16 ++++++++-------- 5 files changed, 25 insertions(+), 36 deletions(-) diff --git a/aether/common.h b/aether/common.h index 824080b0..4a6b0e9e 100644 --- a/aether/common.h +++ b/aether/common.h @@ -76,15 +76,4 @@ enum class CompressionMethod : std::uint8_t { #define AE_CLASS_NO_COPY_MOVE(class_name) \ AE_CLASS_COPY_(class_name, delete) \ AE_CLASS_MOVE_(class_name, delete) - -// concepts -#define AE_REQUIRERS(Condition) \ - std::enable_if_t = 0 - -#define AE_REQUIRERS_NOT(Condition) \ - std::enable_if_t = 0 - -#define AE_REQUIRERS_BOOL(Condition) \ - std::enable_if_t = 0 - #endif // AETHER_COMMON_H_ diff --git a/aether/events/event_handler.h b/aether/events/event_handler.h index 5c0c52cc..5e1f12b6 100644 --- a/aether/events/event_handler.h +++ b/aether/events/event_handler.h @@ -19,9 +19,9 @@ #include -#include "aether/config.h" -#include "aether/common.h" #include "aether-miscpp/types/small_function.h" +#include "aether/common.h" +#include "aether/config.h" namespace ae { @@ -39,9 +39,8 @@ class EventHandler final { public: using Fun = SmallFunction; - template < - typename TFunc, - AE_REQUIRERS_NOT((std::is_same, TFunc>))> + template + requires(!std::is_same_v, TFunc>) constexpr explicit EventHandler(TFunc&& func) : callback_{std::forward(func)} {} diff --git a/aether/events/event_list.h b/aether/events/event_list.h index f8899972..a67e997d 100644 --- a/aether/events/event_list.h +++ b/aether/events/event_list.h @@ -17,14 +17,14 @@ #ifndef AETHER_EVENTS_EVENT_LIST_H_ #define AETHER_EVENTS_EVENT_LIST_H_ -#include -#include +#include #include #include -#include +#include +#include -#include "aether/events/event_handler.h" #include "aether-miscpp/types/aligned_storage.h" +#include "aether/events/event_handler.h" namespace ae { class EventHandlersList { @@ -34,8 +34,8 @@ class EventHandlersList { static constexpr std::size_t kElementAlign = alignof(TemplateHandler); using ValueType = ManagedStorage; struct StoreType { - template >))> + template + requires(!std::is_same_v>) explicit StoreType(U&& value) : value{std::forward(value)} {} ValueType value; diff --git a/aether/obj/obj_ptr.h b/aether/obj/obj_ptr.h index 82cc6f9b..396435ab 100644 --- a/aether/obj/obj_ptr.h +++ b/aether/obj/obj_ptr.h @@ -17,17 +17,17 @@ #ifndef AETHER_OBJ_OBJ_PTR_H_ #define AETHER_OBJ_OBJ_PTR_H_ -#include #include #include #include +#include -#include "aether/ptr/ptr.h" -#include "aether/obj/obj_id.h" +#include "aether-miscpp/reflect/domain_visitor.h" // IWYU pragma: keep #include "aether/obj/domain.h" -#include "aether/obj/registry.h" +#include "aether/obj/obj_id.h" #include "aether/obj/obj_ptr_base.h" -#include "aether-miscpp/reflect/domain_visitor.h" // IWYU pragma: keep +#include "aether/obj/registry.h" +#include "aether/ptr/ptr.h" namespace ae { @@ -109,7 +109,8 @@ class ObjPtr : public ObjectPtrBase { ObjPtr(ObjPtr const& ptr) noexcept = default; ObjPtr(ObjPtr&& ptr) noexcept = default; - template ))> + template + requires(IsAbleToCast::value) ObjPtr(ObjPtr ptr) noexcept : ObjectPtrBase{static_cast(ptr)}, ptr_{std::move(ptr.ptr_)} {} diff --git a/aether/types/statistic_counter.h b/aether/types/statistic_counter.h index a223d9ea..29434b3a 100644 --- a/aether/types/statistic_counter.h +++ b/aether/types/statistic_counter.h @@ -17,10 +17,10 @@ #ifndef AETHER_TYPES_STATISTIC_COUNTER_H_ #define AETHER_TYPES_STATISTIC_COUNTER_H_ +#include +#include #include #include -#include -#include #include #include "aether/warning_disable.h" @@ -30,9 +30,9 @@ IGNORE_IMPLICIT_CONVERSION() #include DISABLE_WARNING_POP() +#include "aether-miscpp/format/format.h" #include "aether/common.h" #include "aether/mstream.h" -#include "aether-miscpp/format/format.h" namespace ae { template ())>>))> + template + requires(std::is_same_v())>>) void Insert(TIterator const& begin, TIterator const& end) { value_buffer_.push(begin, end); } - template >))> + template + requires(std::is_same_v>) void Add(U&& value) { value_buffer_.push(std::forward(value)); } From 8db14ad927b3aa33afc47f115fb1f4c938ee16a7 Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Thu, 23 Jul 2026 10:59:45 +0500 Subject: [PATCH 4/6] split tele env from project env --- aether/access_points/modem_access_point.cpp | 6 +- aether/access_points/wifi_access_point.cpp | 15 +- aether/adapters/adapter_tele.h | 2 +- aether/adapters/wifi_adapter.cpp | 6 +- aether/ae_actions/ae_actions_tele.h | 2 +- aether/ae_actions/telemetry.cpp | 2 +- aether/aether_app.cpp | 5 +- aether/aether_tele.h | 104 ++++++++++++- aether/all.h | 76 ++++----- aether/api_protocol/api_class_impl.h | 2 +- aether/api_protocol/protocol_context.cpp | 2 +- aether/channels/ethernet_channel.cpp | 2 +- aether/channels/wifi_channel.cpp | 2 +- aether/client_messages/client_messages_tele.h | 2 +- .../cloud_connections_tele.h | 2 +- .../cloud_server_connections.cpp | 4 +- .../client_cloud_manager.cpp | 6 +- .../connection_manager/get_cloud_aether.cpp | 6 +- .../hydrogen/hydro_sync_crypto_provider.cpp | 10 +- .../sodium/sodium_sync_crypto_provider.cpp | 2 +- aether/dns/dns_tele.h | 2 +- aether/domain_storage/domain_storage_tele.h | 2 +- .../registrar_domain_storage.cpp | 2 +- aether/domain_storage/static_domain_storage.h | 4 +- aether/lora_modules/lora_modules_tele.h | 2 +- aether/modems/modems_tele.h | 2 +- aether/obj/obj_tele.h | 2 +- aether/poller/poller_tele.h | 2 +- .../root_server_select_stream.cpp | 2 +- .../details/safe_stream_recv_action.h | 2 +- .../details/safe_stream_send_action.h | 12 +- aether/safe_stream/safe_stream.h | 10 +- aether/serial_ports/at_support/at_buffer.cpp | 2 +- aether/serial_ports/serial_ports_tele.h | 2 +- .../server_connections/channel_connection.cpp | 2 +- .../client_server_connection.cpp | 8 +- .../server_connections/server_connection.cpp | 2 +- aether/socket_initializer.cpp | 2 +- aether/tele.h | 31 ++++ aether/tele/collectors.h | 5 +- aether/tele/configs/all_enabled.h | 45 ++++++ aether/tele/configs/config_provider.h | 145 ------------------ aether/tele/defines.h | 50 +++--- aether/tele/env/compiler.h | 27 ++-- aether/tele/env_collectors.h | 82 ++-------- aether/tele/itrap.h | 1 - aether/tele/sink.h | 9 +- aether/tele/tele.h | 12 +- aether/tele/tele_init.h | 2 +- aether/tele/traps/io_stream_traps.cpp | 17 +- aether/tele/traps/statistics_trap.cpp | 1 - aether/tele/traps/statistics_trap.h | 3 +- aether/tele/traps/tele_statistics.h | 2 +- ...ation_options.h => tele_compile_options.h} | 73 +++------ .../sockets/lwip_cb_tcp_socket.cpp | 2 +- .../sockets/lwip_cb_udp_socket.cpp | 2 +- .../system_sockets/sockets/lwip_socket.cpp | 2 +- .../sockets/lwip_tcp_socket.cpp | 2 +- .../sockets/lwip_udp_socket.cpp | 2 +- .../system_sockets/sockets/unix_socket.cpp | 10 +- .../sockets/unix_tcp_socket.cpp | 10 +- .../sockets/unix_udp_socket.cpp | 10 +- .../system_sockets/sockets/win_tcp_socket.cpp | 4 +- .../system_sockets/sockets/win_udp_socket.cpp | 2 +- aether/transport/transport_tele.h | 2 +- .../client_api/client_api_safe.cpp | 2 +- .../client_api/client_api_unsafe.cpp | 2 +- .../work_server_api/login_api.cpp | 2 +- aether/write_action/buffer_write.h | 2 +- .../benches/send_message_delays/receiver.cpp | 2 +- .../send_message_delays_manager.cpp | 2 +- .../benches/send_message_delays/sender.cpp | 10 +- .../send_message_delays/timed_receiver.cpp | 2 +- .../send_message_delays/timed_sender.cpp | 2 +- .../common/test_action.h | 8 +- .../receiver/message_receiver.cpp | 2 +- .../receiver/receiver.cpp | 4 +- .../receiver/receiver_main.cpp | 4 +- .../sender/message_sender.cpp | 2 +- .../send_messages_bandwidth/sender/sender.cpp | 7 +- .../sender/sender_main.cpp | 4 +- examples/cloud/main.cpp | 2 +- tests/test-safe-stream/mock_bad_streams.cpp | 2 +- .../test_safe_stream_reliability.cpp | 6 +- tests/test-tele/test-tele.cpp | 59 +++---- .../libsodium_unit_tests.cpp | 6 +- .../libsodium_ut_aead_aegis128l.cpp | 8 +- .../libsodium_ut_aead_aegis256.cpp | 4 +- .../libsodium_ut_aead_aes256gcm.cpp | 6 +- .../libsodium_ut_aead_aes256gcm2.cpp | 4 +- .../libsodium_ut_aead_chacha20poly1305.cpp | 4 +- .../libsodium_ut_aead_chacha20poly13052.cpp | 4 +- .../libsodium_ut_aead_xchacha20poly1305.cpp | 4 +- .../libsodium_ut_auth.cpp | 4 +- .../libsodium_ut_auth2.cpp | 4 +- .../libsodium_ut_auth3.cpp | 6 +- .../libsodium_ut_auth5.cpp | 4 +- .../libsodium_ut_auth6.cpp | 6 +- .../libsodium_ut_auth7.cpp | 4 +- .../libsodium_unit_tests/libsodium_ut_box.cpp | 4 +- .../libsodium_ut_box2.cpp | 4 +- .../libsodium_ut_box7.cpp | 6 +- .../libsodium_ut_box8.cpp | 6 +- .../libsodium_ut_box_easy.cpp | 4 +- .../libsodium_ut_box_easy2.cpp | 4 +- .../libsodium_ut_box_seal.cpp | 4 +- .../libsodium_ut_box_seed.cpp | 4 +- .../libsodium_ut_chacha20.cpp | 8 +- .../libsodium_ut_codecs.cpp | 10 +- .../libsodium_ut_core1.cpp | 6 +- .../libsodium_ut_core2.cpp | 6 +- .../libsodium_ut_core3.cpp | 6 +- .../libsodium_ut_core4.cpp | 6 +- .../libsodium_ut_core5.cpp | 6 +- .../libsodium_ut_core6.cpp | 8 +- .../libsodium_ut_core_ed25519.cpp | 8 +- .../libsodium_ut_core_ed25519_h2c.cpp | 8 +- .../libsodium_ut_core_ristretto255.cpp | 6 +- .../libsodium_ut_ed25519_convert.cpp | 6 +- .../libsodium_ut_generichash.cpp | 6 +- .../libsodium_ut_generichash2.cpp | 6 +- .../libsodium_ut_generichash3.cpp | 6 +- .../libsodium_ut_hash.cpp | 6 +- .../libsodium_ut_hash3.cpp | 6 +- .../libsodium_unit_tests/libsodium_ut_kdf.cpp | 6 +- .../libsodium_ut_kdf_hkdf.cpp | 6 +- .../libsodium_ut_keygen.cpp | 6 +- .../libsodium_unit_tests/libsodium_ut_kx.cpp | 8 +- .../libsodium_ut_metamorphic.cpp | 8 +- .../libsodium_ut_misuse.cpp | 9 +- .../libsodium_ut_onetimeauth.cpp | 6 +- .../libsodium_ut_onetimeauth2.cpp | 6 +- .../libsodium_ut_onetimeauth7.cpp | 6 +- .../libsodium_ut_pwhash_argon2i.cpp | 6 +- .../libsodium_ut_pwhash_argon2id.cpp | 6 +- .../libsodium_ut_pwhash_scrypt.cpp | 6 +- .../libsodium_ut_pwhash_scrypt_ll.cpp | 6 +- .../libsodium_ut_randombytes.cpp | 6 +- .../libsodium_ut_scalarmult.cpp | 6 +- .../libsodium_ut_scalarmult2.cpp | 6 +- .../libsodium_ut_scalarmult5.cpp | 6 +- .../libsodium_ut_scalarmult6.cpp | 6 +- .../libsodium_ut_scalarmult7.cpp | 6 +- .../libsodium_ut_scalarmult8.cpp | 6 +- .../libsodium_ut_scalarmult_ed25519.cpp | 6 +- .../libsodium_ut_scalarmult_ristretto255.cpp | 6 +- .../libsodium_ut_secretbox.cpp | 6 +- .../libsodium_ut_secretbox2.cpp | 6 +- .../libsodium_ut_secretbox7.cpp | 6 +- .../libsodium_ut_secretbox8.cpp | 6 +- .../libsodium_ut_secretbox_easy.cpp | 8 +- .../libsodium_ut_secretbox_easy2.cpp | 6 +- ...dium_ut_secretstream_xchacha20poly1305.cpp | 6 +- .../libsodium_ut_shorthash.cpp | 6 +- .../libsodium_ut_sign.cpp | 8 +- .../libsodium_ut_sign2.cpp | 6 +- .../libsodium_ut_siphashx24.cpp | 6 +- .../libsodium_ut_sodium_utils.cpp | 6 +- .../libsodium_ut_sodium_utils2.cpp | 6 +- .../libsodium_ut_sodium_utils3.cpp | 6 +- .../libsodium_ut_sodium_version.cpp | 6 +- .../libsodium_ut_stream.cpp | 6 +- .../libsodium_ut_stream2.cpp | 6 +- .../libsodium_ut_stream3.cpp | 6 +- .../libsodium_ut_stream4.cpp | 6 +- .../libsodium_ut_verify1.cpp | 6 +- .../libsodium_ut_xchacha20.cpp | 6 +- 167 files changed, 709 insertions(+), 777 deletions(-) create mode 100644 aether/tele.h create mode 100644 aether/tele/configs/all_enabled.h delete mode 100644 aether/tele/configs/config_provider.h rename aether/{tele/env/compilation_options.h => tele_compile_options.h} (73%) diff --git a/aether/access_points/modem_access_point.cpp b/aether/access_points/modem_access_point.cpp index 6cb1dd48..e5bead1f 100644 --- a/aether/access_points/modem_access_point.cpp +++ b/aether/access_points/modem_access_point.cpp @@ -18,13 +18,13 @@ #if AE_SUPPORT_MODEMS # include "aether/aether.h" -# include "aether/server.h" # include "aether/modems/imodem_driver.h" +# include "aether/server.h" -# include "aether/channels/modem_channel.h" # include "aether/access_points/filter_endpoints.h" +# include "aether/channels/modem_channel.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { ModemConnectAction::ModemConnectAction(AeContext const& ae_context, diff --git a/aether/access_points/wifi_access_point.cpp b/aether/access_points/wifi_access_point.cpp index 38f4a32e..b791504f 100644 --- a/aether/access_points/wifi_access_point.cpp +++ b/aether/access_points/wifi_access_point.cpp @@ -19,15 +19,15 @@ #if AE_SUPPORT_WIFIS # include -# include "aether/aether.h" -# include "aether/server.h" -# include "aether/poller/poller.h" -# include "aether/dns/dns_resolve.h" +# include "aether/access_points/filter_endpoints.h" # include "aether/adapters/wifi_adapter.h" +# include "aether/aether.h" # include "aether/channels/wifi_channel.h" -# include "aether/access_points/filter_endpoints.h" +# include "aether/dns/dns_resolve.h" +# include "aether/poller/poller.h" +# include "aether/server.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { @@ -53,7 +53,8 @@ WifiConnectAction::connection_event() { void WifiConnectAction::EnsureConnected() { auto connected_to = driver_->connected_to(); - AE_TELED_DEBUG("Driver connected to {}", connected_to.value_or("NOT CONNECTED")); + AE_TELED_DEBUG("Driver connected to {}", + connected_to.value_or("NOT CONNECTED")); // if already connected if (connected_to && (*connected_to == wifi_ap_.creds.ssid)) { SetConnected(true); diff --git a/aether/adapters/adapter_tele.h b/aether/adapters/adapter_tele.h index 9cc707b8..cc3eb111 100644 --- a/aether/adapters/adapter_tele.h +++ b/aether/adapters/adapter_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_ADAPTERS_ADAPTER_TELE_H_ #define AETHER_ADAPTERS_ADAPTER_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kAdapter, 5, 101, 121); AE_TAG(kEthernetAdapterCreate, kAdapter) diff --git a/aether/adapters/wifi_adapter.cpp b/aether/adapters/wifi_adapter.cpp index ce5e9cd9..eced12da 100644 --- a/aether/adapters/wifi_adapter.cpp +++ b/aether/adapters/wifi_adapter.cpp @@ -18,15 +18,15 @@ #if AE_SUPPORT_WIFIS -# include # include +# include # include "aether/aether.h" -# include "aether/poller/poller.h" # include "aether/dns/dns_resolve.h" +# include "aether/poller/poller.h" # include "aether/wifi/wifi_driver_factory.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { # if defined AE_DISTILLATION diff --git a/aether/ae_actions/ae_actions_tele.h b/aether/ae_actions/ae_actions_tele.h index 9dbe7e02..f8a24a0c 100644 --- a/aether/ae_actions/ae_actions_tele.h +++ b/aether/ae_actions/ae_actions_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_AE_ACTIONS_AE_ACTIONS_TELE_H_ #define AETHER_AE_ACTIONS_AE_ACTIONS_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" #if AE_SUPPORT_REGISTRATION AE_TELE_MODULE(kRegister, 1000, 1000, 1050); diff --git a/aether/ae_actions/telemetry.cpp b/aether/ae_actions/telemetry.cpp index 22f0b531..fa0348eb 100644 --- a/aether/ae_actions/telemetry.cpp +++ b/aether/ae_actions/telemetry.cpp @@ -20,7 +20,7 @@ # include "aether-miscpp/format/format.h" # include "aether/aether.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" # include "aether/tele/traps/tele_statistics.h" # include "aether/mstream.h" diff --git a/aether/aether_app.cpp b/aether/aether_app.cpp index 4bccdb12..b47023a8 100644 --- a/aether/aether_app.cpp +++ b/aether/aether_app.cpp @@ -37,13 +37,14 @@ #include "aether/tele/tele_init.h" -#include "aether/aether_tele.h" +#include "aether/tele.h" +#include "aether/tele_compile_options.h" namespace ae { AetherAppContext::TelemetryInit::TelemetryInit() { tele::TeleInit::Init(); - AE_TELE_ENV(); + AE_TELE_ENV(kCompileOptions); AE_TELE_INFO(AetherStarted); Registry::GetRegistry().Log(); } diff --git a/aether/aether_tele.h b/aether/aether_tele.h index 1cde3bd1..7ae55515 100644 --- a/aether/aether_tele.h +++ b/aether/aether_tele.h @@ -17,8 +17,110 @@ #ifndef AETHER_AETHER_TELE_H_ #define AETHER_AETHER_TELE_H_ -#include "aether/tele/tele.h" +#include +#include "aether/config.h" +#include "aether/tele/levels.h" +#include "aether/tele/tags.h" + +namespace ae { +namespace aether_tele_internal { +template +consteval bool IsEnabled(std::initializer_list list) { + for (auto v : list) { + if (flag == v) { + return true; + } + } + return false; +} + +template +consteval bool IsEnabled(decltype(flag) value) { + return (flag == value); +} + +template +consteval bool IsAll(T const value) { + return value == static_cast(AE_ALL); +} +template +consteval bool IsAll(T const (& /* value */)[Size]) { // NOLINT(*c-arrays) + return false; +} +} // namespace aether_tele_internal + +// NOLINTBEGIN +// OPTION equals to AE_ALL or MODULE in OPTION list and not in OPTION_EXCLUDE +// list +#define _AE_MODULE_CONFIG(MODULE, OPTION) \ + (((aether_tele_internal::IsAll(OPTION) && \ + !aether_tele_internal::IsEnabled(OPTION##_EXCLUDE)) || \ + aether_tele_internal::IsEnabled(OPTION))) + +#define _AE_MODULE_DEBUG_ENABLED(MODULE) \ + _AE_MODULE_CONFIG(MODULE, AE_TELE_DEBUG_MODULES) +#define _AE_MODULE_INFO_ENABLED(MODULE) \ + _AE_MODULE_CONFIG(MODULE, AE_TELE_INFO_MODULES) +#define _AE_MODULE_WARN_ENABLED(MODULE) \ + _AE_MODULE_CONFIG(MODULE, AE_TELE_WARN_MODULES) +#define _AE_MODULE_ERROR_ENABLED(MODULE) \ + _AE_MODULE_CONFIG(MODULE, AE_TELE_ERROR_MODULES) + +// NOLINTNEXTLINE +#define _AE_LEVEL_MODULE_CONFIG(MODULE, LEVEL) \ + ((LEVEL) == ae::tele::Level::kDebug && _AE_MODULE_DEBUG_ENABLED(MODULE)) || \ + ((LEVEL) == ae::tele::Level::kInfo && \ + _AE_MODULE_INFO_ENABLED(MODULE)) || \ + ((LEVEL) == ae::tele::Level::kWarning && \ + _AE_MODULE_WARN_ENABLED(MODULE)) || \ + ((LEVEL) == ae::tele::Level::kError && _AE_MODULE_ERROR_ENABLED(MODULE)) + +struct AetherTeleConfig { + static constexpr bool kGlobalTeleEnabled = AE_TELE_ENABLED; + + template + struct TeleConfig { + // IF the whole Level + Module enabled + static constexpr bool kTeleEnabled = + kGlobalTeleEnabled && _AE_LEVEL_MODULE_CONFIG(M, L); + + static constexpr bool kLogsEnabled = + kTeleEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_MODULES); + + // count must be always enabled if metrics enabled + static constexpr bool kCountMetrics = + kTeleEnabled && _AE_MODULE_CONFIG(M, AE_TELE_METRICS_MODULES); + // time metrics + static constexpr bool kTimeMetrics = + kTeleEnabled && _AE_MODULE_CONFIG(M, AE_TELE_METRICS_MODULES) && + _AE_MODULE_CONFIG(M, AE_TELE_METRICS_DURATION); + + // start time + static constexpr bool kStartTimeLogs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_TIME_POINT); + // level and module + static constexpr bool kLevelModuleLogs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_LEVEL_MODULE); + // location + static constexpr bool kLocationLogs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_LOCATION); + // name + static constexpr bool kNameLogs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_NAME); + // blob + static constexpr bool kBlobLogs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_BLOB); + }; + + struct EnvConfig { + static constexpr bool kStaticInfo = AE_TELE_COMPILATION_INFO; + static constexpr bool kRuntimeInfo = AE_TELE_RUNTIME_INFO; + }; +}; +} // namespace ae + +// Main module for aether and tags AE_TELE_MODULE(kAether, 2, 3, 5); AE_TAG(AetherStarted, kAether) AE_TAG(AetherCreated, kAether) diff --git a/aether/all.h b/aether/all.h index 0f63ffe2..e18f9771 100644 --- a/aether/all.h +++ b/aether/all.h @@ -18,65 +18,65 @@ #define AETHER_ALL_H_ // IWYU pragma: begin_exports -#include "aether/config.h" -#include "aether/common.h" -#include "aether/memory.h" #include "aether/ae_context.h" #include "aether/aether_app.h" +#include "aether/common.h" +#include "aether/config.h" +#include "aether/memory.h" -#include "aether/executors/executors.h" #include "aether/actions/action_context.h" #include "aether/actions/repeatable_task.h" -#include "aether/events/events.h" #include "aether/events/cumulative_event.h" #include "aether/events/event_subscription.h" +#include "aether/events/events.h" #include "aether/events/multi_subscription.h" +#include "aether/executors/executors.h" #include "aether-miscpp/format/format.h" #include "aether-miscpp/reflect/reflect.h" -#include "aether/ptr/ptr.h" -#include "aether/ptr/rc_ptr.h" -#include "aether/ptr/ptr_view.h" +#include "aether/obj/domain.h" #include "aether/obj/obj.h" #include "aether/obj/obj_id.h" -#include "aether/obj/domain.h" #include "aether/obj/obj_ptr.h" #include "aether/obj/registry.h" +#include "aether/ptr/ptr.h" +#include "aether/ptr/ptr_view.h" +#include "aether/ptr/rc_ptr.h" #include "aether/tele/tele_init.h" -#include "aether/domain_storage/ram_domain_storage.h" -#include "aether/domain_storage/spifs_domain_storage.h" -#include "aether/domain_storage/static_domain_storage.h" #include "aether/domain_storage/domain_storage_factory.h" #include "aether/domain_storage/file_system_std_storage.h" +#include "aether/domain_storage/ram_domain_storage.h" #include "aether/domain_storage/registrar_domain_storage.h" +#include "aether/domain_storage/spifs_domain_storage.h" +#include "aether/domain_storage/static_domain_storage.h" -#include "aether/types/uid.h" -#include "aether/types/span.h" #include "aether/types/address.h" -#include "aether/types/static_map.h" -#include "aether/types/server_id.h" +#include "aether/types/address_parser.h" +#include "aether/types/client_config.h" #include "aether/types/client_id.h" -#include "aether/types/ring_index.h" #include "aether/types/data_buffer.h" -#include "aether/types/client_config.h" -#include "aether/types/server_config.h" -#include "aether/types/state_machine.h" #include "aether/types/literal_array.h" #include "aether/types/nullable_type.h" -#include "aether/types/address_parser.h" +#include "aether/types/ring_index.h" +#include "aether/types/server_config.h" +#include "aether/types/server_id.h" +#include "aether/types/span.h" +#include "aether/types/state_machine.h" +#include "aether/types/static_map.h" +#include "aether/types/uid.h" -#include "aether/stream_api/istream.h" #include "aether/stream_api/api_call_adapter.h" -#include "aether/write_action/write_action.h" +#include "aether/stream_api/istream.h" #include "aether/write_action/buffer_write.h" -#include "aether/write_action/failed_write_action.h" #include "aether/write_action/done_write_action.h" +#include "aether/write_action/failed_write_action.h" +#include "aether/write_action/write_action.h" #include "aether/serial_ports/iserial_port.h" -#include "aether/serial_ports/serial_port_types.h" #include "aether/serial_ports/serial_port_factory.h" +#include "aether/serial_ports/serial_port_types.h" #include "aether/gateway_api/gateway_api.h" #include "aether/gateway_api/server_endpoints.h" @@ -84,33 +84,33 @@ #include "aether/adapter_registry.h" #include "aether/adapters/ethernet.h" -#include "aether/adapters/wifi_adapter.h" -#include "aether/adapters/modem_adapter.h" #include "aether/adapters/lora_module_adapter.h" +#include "aether/adapters/modem_adapter.h" +#include "aether/adapters/wifi_adapter.h" -#include "aether/ae_actions/ping.h" -#include "aether/ae_actions/telemetry.h" +#include "aether/ae_actions/check_access_for_send_message.h" #include "aether/ae_actions/get_servers.h" +#include "aether/ae_actions/ping.h" #include "aether/ae_actions/select_client.h" -#include "aether/ae_actions/check_access_for_send_message.h" +#include "aether/ae_actions/telemetry.h" #include "aether/modems/imodem_driver.h" #include "aether/modems/modem_factory.h" -#include "aether/global_ids.h" #include "aether/aether.h" +#include "aether/channels/channel.h" #include "aether/client.h" #include "aether/client_connectivity_policy.h" -#include "aether/server.h" -#include "aether/channels/channel.h" -#include "aether/crypto.h" -#include "aether/cloud.h" -#include "aether/work_cloud.h" -#include "aether/registration_cloud.h" #include "aether/client_messages/p2p_message_stream.h" #include "aether/client_messages/p2p_safe_message_stream.h" +#include "aether/cloud.h" +#include "aether/crypto.h" +#include "aether/global_ids.h" +#include "aether/registration_cloud.h" +#include "aether/server.h" +#include "aether/work_cloud.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" // IWYU pragma: end_exports #endif // AETHER_ALL_H_ diff --git a/aether/api_protocol/api_class_impl.h b/aether/api_protocol/api_class_impl.h index e0294a2a..fa047fab 100644 --- a/aether/api_protocol/api_class_impl.h +++ b/aether/api_protocol/api_class_impl.h @@ -20,7 +20,7 @@ #include "aether-miscpp/reflect/reflect.h" #include "aether/api_protocol/api_class.h" #include "aether/api_protocol/api_pack_parser.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { /** diff --git a/aether/api_protocol/protocol_context.cpp b/aether/api_protocol/protocol_context.cpp index 3539411e..37d2f9b5 100644 --- a/aether/api_protocol/protocol_context.cpp +++ b/aether/api_protocol/protocol_context.cpp @@ -22,7 +22,7 @@ #include "aether/api_protocol/api_protocol.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { ProtocolContext::ProtocolContext() = default; diff --git a/aether/channels/ethernet_channel.cpp b/aether/channels/ethernet_channel.cpp index ecff57ab..a04fdf19 100644 --- a/aether/channels/ethernet_channel.cpp +++ b/aether/channels/ethernet_channel.cpp @@ -29,7 +29,7 @@ #include "aether/channels/ethernet_transport_factory.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { namespace ethernet_access_point_internal { diff --git a/aether/channels/wifi_channel.cpp b/aether/channels/wifi_channel.cpp index c33f5fae..5b23bde3 100644 --- a/aether/channels/wifi_channel.cpp +++ b/aether/channels/wifi_channel.cpp @@ -31,7 +31,7 @@ # include "aether/channels/ethernet_transport_factory.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { namespace wifi_channel_internal { diff --git a/aether/client_messages/client_messages_tele.h b/aether/client_messages/client_messages_tele.h index e5d3ec33..4cf1c6c1 100644 --- a/aether/client_messages/client_messages_tele.h +++ b/aether/client_messages/client_messages_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_CLIENT_MESSAGES_CLIENT_MESSAGES_TELE_H_ #define AETHER_CLIENT_MESSAGES_CLIENT_MESSAGES_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kClientMessages, 8, 166, 170); diff --git a/aether/cloud_connections/cloud_connections_tele.h b/aether/cloud_connections/cloud_connections_tele.h index 4bdf67f4..022b4969 100644 --- a/aether/cloud_connections/cloud_connections_tele.h +++ b/aether/cloud_connections/cloud_connections_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_CLOUD_CONNECTIONS_CLOUD_CONNECTIONS_TELE_H_ #define AETHER_CLOUD_CONNECTIONS_CLOUD_CONNECTIONS_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kCloudClientConnection, 30, 110, 112); diff --git a/aether/cloud_connections/cloud_server_connections.cpp b/aether/cloud_connections/cloud_server_connections.cpp index 5329038f..4d7d32e7 100644 --- a/aether/cloud_connections/cloud_server_connections.cpp +++ b/aether/cloud_connections/cloud_server_connections.cpp @@ -18,11 +18,11 @@ #include -#include "aether/server.h" #include "aether/api_protocol/api_protocol.h" +#include "aether/server.h" #include "aether/server_connections/server_connection.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { diff --git a/aether/connection_manager/client_cloud_manager.cpp b/aether/connection_manager/client_cloud_manager.cpp index e9c284d8..22b14b54 100644 --- a/aether/connection_manager/client_cloud_manager.cpp +++ b/aether/connection_manager/client_cloud_manager.cpp @@ -16,15 +16,15 @@ #include "aether/connection_manager/client_cloud_manager.h" -#include #include #include +#include #include "aether/aether.h" #include "aether/client.h" #include "aether/work_cloud.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { namespace client_cloud_manager_internal { @@ -212,7 +212,7 @@ void ClientCloudManager::ListenForCloudUpdate() { cloud_update_sub_ = CloudEventListener{ ApiEventSubscriber{[this](ClientApiSafe& client_api, - CloudServerConnection* /*server_connection*/) { + CloudServerConnection* /*server_connection*/) { return client_api.send_cloud_configs().Subscribe( MethodPtr<&ClientCloudManager::CloudConfigs>{this}); }}, diff --git a/aether/connection_manager/get_cloud_aether.cpp b/aether/connection_manager/get_cloud_aether.cpp index 923dbb27..81065442 100644 --- a/aether/connection_manager/get_cloud_aether.cpp +++ b/aether/connection_manager/get_cloud_aether.cpp @@ -18,7 +18,7 @@ #include "aether/connection_manager/client_cloud_manager.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { GetCloudFromAether::GetCloudFromAether(AeContext const& ae_context, @@ -48,8 +48,8 @@ GetCloudFromAether::GetCloudFromAether(AeContext const& ae_context, }, cloud_update_sub_{client_cloud_manager.cloud_update_event().Subscribe( MethodPtr<&GetCloudFromAether::CloudUpdate>{this})} { - cloud_request_result_sub_ = cloud_request_.result_event().Subscribe( - [this](bool success) { + cloud_request_result_sub_ = + cloud_request_.result_event().Subscribe([this](bool success) { if (!success) { AE_TELED_ERROR("CloudRequest failed for uid:{}", client_uid_); result_event_.Emit(Error{-1}); diff --git a/aether/crypto/hydrogen/hydro_sync_crypto_provider.cpp b/aether/crypto/hydrogen/hydro_sync_crypto_provider.cpp index 178567f4..0a8f836b 100644 --- a/aether/crypto/hydrogen/hydro_sync_crypto_provider.cpp +++ b/aether/crypto/hydrogen/hydro_sync_crypto_provider.cpp @@ -24,7 +24,7 @@ # include # include "aether/crypto/crypto_definitions.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { namespace _internal { @@ -63,10 +63,10 @@ inline std::vector DecryptWithSymmetric( auto const* encrypted_ptr = msg_id_ptr + sizeof(msg_id); - auto r = hydro_secretbox_decrypt( - decrypted_data.data(), encrypted_ptr, - encrypted_data.size() - sizeof(msg_id), msg_id, HYDRO_CONTEXT, - secret_key.key.data()); + auto r = + hydro_secretbox_decrypt(decrypted_data.data(), encrypted_ptr, + encrypted_data.size() - sizeof(msg_id), msg_id, + HYDRO_CONTEXT, secret_key.key.data()); if (r != 0) { return {}; } diff --git a/aether/crypto/sodium/sodium_sync_crypto_provider.cpp b/aether/crypto/sodium/sodium_sync_crypto_provider.cpp index 47d89c67..9633c8a4 100644 --- a/aether/crypto/sodium/sodium_sync_crypto_provider.cpp +++ b/aether/crypto/sodium/sodium_sync_crypto_provider.cpp @@ -24,7 +24,7 @@ # include # include "aether/crypto/crypto_nonce.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { diff --git a/aether/dns/dns_tele.h b/aether/dns/dns_tele.h index 74ed1c55..c3fb727e 100644 --- a/aether/dns/dns_tele.h +++ b/aether/dns/dns_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_DNS_DNS_TELE_H_ #define AETHER_DNS_DNS_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kDns, 7, 156, 165); diff --git a/aether/domain_storage/domain_storage_tele.h b/aether/domain_storage/domain_storage_tele.h index 9e1a052b..66d11c17 100644 --- a/aether/domain_storage/domain_storage_tele.h +++ b/aether/domain_storage/domain_storage_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_DOMAIN_STORAGE_DOMAIN_STORAGE_TELE_H_ #define AETHER_DOMAIN_STORAGE_DOMAIN_STORAGE_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kDomainStorage, 9, 171, 185); AE_TELE_MODULE(kDomainStorageDebug, 109, 300, 320); diff --git a/aether/domain_storage/registrar_domain_storage.cpp b/aether/domain_storage/registrar_domain_storage.cpp index 8b19c9ef..576283b6 100644 --- a/aether/domain_storage/registrar_domain_storage.cpp +++ b/aether/domain_storage/registrar_domain_storage.cpp @@ -24,7 +24,7 @@ # include "aether-miscpp/format/format.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { diff --git a/aether/domain_storage/static_domain_storage.h b/aether/domain_storage/static_domain_storage.h index 4138fde9..43c986c4 100644 --- a/aether/domain_storage/static_domain_storage.h +++ b/aether/domain_storage/static_domain_storage.h @@ -17,10 +17,10 @@ #ifndef AETHER_DOMAIN_STORAGE_STATIC_DOMAIN_STORAGE_H_ #define AETHER_DOMAIN_STORAGE_STATIC_DOMAIN_STORAGE_H_ -#include "aether/obj/idomain_storage.h" #include "aether/domain_storage/static_object_types.h" +#include "aether/obj/idomain_storage.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { class StaticDomainStorageReader final : public IDomainStorageReader { diff --git a/aether/lora_modules/lora_modules_tele.h b/aether/lora_modules/lora_modules_tele.h index cf1b6444..61683008 100644 --- a/aether/lora_modules/lora_modules_tele.h +++ b/aether/lora_modules/lora_modules_tele.h @@ -17,7 +17,7 @@ #define AETHER_LORA_MODULES_LORA_MODULES_TELE_H_ // IWYU pragma: begin_exports -#include "aether/tele/tele.h" +#include "aether/tele.h" // IWYU pragma: end_exports #endif // AETHER_LORA_MODULES_LORA_MODULES_TELE_H_ diff --git a/aether/modems/modems_tele.h b/aether/modems/modems_tele.h index 81b3ead6..3abfb597 100644 --- a/aether/modems/modems_tele.h +++ b/aether/modems/modems_tele.h @@ -17,7 +17,7 @@ #define AETHER_MODEMS_MODEMS_TELE_H_ // IWYU pragma: begin_exports -#include "aether/tele/tele.h" +#include "aether/tele.h" // IWYU pragma: end_exports #endif // AETHER_MODEMS_MODEMS_TELE_H_ diff --git a/aether/obj/obj_tele.h b/aether/obj/obj_tele.h index ecef9d6f..5e9e68c7 100644 --- a/aether/obj/obj_tele.h +++ b/aether/obj/obj_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_OBJ_OBJ_TELE_H_ #define AETHER_OBJ_OBJ_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kObj, 1, 1, 2); AE_TAG(ObjectDomainUpdatePastTime, kObj); diff --git a/aether/poller/poller_tele.h b/aether/poller/poller_tele.h index 3364b9f6..e37ba631 100644 --- a/aether/poller/poller_tele.h +++ b/aether/poller/poller_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_POLLER_POLLER_TELE_H_ #define AETHER_POLLER_POLLER_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kPoller, 6, 121, 155); diff --git a/aether/registration/root_server_select_stream.cpp b/aether/registration/root_server_select_stream.cpp index a0522e4f..0e4daed5 100644 --- a/aether/registration/root_server_select_stream.cpp +++ b/aether/registration/root_server_select_stream.cpp @@ -18,7 +18,7 @@ #if AE_SUPPORT_REGISTRATION -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { RootServerSelectStream::RootServerSelectStream( diff --git a/aether/safe_stream/details/safe_stream_recv_action.h b/aether/safe_stream/details/safe_stream_recv_action.h index 509f314a..00283ee5 100644 --- a/aether/safe_stream/details/safe_stream_recv_action.h +++ b/aether/safe_stream/details/safe_stream_recv_action.h @@ -27,7 +27,7 @@ #include "aether/safe_stream/details/safe_stream_data_message.h" #include "aether/safe_stream/safe_stream_config.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { class ISendAckRepeat { diff --git a/aether/safe_stream/details/safe_stream_send_action.h b/aether/safe_stream/details/safe_stream_send_action.h index ff30834d..6463f532 100644 --- a/aether/safe_stream/details/safe_stream_send_action.h +++ b/aether/safe_stream/details/safe_stream_send_action.h @@ -19,19 +19,19 @@ #include +#include "aether/ae_context.h" #include "aether/common.h" #include "aether/config.h" -#include "aether/ae_context.h" #include "aether/events/events.h" -#include "aether/types/statistic_counter.h" #include "aether/events/multi_subscription.h" -#include "aether/write_action/write_action.h" -#include "aether/safe_stream/safe_stream_config.h" #include "aether/safe_stream/details/circular_buffer.h" -#include "aether/safe_stream/details/sending_chunk_list.h" #include "aether/safe_stream/details/safe_stream_data_message.h" +#include "aether/safe_stream/details/sending_chunk_list.h" +#include "aether/safe_stream/safe_stream_config.h" +#include "aether/types/statistic_counter.h" +#include "aether/write_action/write_action.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { diff --git a/aether/safe_stream/safe_stream.h b/aether/safe_stream/safe_stream.h index df553bf8..7e9a4dc6 100644 --- a/aether/safe_stream/safe_stream.h +++ b/aether/safe_stream/safe_stream.h @@ -17,20 +17,20 @@ #ifndef AETHER_STREAM_API_SAFE_STREAM_H_ #define AETHER_STREAM_API_SAFE_STREAM_H_ -#include "aether/common.h" #include "aether/actions/action_context.h" +#include "aether/common.h" #include "aether/write_action/failed_write_action.h" -#include "aether/stream_api/api_call_adapter.h" -#include "aether/safe_stream/safe_stream_config.h" #include "aether/safe_stream/details/safe_stream_api.h" +#include "aether/safe_stream/details/safe_stream_data_message.h" #include "aether/safe_stream/details/safe_stream_recv_action.h" #include "aether/safe_stream/details/safe_stream_send_action.h" -#include "aether/safe_stream/details/safe_stream_data_message.h" +#include "aether/safe_stream/safe_stream_config.h" +#include "aether/stream_api/api_call_adapter.h" #include "aether/stream_api/istream.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { template diff --git a/aether/serial_ports/at_support/at_buffer.cpp b/aether/serial_ports/at_support/at_buffer.cpp index 7423f4b2..f38168ef 100644 --- a/aether/serial_ports/at_support/at_buffer.cpp +++ b/aether/serial_ports/at_support/at_buffer.cpp @@ -16,7 +16,7 @@ #include "aether/serial_ports/at_support/at_buffer.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { AtBuffer::AtBuffer(ISerialPort& serial_port) diff --git a/aether/serial_ports/serial_ports_tele.h b/aether/serial_ports/serial_ports_tele.h index b319025a..fbeaf3e7 100644 --- a/aether/serial_ports/serial_ports_tele.h +++ b/aether/serial_ports/serial_ports_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_SERIAL_PORTS_SERIAL_PORTS_TELE_H_ #define AETHER_SERIAL_PORTS_SERIAL_PORTS_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kSerialPorts, 200, 500, 550); diff --git a/aether/server_connections/channel_connection.cpp b/aether/server_connections/channel_connection.cpp index 5a6a008e..09b43acb 100644 --- a/aether/server_connections/channel_connection.cpp +++ b/aether/server_connections/channel_connection.cpp @@ -21,7 +21,7 @@ #include "aether-miscpp/misc/override.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { ChannelConnection::ChannelConnection(AeContext const& ae_context) diff --git a/aether/server_connections/client_server_connection.cpp b/aether/server_connections/client_server_connection.cpp index 66d29b46..6603eabb 100644 --- a/aether/server_connections/client_server_connection.cpp +++ b/aether/server_connections/client_server_connection.cpp @@ -17,14 +17,14 @@ #include "aether/server_connections/client_server_connection.h" #include "aether/aether.h" -#include "aether/server.h" +#include "aether/api_protocol/api_protocol.h" #include "aether/client.h" #include "aether/crypto/ikey_provider.h" -#include "aether/api_protocol/api_protocol.h" -#include "aether/stream_api/api_call_adapter.h" #include "aether/crypto/sync_crypto_provider.h" +#include "aether/server.h" +#include "aether/stream_api/api_call_adapter.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { namespace client_server_connection_internal { diff --git a/aether/server_connections/server_connection.cpp b/aether/server_connections/server_connection.cpp index b63e07e1..37fe61e6 100644 --- a/aether/server_connections/server_connection.cpp +++ b/aether/server_connections/server_connection.cpp @@ -23,7 +23,7 @@ #include "aether/channels/channel.h" #include "aether/server.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { ServerConnection::ChannelSelectAction::ChannelSelectAction( diff --git a/aether/socket_initializer.cpp b/aether/socket_initializer.cpp index 5d5d0e8b..318c99d8 100644 --- a/aether/socket_initializer.cpp +++ b/aether/socket_initializer.cpp @@ -19,7 +19,7 @@ #if defined WIN32 # include -# include "aether/tele/tele.h" +# include "aether/tele.h" #endif namespace ae { diff --git a/aether/tele.h b/aether/tele.h new file mode 100644 index 00000000..5b313bf3 --- /dev/null +++ b/aether/tele.h @@ -0,0 +1,31 @@ +/* + * Copyright 2026 Aethernet Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AETHER_TELE_H_ +#define AETHER_TELE_H_ + +// IWYU pragma: begin_keeps +#include "aether/aether_tele.h" + +#ifdef TELE_SINK +# undef TELE_SINK +#endif +#define TELE_SINK ::ae::tele::TeleSink<::ae::AetherTeleConfig> + +#include "aether/tele/tele.h" +// IWYU pragma: end_keeps + +#endif // AETHER_TELE_H_ diff --git a/aether/tele/collectors.h b/aether/tele/collectors.h index 2b0c38f1..8ce3e419 100644 --- a/aether/tele/collectors.h +++ b/aether/tele/collectors.h @@ -66,10 +66,7 @@ struct TimedTele { }; template -static constexpr inline bool kIsAnyLogs = - TConfig::kIndexLogs || TConfig::kStartTimeLogs || - TConfig::kLevelModuleLogs || TConfig::kLocationLogs || TConfig::kNameLogs || - TConfig::kBlobLogs; +static constexpr inline bool kIsAnyLogs = TConfig::kLogsEnabled; template static constexpr inline bool kIsAnyMetrics = diff --git a/aether/tele/configs/all_enabled.h b/aether/tele/configs/all_enabled.h new file mode 100644 index 00000000..956947f6 --- /dev/null +++ b/aether/tele/configs/all_enabled.h @@ -0,0 +1,45 @@ +/* + * Copyright 2026 Aethernet Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef AETHER_TELE_CONFIGS_ALL_ENABLED_H_ +#define AETHER_TELE_CONFIGS_ALL_ENABLED_H_ + +#include + +#include "aether/tele/levels.h" + +namespace ae::tele { +struct AllEnabledConfig { + template + struct TeleConfig { + static constexpr bool kCountMetrics = true; + static constexpr bool kTimeMetrics = true; + static constexpr bool kLogsEnabled = true; + static constexpr bool kStartTimeLogs = true; + static constexpr bool kLevelModuleLogs = true; + static constexpr bool kLocationLogs = true; + static constexpr bool kNameLogs = true; + static constexpr bool kBlobLogs = true; + }; + + struct EnvConfig { + static constexpr bool kStaticInfo = true; + static constexpr bool kRuntimeInfo = true; + }; +}; +} // namespace ae::tele + +#endif // AETHER_TELE_CONFIGS_ALL_ENABLED_H_ diff --git a/aether/tele/configs/config_provider.h b/aether/tele/configs/config_provider.h deleted file mode 100644 index 82027bac..00000000 --- a/aether/tele/configs/config_provider.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright 2024 Aethernet Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AETHER_TELE_CONFIGS_CONFIG_PROVIDER_H_ -#define AETHER_TELE_CONFIGS_CONFIG_PROVIDER_H_ - -#include - -#include "aether/config.h" - -#include "aether/tele/levels.h" - -namespace ae::tele { -template -constexpr bool IsEnabled(std::initializer_list list) { - for (auto v : list) { - if (flag == v) { - return AE_TELE_ENABLED; - } - } - return false; -} - -template -constexpr bool IsEnabled(decltype(flag) value) { - return AE_TELE_ENABLED && (flag == value); -} - -template -constexpr bool IsAll(T const value) { - return AE_TELE_ENABLED && value == static_cast(AE_ALL); -} -template -constexpr bool IsAll(T const (& /* value */)[Size]) { - return false; -} - -// OPTION equals to AE_ALL or MODULE in OPTION list and not in OPTION_EXCLUDE -// list -#define _AE_MODULE_CONFIG(MODULE, OPTION) \ - (((IsAll(OPTION) && !IsEnabled(OPTION##_EXCLUDE)) || \ - IsEnabled(OPTION))) - -#define _AE_LEVEL_MODULE_CONFIG(MODULE, LEVEL) \ - (LEVEL == ae::tele::Level::kDebug \ - ? _AE_MODULE_CONFIG(MODULE, AE_TELE_DEBUG_MODULES) \ - : (LEVEL == ae::tele::Level::kInfo \ - ? _AE_MODULE_CONFIG(MODULE, AE_TELE_INFO_MODULES) \ - : (LEVEL == ae::tele::Level::kWarning \ - ? _AE_MODULE_CONFIG(MODULE, AE_TELE_WARN_MODULES) \ - : /* ae::tele::Level::kError */ _AE_MODULE_CONFIG( \ - MODULE, AE_TELE_ERROR_MODULES)))) - -struct ConfigProvider { - template - struct TeleConfig { - static constexpr bool kCountMetrics = count_metrics; - static constexpr bool kTimeMetrics = time_metrics; - static constexpr bool kIndexLogs = index_logs; - static constexpr bool kStartTimeLogs = start_time_logs; - static constexpr bool kLevelModuleLogs = level_module_logs; - static constexpr bool kLocationLogs = location_logs; - static constexpr bool kNameLogs = name_logs; - static constexpr bool kBlobLogs = blob_logs; - }; - - template - struct EnvConfig { - static constexpr bool kCompiler{compiler}; - static constexpr bool kPlatformType{platform_type}; - static constexpr bool kCompilationOptions{compilation_options}; - static constexpr bool kLibraryVersion{library_version}; - static constexpr bool kApiVersion{api_version}; - static constexpr bool kCpuType{cpu_type}; - static constexpr bool kUtmId{utm_id}; - static constexpr bool kCustomData{custom_data}; - }; - - template - static constexpr auto GetStaticConfig() { - return TeleConfig< - // - // count must be always enabled if metrics enabled - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_METRICS_MODULES), - // time metrics - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_METRICS_MODULES) && - _AE_MODULE_CONFIG(module, AE_TELE_METRICS_DURATION), - // index must be always enabled if log enabled - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_MODULES), - // start time - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_MODULES) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_TIME_POINT), - // level and module - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_MODULES) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_LEVEL_MODULE), - // location - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_MODULES) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_LOCATION), - // name - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_MODULES) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_NAME), - // blob - _AE_LEVEL_MODULE_CONFIG(module, level) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_MODULES) && - _AE_MODULE_CONFIG(module, AE_TELE_LOG_BLOB)>{}; - } - - template - using StaticTeleConfig = decltype(GetStaticConfig()); - - using StaticEnvConfig = - EnvConfig; -}; -} // namespace ae::tele - -#endif // AETHER_TELE_CONFIGS_CONFIG_PROVIDER_H_ */ diff --git a/aether/tele/defines.h b/aether/tele/defines.h index 3e43c6c9..5384013f 100644 --- a/aether/tele/defines.h +++ b/aether/tele/defines.h @@ -17,21 +17,25 @@ #ifndef AETHER_TELE_DEFINES_H_ #define AETHER_TELE_DEFINES_H_ -#include "aether/common.h" - +// IWYU pragma: begin_keeps #include "aether/tele/collectors.h" #include "aether/tele/env_collectors.h" #include "aether/tele/modules.h" #include "aether/tele/tags.h" +// IWYU pragma: end_keeps + +#define AETE_CAT_(A, B) A##B +#define AETE_CAT(A, B) AETE_CAT_(A, B) +#define AETE_UNIQUE_NAME(P) AETE_CAT(P, AETE_CAT(__LINE__, __COUNTER__)) #ifndef UTM_ID # define UTM_ID 0 #endif -namespace ae::tele { -using ae::tele::EnvTele; -using ae::tele::Tele; -} // namespace ae::tele +// namespace ae::tele { +// using ae::tele::EnvTele; +// using ae::tele::Tele; +// } // namespace ae::tele // A special tag for telemetry debug debug @@ -47,29 +51,33 @@ AE_TAG(kLog, MLog) } #define AE_TELE_DEBUG(TAG, ...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kDebug, __VA_ARGS__) + AE_TELE_(AETE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kDebug, __VA_ARGS__) #define AE_TELE_INFO(TAG, ...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kInfo, __VA_ARGS__) -#define AE_TELE_WARNING(TAG, ...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kWarning, __VA_ARGS__) + AE_TELE_(AETE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kInfo, __VA_ARGS__) +#define AE_TELE_WARNING(TAG, ...) \ + AE_TELE_(AETE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kWarning, \ + __VA_ARGS__) #define AE_TELE_ERROR(TAG, ...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kError, __VA_ARGS__) + AE_TELE_(AETE_UNIQUE_NAME(TELE_), TAG, ::ae::tele::Level::kError, __VA_ARGS__) // For simple logging -#define AE_TELED_DEBUG(...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kDebug, __VA_ARGS__) +#define AE_TELED_DEBUG(...) \ + AE_TELE_(AETE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kDebug, \ + __VA_ARGS__) #define AE_TELED_INFO(...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kInfo, __VA_ARGS__) -#define AE_TELED_WARNING(...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kWarning, \ + AE_TELE_(AETE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kInfo, __VA_ARGS__) +#define AE_TELED_WARNING(...) \ + AE_TELE_(AETE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kWarning, \ + __VA_ARGS__) +#define AE_TELED_ERROR(...) \ + AE_TELE_(AETE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kError, \ __VA_ARGS__) -#define AE_TELED_ERROR(...) \ - AE_TELE_(AE_UNIQUE_NAME(TELE_), kLog, ::ae::tele::Level::kError, __VA_ARGS__) // Log environment data -#define AE_TELE_ENV(...) \ - [[maybe_unused]] ::ae::tele::EnvTele AE_UNIQUE_NAME(TELE_ENV_) { \ - TELE_SINK::Instance(), UTM_ID __VA_ARGS__ \ +#define AE_TELE_ENV(...) \ + [[maybe_unused]] auto AETE_UNIQUE_NAME(TELE_ENV_) = \ + ::ae::tele::EnvTele { \ + TELE_SINK::Instance(), UTM_ID, __VA_ARGS__ \ } #endif // AETHER_TELE_DEFINES_H_ */ diff --git a/aether/tele/env/compiler.h b/aether/tele/env/compiler.h index c434a915..74805086 100644 --- a/aether/tele/env/compiler.h +++ b/aether/tele/env/compiler.h @@ -17,14 +17,16 @@ #ifndef AETHER_TELE_ENV_COMPILER_H_ #define AETHER_TELE_ENV_COMPILER_H_ -#define _STR(x) _QUOTE(x) +#define AETE_QUOTE(x) #x -#define _AE_CONCAT_0(A, B, ...) A##B -#define _AE_CONCAT_1(A, ...) _AE_CONCAT_0(A##__VA_ARGS__) -#define _AE_CONCAT_2(A, ...) _AE_CONCAT_1(A##__VA_ARGS__) -#define _AE_CONCAT_3(A, ...) _AE_CONCAT_2(A##__VA_ARGS__) -#define _AE_CONCAT_N(_3, _2, _1, _0, X, ...) _AE_CONCAT##X(_3, _2, _1, _0) -#define AETE_CONCAT(...) _AE_CONCAT_N(__VA_ARGS__, _2, _1, _0) +#define AETE_STR(x) AETE_QUOTE(x) + +#define _AETE_CONCAT_0(A, B, ...) A##B +#define _AETE_CONCAT_1(A, ...) __CONCAT_0(A##__VA_ARGS__) +#define _AETE_CONCAT_2(A, ...) _AETE_CONCAT_1(A##__VA_ARGS__) +#define _AETE_CONCAT_3(A, ...) _AETE_CONCAT_2(A##__VA_ARGS__) +#define _AETE_CONCAT_N(_3, _2, _1, _0, X, ...) _AETE_CONCAT##X(_3, _2, _1, _0) +#define AETE_CONCAT(...) _AETE_CONCAT_N(__VA_ARGS__, _2, _1, _0) #if defined __clang__ # if defined __MINGW32__ @@ -32,9 +34,9 @@ # else # define COMPILER "clang" # endif -# define COMPILER_VERSION \ - _STR(__clang_major__) \ - "." _STR(__clang_minor__) "." _STR(__clang_patchlevel__) +# define COMPILER_VERSION \ + AETE_STR(__clang_major__) \ + "." AETE_STR(__clang_minor__) "." AETE_STR(__clang_patchlevel__) # define COMPILER_VERSION_NUM \ AE_CONCAT(__clang_major__, __clang_minor__, __clang_patchlevel__) #elif defined __GNUC__ @@ -44,12 +46,13 @@ # define COMPILER "gcc" # endif # define COMPILER_VERSION \ - _STR(__GNUC__) "." _STR(__GNUC_MINOR__) "." _STR(__GNUC_PATCHLEVEL__) + AETE_STR(__GNUC__) \ + "." AETE_STR(__GNUC_MINOR__) "." AETE_STR(__GNUC_PATCHLEVEL__) # define COMPILER_VERSION_NUM \ AE_CONCAT(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) #elif defined _MSC_VER # define COMPILER "msvc" -# define COMPILER_VERSION _STR(_MSC_FULL_VER) +# define COMPILER_VERSION AETE_STR(_MSC_FULL_VER) # define COMPILER_VERSION_NUM _MSC_FULL_VER #else # warning "unknown compiler" diff --git a/aether/tele/env_collectors.h b/aether/tele/env_collectors.h index e18cfaed..c6900b90 100644 --- a/aether/tele/env_collectors.h +++ b/aether/tele/env_collectors.h @@ -23,7 +23,6 @@ #include "aether/env.h" #include "aether/tele/compile_option.h" -#include "aether/tele/env/compilation_options.h" #include "aether/tele/env/compiler.h" #include "aether/tele/env/cpu_architecture.h" #include "aether/tele/env/library_version.h" @@ -46,90 +45,48 @@ namespace ae::tele { * - architecture */ -template -constexpr bool IsCompilation() { - return TEnvConfig::kCompiler || TEnvConfig::kCompilationOptions || - TEnvConfig::kLibraryVersion || TEnvConfig::kApiVersion; -} - -template -constexpr bool IsRuntime() { - return false; -} - -template -constexpr bool IsAnyEnvCollection() { - return IsCompilation() || IsRuntime() || - TEnvConfig::kCustomData; -} - constexpr auto PlatformType() { return AE_PLATFORM_TYPE; } constexpr auto CompilerName() { return COMPILER; } constexpr auto CompilerVersion() { return COMPILER_VERSION; } - -template -constexpr auto CompilationOptionsImpl(OptsArr const& arr, - std::index_sequence) { - return std::array{ - CompileOption{Is, arr[Is].first, arr[Is].second}...}; -} -constexpr auto CompilationOptions() { - return CompilationOptionsImpl( - _compile_options_list, - std::make_index_sequence<_compile_options_list.size()>{}); -} constexpr auto LibraryVersion() { return LIBRARY_VERSION; } -constexpr auto ApiVersion() { - // TODO: add collect api version - return "0.0.0"; -} constexpr Endianness PlatformEndianness() { return static_cast(AE_ENDIANNESS); } constexpr auto CpuType() { return AE_CPU_TYPE; } -template ()> +template struct EnvTele { + template + constexpr explicit EnvTele(TArgs&&... /* args */) {} +}; + +template +struct EnvTele> { using Sink = TSink; using SinkConfig = typename Sink::EnvConfig; - template + template explicit EnvTele( Sink& sink, [[maybe_unused]] std::uint32_t utm_id, - [[maybe_unused]] std::pair&&... args) { - std::vector compile_options; - std::vector custom_options; + [[maybe_unused]] std::array const& + compile_options = {}, + [[maybe_unused]] std::array const& + custom_options = {}) { auto env_data = EnvData{}; - if constexpr (SinkConfig::kPlatformType) { + + if constexpr (SinkConfig::kStaticInfo) { env_data.platform_type = PlatformType(); - } - if constexpr (SinkConfig::kCompiler) { env_data.compiler = CompilerName(); env_data.compiler_version = CompilerVersion(); - } - if constexpr (SinkConfig::kCompilationOptions) { - auto opts = CompilationOptions(); - compile_options.insert(std::end(compile_options), std::begin(opts), - std::end(opts)); - env_data.compile_options = std::span{compile_options}; - } - if constexpr (SinkConfig::kLibraryVersion) { env_data.library_version = LibraryVersion(); - } - if constexpr (SinkConfig::kApiVersion) { - env_data.api_version = ApiVersion(); - } - if constexpr (SinkConfig::kCpuType) { env_data.cpu_arch = CpuType(); env_data.endianness = PlatformEndianness(); - } - if constexpr (SinkConfig::kUtmId) { env_data.utm_id = utm_id; + env_data.compile_options = std::span{compile_options}; } - if constexpr (SinkConfig::kCustomData) { - custom_options = {CustomOption{args.first, args.second}...}; + if constexpr (SinkConfig::kRuntimeInfo) { env_data.custom_options = std::span{custom_options}; } auto& trap = sink.trap(); @@ -140,11 +97,6 @@ struct EnvTele { } }; -template -struct EnvTele { - template - constexpr explicit EnvTele(TArgs&&... /* args */) {} -}; } // namespace ae::tele #endif // AETHER_TELE_ENV_COLLECTORS_H_ */ diff --git a/aether/tele/itrap.h b/aether/tele/itrap.h index dac4252a..47396ba0 100644 --- a/aether/tele/itrap.h +++ b/aether/tele/itrap.h @@ -39,7 +39,6 @@ struct EnvData { std::string_view compiler; std::string_view compiler_version; std::string_view library_version; - std::string_view api_version; std::string_view cpu_arch; Endianness endianness; std::uint32_t utm_id; diff --git a/aether/tele/sink.h b/aether/tele/sink.h index e58122ed..1bb4a77f 100644 --- a/aether/tele/sink.h +++ b/aether/tele/sink.h @@ -17,25 +17,22 @@ #ifndef AETHER_TELE_SINK_H_ #define AETHER_TELE_SINK_H_ -#include #include #include "aether/tele/itrap.h" #include "aether/tele/levels.h" -#include "aether/tele/modules.h" +#include "aether/tele/modules.h" // IWYU pragma: keep namespace ae::tele { - template class TeleSink { public: using ConfigProviderType = ConfigProvider; template - using TeleConfig = - typename ConfigProviderType::template StaticTeleConfig; + using TeleConfig = typename ConfigProviderType::template TeleConfig; - using EnvConfig = typename ConfigProviderType::StaticEnvConfig; + using EnvConfig = typename ConfigProviderType::EnvConfig; static TeleSink& Instance() { static TeleSink sink; diff --git a/aether/tele/tele.h b/aether/tele/tele.h index 64458e23..6f99a802 100644 --- a/aether/tele/tele.h +++ b/aether/tele/tele.h @@ -18,21 +18,21 @@ #define AETHER_TELE_TELE_H_ // IWYU pragma: begin_exports -#include "aether/tele/tags.h" -#include "aether/tele/sink.h" +#include "aether/tele/configs/all_enabled.h" #include "aether/tele/defines.h" #include "aether/tele/modules.h" +#include "aether/tele/sink.h" +#include "aether/tele/tags.h" +#include "aether/tele/traps/io_stream_traps.h" #include "aether/tele/traps/proxy_trap.h" #include "aether/tele/traps/statistics_trap.h" -#include "aether/tele/traps/io_stream_traps.h" -#include "aether/tele/configs/config_provider.h" // IWYU pragma: end_exports -#define SELECTED_SINK ::ae::tele::TeleSink<::ae::tele::ConfigProvider> +#define DEFAULT_SINK ::ae::tele::TeleSink<::ae::tele::AllEnabledConfigProvider> // redefine this macro to use your own sink #ifndef TELE_SINK -# define TELE_SINK SELECTED_SINK +# define TELE_SINK DEFAULT_SINK #endif #endif // AETHER_TELE_TELE_H_ diff --git a/aether/tele/tele_init.h b/aether/tele/tele_init.h index ab07e088..0bbb2f3b 100644 --- a/aether/tele/tele_init.h +++ b/aether/tele/tele_init.h @@ -18,7 +18,7 @@ #define AETHER_TELE_TELE_INIT_H_ // IWYU pragma: begin_keeps -#include "aether/tele/tele.h" +#include "aether/tele.h" #include "aether/tele/traps/tele_statistics.h" // IWYU pragma: end_keeps diff --git a/aether/tele/traps/io_stream_traps.cpp b/aether/tele/traps/io_stream_traps.cpp index b4257b68..f0d9944e 100644 --- a/aether/tele/traps/io_stream_traps.cpp +++ b/aether/tele/traps/io_stream_traps.cpp @@ -134,15 +134,14 @@ void IoStreamTrap::LogLine(Tag const& tag, ILogCollector& log_collector) { void IoStreamTrap::WriteEnvData(EnvData const& env_data) { auto lock = std::scoped_lock{sync_lock_}; - Format( - stream_, - "Platform:{}\nCompiler:{}\nCompiler version:{}\nLibrary version:{}\nApi " - "version:{}\nCPU arch:{}\nEndianness:{}\nUTMid:{}\n", - env_data.platform_type, env_data.compiler, env_data.compiler_version, - env_data.library_version, env_data.api_version, env_data.cpu_arch, - (env_data.endianness == Endianness::Little ? "LittleEndian" - : "BigEndian"), - env_data.utm_id); + Format(stream_, + "Platform:{}\nCompiler:{}\nCompiler version:{}\nLibrary " + "version:{}\nCPU arch:{}\nEndianness:{}\nUTMid:{}\n", + env_data.platform_type, env_data.compiler, env_data.compiler_version, + env_data.library_version, env_data.cpu_arch, + (env_data.endianness == Endianness::Little ? "LittleEndian" + : "BigEndian"), + env_data.utm_id); constexpr auto option_format = FormatScheme{"{}:{}\n"}; for (auto const& opt : env_data.compile_options) { Format(stream_, option_format, opt.name, opt.value); diff --git a/aether/tele/traps/statistics_trap.cpp b/aether/tele/traps/statistics_trap.cpp index fa947954..99c2fcef 100644 --- a/aether/tele/traps/statistics_trap.cpp +++ b/aether/tele/traps/statistics_trap.cpp @@ -121,7 +121,6 @@ void StatisticsTrapBasic::WriteEnvData(EnvData const& env_data) { env_store_.compiler = env_data.compiler; env_store_.compiler_version = env_data.compiler_version; env_store_.library_version = env_data.library_version; - env_store_.api_version = env_data.api_version; env_store_.cpu_arch = env_data.cpu_arch; env_store_.endianness = static_cast(env_data.endianness); env_store_.utm_id = env_data.utm_id; diff --git a/aether/tele/traps/statistics_trap.h b/aether/tele/traps/statistics_trap.h index d1d66086..ca36a2de 100644 --- a/aether/tele/traps/statistics_trap.h +++ b/aether/tele/traps/statistics_trap.h @@ -69,14 +69,13 @@ struct EnvStore { std::string platform; std::string compiler; std::string compiler_version; - std::string api_version; std::string cpu_arch; std::uint8_t endianness; std::uint32_t utm_id; std::vector> compile_options; AE_REFLECT_MEMBERS(library_version, platform, compiler, compiler_version, - api_version, cpu_arch, endianness, utm_id, compile_options) + cpu_arch, endianness, utm_id, compile_options) }; class ILogStorage { diff --git a/aether/tele/traps/tele_statistics.h b/aether/tele/traps/tele_statistics.h index eb132fdf..3f34be6a 100644 --- a/aether/tele/traps/tele_statistics.h +++ b/aether/tele/traps/tele_statistics.h @@ -22,7 +22,7 @@ #include "aether/obj/obj.h" #include "aether/ptr/rc_ptr.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" #include "aether/tele/traps/statistics_trap.h" namespace ae::tele { diff --git a/aether/tele/env/compilation_options.h b/aether/tele_compile_options.h similarity index 73% rename from aether/tele/env/compilation_options.h rename to aether/tele_compile_options.h index 60961103..6ffa3aa6 100644 --- a/aether/tele/env/compilation_options.h +++ b/aether/tele_compile_options.h @@ -1,5 +1,5 @@ /* - * Copyright 2024 Aethernet Inc. + * Copyright 2026 Aethernet Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,69 +14,25 @@ * limitations under the License. */ -#ifndef AETHER_TELE_ENV_COMPILATION_OPTIONS_H_ -#define AETHER_TELE_ENV_COMPILATION_OPTIONS_H_ +#ifndef AETHER_TELE_COMPILE_OPTIONS_H_ +#define AETHER_TELE_COMPILE_OPTIONS_H_ #include -#include -#include #include #include +#include "aether/tele/compile_option.h" + #include "aether/common.h" #include "aether/config.h" -#define _OPTION_VALUE(option, value) \ - std::pair { \ - std::string_view{#option}, std::string_view { STR(value) } \ - } +#define _OPTION_VALUE(option, value) \ + std::pair { std::string_view{#option}, std::string_view{STR(value)}, } #define _OPTION(option) \ std::pair { std::string_view{#option}, std::string_view{VA_STR(option)}, } namespace ae { -// template -// constexpr auto str_to_ui64(char const (&str)[N]) { -// std::uint64_t result = 0; -// std::uint64_t base = 10; -// std::size_t i = 0; - -// if constexpr (N > 2) { -// if (N > 3 && str[0] == '0' && str[1] == 'x') { -// base = 16; -// i = 2; -// } else if (str[0] == '0') { -// base = 8; -// i = 1; -// } else if (str[0] == 'b') { -// base = 2; -// i = 1; -// } -// } - -// for (; i < N; ++i) { -// if ((str[i] >= '0') && (str[i] <= '9')) { -// result = result * base + static_cast(str[i] - '0'); -// } -// if ((base > 10) && (str[i] >= 'a') && (str[i] <= 'f')) { -// result = result * base + static_cast(str[i] - 'a' + 10); -// } -// if ((base > 10) && (str[i] >= 'A') && (str[i] <= 'F')) { -// result = result * base + static_cast(str[i] - 'A' + 10); -// } -// } -// return result; -// } - -// // some tests -// static_assert(str_to_ui64("0") == 0); -// static_assert(str_to_ui64("1") == 1); -// static_assert(str_to_ui64("112") == 112); -// static_assert(str_to_ui64("0xffff") == 65535); -// static_assert(str_to_ui64("0xAaCb") == 0xaacb); -// static_assert(str_to_ui64("042") == 34); -// static_assert(str_to_ui64("b110") == 6); - constexpr inline auto _compile_options_list = std::array{ _OPTION(AE_TASK_MAX_COUNT), _OPTION(AE_TASK_MAX_SIZE), @@ -190,5 +146,18 @@ constexpr inline auto _compile_options_list = std::array{ _OPTION(_AE_REG_CLOUD_IP), #endif }; + +constexpr auto MakeCompileOptions() { + return [](std::index_sequence) noexcept { + return std::array{::ae::tele::CompileOption{ + .index = Is, + .name = _compile_options_list[Is].first, + .value = _compile_options_list[Is].second}...}; + }(std::make_index_sequence<_compile_options_list.size()>()); +} + +static constexpr inline auto kCompileOptions = MakeCompileOptions(); + } // namespace ae -#endif // AETHER_TELE_ENV_COMPILATION_OPTIONS_H_ */ + +#endif // AETHER_TELE_COMPILE_OPTIONS_H_ diff --git a/aether/transport/system_sockets/sockets/lwip_cb_tcp_socket.cpp b/aether/transport/system_sockets/sockets/lwip_cb_tcp_socket.cpp index 18e778e2..9e519a88 100644 --- a/aether/transport/system_sockets/sockets/lwip_cb_tcp_socket.cpp +++ b/aether/transport/system_sockets/sockets/lwip_cb_tcp_socket.cpp @@ -23,7 +23,7 @@ # include "aether/transport/system_sockets/sockets/lwip_get_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { LwipCBTcpSocket::LwipCBTcpSocket(Ptr const&) {} diff --git a/aether/transport/system_sockets/sockets/lwip_cb_udp_socket.cpp b/aether/transport/system_sockets/sockets/lwip_cb_udp_socket.cpp index 28425dd7..d927d93f 100644 --- a/aether/transport/system_sockets/sockets/lwip_cb_udp_socket.cpp +++ b/aether/transport/system_sockets/sockets/lwip_cb_udp_socket.cpp @@ -23,7 +23,7 @@ # include "aether/transport/system_sockets/sockets/lwip_get_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { LwipCBUdpSocket::LwipCBUdpSocket(Ptr const&) {} diff --git a/aether/transport/system_sockets/sockets/lwip_socket.cpp b/aether/transport/system_sockets/sockets/lwip_socket.cpp index d424d96d..e07be5ed 100644 --- a/aether/transport/system_sockets/sockets/lwip_socket.cpp +++ b/aether/transport/system_sockets/sockets/lwip_socket.cpp @@ -20,7 +20,7 @@ # include "lwip/sockets.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { LwipSocket::LwipSocket(IPoller& poller, int socket) diff --git a/aether/transport/system_sockets/sockets/lwip_tcp_socket.cpp b/aether/transport/system_sockets/sockets/lwip_tcp_socket.cpp index 381c9f2e..655f1f94 100644 --- a/aether/transport/system_sockets/sockets/lwip_tcp_socket.cpp +++ b/aether/transport/system_sockets/sockets/lwip_tcp_socket.cpp @@ -23,7 +23,7 @@ # include "aether-miscpp/misc/defer.h" # include "aether/transport/system_sockets/sockets/get_sock_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { namespace lwip_tcp_socket_internal { diff --git a/aether/transport/system_sockets/sockets/lwip_udp_socket.cpp b/aether/transport/system_sockets/sockets/lwip_udp_socket.cpp index 55ef5c8b..6dd58971 100644 --- a/aether/transport/system_sockets/sockets/lwip_udp_socket.cpp +++ b/aether/transport/system_sockets/sockets/lwip_udp_socket.cpp @@ -23,7 +23,7 @@ # include "aether-miscpp/misc/defer.h" # include "aether/transport/system_sockets/sockets/get_sock_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { LwipUdpSocket::LwipUdpSocket(Ptr const& poller) diff --git a/aether/transport/system_sockets/sockets/unix_socket.cpp b/aether/transport/system_sockets/sockets/unix_socket.cpp index 94249294..d2a96069 100644 --- a/aether/transport/system_sockets/sockets/unix_socket.cpp +++ b/aether/transport/system_sockets/sockets/unix_socket.cpp @@ -18,17 +18,17 @@ #if UNIX_SOCKET_ENABLED -# include -# include # include -# include -# include +# include # include # include +# include +# include +# include # include -# include "aether/tele/tele.h" +# include "aether/tele.h" # if not defined MSG_NOSIGNAL # define MSG_NOSIGNAL 0 diff --git a/aether/transport/system_sockets/sockets/unix_tcp_socket.cpp b/aether/transport/system_sockets/sockets/unix_tcp_socket.cpp index 2a774779..1a4a1526 100644 --- a/aether/transport/system_sockets/sockets/unix_tcp_socket.cpp +++ b/aether/transport/system_sockets/sockets/unix_tcp_socket.cpp @@ -18,20 +18,20 @@ #if AE_SUPPORT_TCP && UNIX_SOCKET_ENABLED -# include -# include -# include # include -# include +# include # include # include +# include +# include +# include # include # include "aether-miscpp/misc/defer.h" # include "aether/transport/system_sockets/sockets/get_sock_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" // Workaround for BSD and MacOS # if not defined SOL_TCP and defined IPPROTO_TCP diff --git a/aether/transport/system_sockets/sockets/unix_udp_socket.cpp b/aether/transport/system_sockets/sockets/unix_udp_socket.cpp index 4fa0786c..5ff5af09 100644 --- a/aether/transport/system_sockets/sockets/unix_udp_socket.cpp +++ b/aether/transport/system_sockets/sockets/unix_udp_socket.cpp @@ -17,18 +17,18 @@ #include "aether/transport/system_sockets/sockets/unix_udp_socket.h" #if AE_SUPPORT_UDP && UNIX_SOCKET_ENABLED -# include -# include -# include # include -# include +# include # include # include +# include +# include +# include # include "aether-miscpp/misc/defer.h" # include "aether/transport/system_sockets/sockets/get_sock_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { UnixUdpSocket::UnixUdpSocket(Ptr const& poller) diff --git a/aether/transport/system_sockets/sockets/win_tcp_socket.cpp b/aether/transport/system_sockets/sockets/win_tcp_socket.cpp index 7fbc9d75..f63aa793 100644 --- a/aether/transport/system_sockets/sockets/win_tcp_socket.cpp +++ b/aether/transport/system_sockets/sockets/win_tcp_socket.cpp @@ -18,15 +18,15 @@ #if AE_SUPPORT_TCP && defined WIN_SOCKET_ENABLED +# include # include # include # include -# include # include "aether-miscpp/misc/defer.h" # include "aether/transport/system_sockets/sockets/get_sock_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { namespace win_socket_internal { diff --git a/aether/transport/system_sockets/sockets/win_udp_socket.cpp b/aether/transport/system_sockets/sockets/win_udp_socket.cpp index 292f5332..86489d8a 100644 --- a/aether/transport/system_sockets/sockets/win_udp_socket.cpp +++ b/aether/transport/system_sockets/sockets/win_udp_socket.cpp @@ -24,7 +24,7 @@ # include "aether-miscpp/misc/defer.h" # include "aether/transport/system_sockets/sockets/get_sock_addr.h" -# include "aether/tele/tele.h" +# include "aether/tele.h" namespace ae { WinUdpSocket::WinUdpSocket(Ptr const& poller) diff --git a/aether/transport/transport_tele.h b/aether/transport/transport_tele.h index 532058a4..44efd3c7 100644 --- a/aether/transport/transport_tele.h +++ b/aether/transport/transport_tele.h @@ -17,7 +17,7 @@ #ifndef AETHER_TRANSPORT_TRANSPORT_TELE_H_ #define AETHER_TRANSPORT_TRANSPORT_TELE_H_ -#include "aether/tele/tele.h" +#include "aether/tele.h" AE_TELE_MODULE(kTransport, 4, 51, 100); AE_TELE_MODULE(kTransportDebug, 104, 400, 445); diff --git a/aether/work_cloud_api/client_api/client_api_safe.cpp b/aether/work_cloud_api/client_api/client_api_safe.cpp index d25e6bda..5f36082d 100644 --- a/aether/work_cloud_api/client_api/client_api_safe.cpp +++ b/aether/work_cloud_api/client_api/client_api_safe.cpp @@ -20,7 +20,7 @@ #include "aether/api_protocol/api_protocol.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { diff --git a/aether/work_cloud_api/client_api/client_api_unsafe.cpp b/aether/work_cloud_api/client_api/client_api_unsafe.cpp index 2e291a9e..7bb23793 100644 --- a/aether/work_cloud_api/client_api/client_api_unsafe.cpp +++ b/aether/work_cloud_api/client_api/client_api_unsafe.cpp @@ -16,7 +16,7 @@ #include "aether/work_cloud_api/client_api/client_api_unsafe.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { ClientApiUnsafe::ClientApiUnsafe(ProtocolContext& protocol_context, diff --git a/aether/work_cloud_api/work_server_api/login_api.cpp b/aether/work_cloud_api/work_server_api/login_api.cpp index 6d6a248c..07e45bc1 100644 --- a/aether/work_cloud_api/work_server_api/login_api.cpp +++ b/aether/work_cloud_api/work_server_api/login_api.cpp @@ -16,7 +16,7 @@ #include "aether/work_cloud_api/work_server_api/login_api.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { LoginApi::LoginApi(ProtocolContext& protocol_context, diff --git a/aether/write_action/buffer_write.h b/aether/write_action/buffer_write.h index d2c7bd59..12ef6215 100644 --- a/aether/write_action/buffer_write.h +++ b/aether/write_action/buffer_write.h @@ -32,7 +32,7 @@ DISABLE_WARNING_POP() #include "aether/write_action/write_action.h" #if DEBUG // include tele only in debug mode -# include "aether/tele/tele.h" +# include "aether/tele.h" #endif namespace ae { diff --git a/examples/benches/send_message_delays/receiver.cpp b/examples/benches/send_message_delays/receiver.cpp index c7c915b5..f9bb1eee 100644 --- a/examples/benches/send_message_delays/receiver.cpp +++ b/examples/benches/send_message_delays/receiver.cpp @@ -25,7 +25,7 @@ #include "send_message_delays/api/bench_delays_api.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { Receiver::Receiver(AeContext const& ae_context, Client::ptr client, diff --git a/examples/benches/send_message_delays/send_message_delays_manager.cpp b/examples/benches/send_message_delays/send_message_delays_manager.cpp index 8da95135..7b605c9e 100644 --- a/examples/benches/send_message_delays/send_message_delays_manager.cpp +++ b/examples/benches/send_message_delays/send_message_delays_manager.cpp @@ -18,7 +18,7 @@ #include -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { SendMessageDelaysManager::TestAction::TestAction( diff --git a/examples/benches/send_message_delays/sender.cpp b/examples/benches/send_message_delays/sender.cpp index 9b1bcbef..a950beb4 100644 --- a/examples/benches/send_message_delays/sender.cpp +++ b/examples/benches/send_message_delays/sender.cpp @@ -19,11 +19,11 @@ #include #include "aether/api_protocol/api_context.h" -#include "aether/stream_api/api_call_adapter.h" #include "aether/client_messages/p2p_message_stream.h" #include "aether/client_messages/p2p_safe_message_stream.h" +#include "aether/stream_api/api_call_adapter.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" #include "send_message_delays/api/bench_delays_api.h" @@ -40,8 +40,7 @@ Sender::Sender(AeContext const& ae_context, Client::ptr client, void Sender::ConnectP2pStream() { AE_TELED_DEBUG("Sender::ConnectP2pStream()"); - auto handle = - client_->message_stream_manager().CreatePort(destination_uid_); + auto handle = client_->message_stream_manager().CreatePort(destination_uid_); send_message_stream_ = std::make_shared( ae_context_, client_.Load(), destination_uid_, std::move(handle)); connected_stream_ = send_message_stream_.get(); @@ -49,8 +48,7 @@ void Sender::ConnectP2pStream() { void Sender::ConnectP2pSafeStream() { AE_TELED_DEBUG("Sender::ConnectP2pSafeStream()"); - auto handle = - client_->message_stream_manager().CreatePort(destination_uid_); + auto handle = client_->message_stream_manager().CreatePort(destination_uid_); auto p2p_stream = std::make_shared( ae_context_, client_.Load(), destination_uid_, std::move(handle)); send_message_safe_stream_ = make_unique( diff --git a/examples/benches/send_message_delays/timed_receiver.cpp b/examples/benches/send_message_delays/timed_receiver.cpp index 07b21738..a7ca34c9 100644 --- a/examples/benches/send_message_delays/timed_receiver.cpp +++ b/examples/benches/send_message_delays/timed_receiver.cpp @@ -16,7 +16,7 @@ #include "send_message_delays/timed_receiver.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { TimedReceiver::TimedReceiver(AeContext const& ae_context, diff --git a/examples/benches/send_message_delays/timed_sender.cpp b/examples/benches/send_message_delays/timed_sender.cpp index 475f5d84..39b29068 100644 --- a/examples/benches/send_message_delays/timed_sender.cpp +++ b/examples/benches/send_message_delays/timed_sender.cpp @@ -16,7 +16,7 @@ #include "send_message_delays/timed_sender.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { TimedSender::TimedSender(AeContext const& ae_context, diff --git a/examples/benches/send_messages_bandwidth/common/test_action.h b/examples/benches/send_messages_bandwidth/common/test_action.h index e5d58d74..36b89f4a 100644 --- a/examples/benches/send_messages_bandwidth/common/test_action.h +++ b/examples/benches/send_messages_bandwidth/common/test_action.h @@ -17,18 +17,18 @@ #ifndef EXAMPLES_BENCHES_SEND_MESSAGES_BANDWIDTH_COMMON_TEST_ACTION_H_ #define EXAMPLES_BENCHES_SEND_MESSAGES_BANDWIDTH_COMMON_TEST_ACTION_H_ -#include #include +#include -#include "aether/ae_context.h" #include "aether-miscpp/types/result.h" +#include "aether/ae_context.h" +#include "aether/events/event_subscription.h" #include "aether/events/events.h" #include "aether/executors/executors.h" -#include "aether/events/event_subscription.h" #include "send_messages_bandwidth/common/bandwidth.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { template diff --git a/examples/benches/send_messages_bandwidth/receiver/message_receiver.cpp b/examples/benches/send_messages_bandwidth/receiver/message_receiver.cpp index 2314b3d0..e942db16 100644 --- a/examples/benches/send_messages_bandwidth/receiver/message_receiver.cpp +++ b/examples/benches/send_messages_bandwidth/receiver/message_receiver.cpp @@ -16,7 +16,7 @@ #include "send_messages_bandwidth/receiver/message_receiver.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { MessageReceiver::MessageReceiver(AeContext const& ae_context) diff --git a/examples/benches/send_messages_bandwidth/receiver/receiver.cpp b/examples/benches/send_messages_bandwidth/receiver/receiver.cpp index d4cdaac4..3f112e33 100644 --- a/examples/benches/send_messages_bandwidth/receiver/receiver.cpp +++ b/examples/benches/send_messages_bandwidth/receiver/receiver.cpp @@ -16,10 +16,10 @@ #include "send_messages_bandwidth/receiver/receiver.h" -#include "aether/stream_api/api_call_adapter.h" #include "aether/client_messages/p2p_message_stream.h" +#include "aether/stream_api/api_call_adapter.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { Receiver::Receiver(AeContext const& ae_context, Client::ptr client) diff --git a/examples/benches/send_messages_bandwidth/receiver/receiver_main.cpp b/examples/benches/send_messages_bandwidth/receiver/receiver_main.cpp index 53631260..5e686a6d 100644 --- a/examples/benches/send_messages_bandwidth/receiver/receiver_main.cpp +++ b/examples/benches/send_messages_bandwidth/receiver/receiver_main.cpp @@ -18,10 +18,10 @@ #include "aether/all.h" -#include "send_messages_bandwidth/receiver/receiver.h" #include "send_messages_bandwidth/common/test_action.h" +#include "send_messages_bandwidth/receiver/receiver.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { diff --git a/examples/benches/send_messages_bandwidth/sender/message_sender.cpp b/examples/benches/send_messages_bandwidth/sender/message_sender.cpp index 3650c850..3e1e0eac 100644 --- a/examples/benches/send_messages_bandwidth/sender/message_sender.cpp +++ b/examples/benches/send_messages_bandwidth/sender/message_sender.cpp @@ -16,7 +16,7 @@ #include "send_messages_bandwidth/sender/message_sender.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { diff --git a/examples/benches/send_messages_bandwidth/sender/sender.cpp b/examples/benches/send_messages_bandwidth/sender/sender.cpp index 8c1c5ba8..58397922 100644 --- a/examples/benches/send_messages_bandwidth/sender/sender.cpp +++ b/examples/benches/send_messages_bandwidth/sender/sender.cpp @@ -17,10 +17,10 @@ #include "send_messages_bandwidth/sender/sender.h" #include "aether/api_protocol/api_context.h" -#include "aether/stream_api/api_call_adapter.h" #include "aether/client_messages/p2p_message_stream.h" +#include "aether/stream_api/api_call_adapter.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { Sender::Sender(AeContext const& ae_context, Client::ptr client, Uid destination) @@ -32,8 +32,7 @@ Sender::Sender(AeContext const& ae_context, Client::ptr client, Uid destination) EventSubscriber Sender::error_event() { return error_event_; } void Sender::Connect() { - auto handle = - client_->message_stream_manager().CreatePort(destination_); + auto handle = client_->message_stream_manager().CreatePort(destination_); message_stream_ = std::make_shared( ae_context_, client_.Load(), destination_, std::move(handle)); diff --git a/examples/benches/send_messages_bandwidth/sender/sender_main.cpp b/examples/benches/send_messages_bandwidth/sender/sender_main.cpp index 3ec044df..ca1ef1a3 100644 --- a/examples/benches/send_messages_bandwidth/sender/sender_main.cpp +++ b/examples/benches/send_messages_bandwidth/sender/sender_main.cpp @@ -18,10 +18,10 @@ #include "aether/all.h" -#include "send_messages_bandwidth/sender/sender.h" #include "send_messages_bandwidth/common/test_action.h" +#include "send_messages_bandwidth/sender/sender.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae::bench { static constexpr auto kTestUid = diff --git a/examples/cloud/main.cpp b/examples/cloud/main.cpp index fec5e656..de7122cf 100644 --- a/examples/cloud/main.cpp +++ b/examples/cloud/main.cpp @@ -31,7 +31,7 @@ */ #include "aether/config.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" #include "aether/tele/tele_init.h" #if (defined(CM_ESP32)) diff --git a/tests/test-safe-stream/mock_bad_streams.cpp b/tests/test-safe-stream/mock_bad_streams.cpp index 85ab353d..bac38737 100644 --- a/tests/test-safe-stream/mock_bad_streams.cpp +++ b/tests/test-safe-stream/mock_bad_streams.cpp @@ -18,7 +18,7 @@ #include -#include "aether/tele/tele.h" +#include "aether/tele.h" namespace ae { namespace bad_streams_internal { diff --git a/tests/test-safe-stream/test_safe_stream_reliability.cpp b/tests/test-safe-stream/test_safe_stream_reliability.cpp index d9998684..103a0738 100644 --- a/tests/test-safe-stream/test_safe_stream_reliability.cpp +++ b/tests/test-safe-stream/test_safe_stream_reliability.cpp @@ -23,13 +23,13 @@ #include "aether/safe_stream/safe_stream.h" -#include "aether/tele/tele.h" +#include "aether/tele.h" -#include "tests/test-stream/to_data_buffer.h" #include "tests/test-stream/mock_write_stream.h" +#include "tests/test-stream/to_data_buffer.h" -#include "stream-test-ctx.h" #include "mock_bad_streams.h" +#include "stream-test-ctx.h" namespace ae::test_safe_stream_reliability { constexpr auto config = SafeStreamConfig{ diff --git a/tests/test-tele/test-tele.cpp b/tests/test-tele/test-tele.cpp index 90ff41dc..128bfe81 100644 --- a/tests/test-tele/test-tele.cpp +++ b/tests/test-tele/test-tele.cpp @@ -48,8 +48,6 @@ #define AETHER_TELE_TELE_H_ -#include "aether-miscpp/meta/type_list.h" - #include "aether/tele/collectors.h" #include "aether/tele/defines.h" #include "aether/tele/env_collectors.h" @@ -57,13 +55,13 @@ #include "aether/tele/sink.h" #include "aether/tele/tags.h" -#include "aether/tele/configs/config_provider.h" +#include "aether/tele/configs/all_enabled.h" #include "aether/tele/traps/io_stream_traps.h" #include "aether/tele/traps/proxy_trap.h" #include "aether/tele/traps/statistics_trap.h" -using SinkType = ae::tele::TeleSink; +using SinkType = ae::tele::TeleSink; #define TELE_SINK SinkType static std::shared_ptr trap; @@ -199,37 +197,26 @@ struct TeleTrap final : public ITrap { std::map metric_data_; }; -template + bool TagName = true, bool Blob = true> struct ConfigProvider { - template + template struct TeleConfig { - static constexpr bool kCountMetrics = ArgAt_v<0, args...>; - static constexpr bool kTimeMetrics = ArgAt_v<1, args...>; - static constexpr bool kIndexLogs = ArgAt_v<2, args...>; - static constexpr bool kStartTimeLogs = ArgAt_v<3, args...>; - static constexpr bool kLevelModuleLogs = ArgAt_v<4, args...>; - static constexpr bool kLocationLogs = ArgAt_v<5, args...>; - static constexpr bool kNameLogs = ArgAt_v<6, args...>; - static constexpr bool kBlobLogs = ArgAt_v<7, args...>; + static constexpr bool kCountMetrics = Count; + static constexpr bool kTimeMetrics = Time; + static constexpr bool kLogsEnabled = LogsEnabled; + static constexpr bool kStartTimeLogs = StartTime; + static constexpr bool kLevelModuleLogs = LevelModule; + static constexpr bool kLocationLogs = Location; + static constexpr bool kNameLogs = TagName; + static constexpr bool kBlobLogs = Blob; }; - template struct EnvConfig { - static constexpr bool kCompiler = ArgAt_v<0, args...>; - static constexpr bool kPlatformType = ArgAt_v<1, args...>; - static constexpr bool kCompilationOptions = ArgAt_v<2, args...>; - static constexpr bool kLibraryVersion = ArgAt_v<3, args...>; - static constexpr bool kApiVersion = ArgAt_v<4, args...>; - static constexpr bool kCpuType = ArgAt_v<5, args...>; + static constexpr bool kStaticInfo = true; + static constexpr bool kRuntimeInfo = true; }; - - template - using StaticTeleConfig = TeleConfig; - - using StaticEnvConfig = EnvConfig; }; } // namespace tele_configuration @@ -309,14 +296,6 @@ void test_TeleConfigurations() { false, false, false, false, false, false, false, false>>; auto tele_trap = std::make_shared(); - TEST_ASSERT(tele_trap->log_lines_.empty()); - } - { - // nothing - using Sink = TeleSink>; - auto tele_trap = std::make_shared(); - Sink::Instance().SetTrap(tele_trap); { auto t = Tele>{ @@ -500,16 +479,16 @@ void test_SaveLoadTeleStatistics() { // simple check with _AE_MODULE_CONFIG leads here to AST broken error for // cppcheck constexpr bool time_metrics_enabled = - TELE_SINK::ConfigProviderType::StaticTeleConfig::kTimeMetrics; + TELE_SINK::ConfigProviderType::TeleConfig::kTimeMetrics; if constexpr (time_metrics_enabled) { TEST_ASSERT_EQUAL(metrics1.at(log_index).sum_duration, metrics2.at(log_index).sum_duration); } constexpr bool count_metrics_enabled = - TELE_SINK::ConfigProviderType::StaticTeleConfig::kCountMetrics; + TELE_SINK::ConfigProviderType::TeleConfig::kCountMetrics; if constexpr (count_metrics_enabled) { TEST_ASSERT_EQUAL(metrics1.at(log_index).invocations_count, diff --git a/third_party/libsodium_unit_tests/libsodium_unit_tests.cpp b/third_party/libsodium_unit_tests/libsodium_unit_tests.cpp index 309a96d6..99c9f377 100644 --- a/third_party/libsodium_unit_tests/libsodium_unit_tests.cpp +++ b/third_party/libsodium_unit_tests/libsodium_unit_tests.cpp @@ -16,7 +16,7 @@ #include "libsodium_unit_tests.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" #include "libsodium_ut_aead_aegis128l.h" #include "libsodium_ut_aead_aegis256.h" #include "libsodium_ut_aead_aes256gcm.h" @@ -114,7 +114,7 @@ static const char *TAG = "HYDROGEN UNITY"; -#if DEBUG_OUT==1 +#if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) @@ -132,7 +132,7 @@ int libsodium_unit_tests_runner() UNITY_BEGIN(); DebugPrint("Starting libsodium unit tests."); - + RUN_TEST(aead_aegis128l::_libsodium_ut_aead_aegis128l); RUN_TEST(aead_aegis256::_libsodium_ut_aead_aegis256); RUN_TEST(aead_aes256gcm::_libsodium_ut_aead_aes256gcm); diff --git a/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis128l.cpp b/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis128l.cpp index 01ad0c86..6843ec13 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis128l.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis128l.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_aead_aegis128l.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace aead_aegis128l { @@ -17,7 +17,7 @@ namespace aead_aegis128l static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) @@ -25,7 +25,7 @@ namespace aead_aegis128l #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - static int + static int tv(void) { unsigned char *ad; @@ -167,4 +167,4 @@ namespace aead_aegis128l assert(crypto_aead_aegis128l_abytes() == crypto_aead_aegis128l_ABYTES); assert(crypto_aead_aegis128l_messagebytes_max() == crypto_aead_aegis128l_MESSAGEBYTES_MAX); } -} //namespace aead_aegis128l \ No newline at end of file +} //namespace aead_aegis128l diff --git a/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis256.cpp b/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis256.cpp index 76e8482a..d6aaca5d 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis256.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_aead_aegis256.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_aead_aegis256.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace aead_aegis256 { @@ -17,7 +17,7 @@ namespace aead_aegis256 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm.cpp b/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm.cpp index 28102e60..c69c92ee 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_aead_aes256gcm.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace aead_aes256gcm { @@ -17,7 +17,7 @@ namespace aead_aes256gcm static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) @@ -272,4 +272,4 @@ namespace aead_aes256gcm assert(crypto_aead_aes256gcm_messagebytes_max() == crypto_aead_aes256gcm_MESSAGEBYTES_MAX); } -} //namespace aead_aes256gcm \ No newline at end of file +} //namespace aead_aes256gcm diff --git a/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm2.cpp index a4ecbc70..90970044 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_aead_aes256gcm2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_aead_aes256gcm2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace aead_aes256gcm2 { @@ -17,7 +17,7 @@ namespace aead_aes256gcm2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly1305.cpp b/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly1305.cpp index 88904252..e7f0f801 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly1305.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly1305.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_aead_chacha20poly1305.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace aead_chacha20poly1305 { @@ -17,7 +17,7 @@ namespace aead_chacha20poly1305 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly13052.cpp b/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly13052.cpp index cee2d503..c417a9b9 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly13052.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_aead_chacha20poly13052.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_aead_chacha20poly13052.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace aead_chacha20poly13052 { @@ -17,7 +17,7 @@ namespace aead_chacha20poly13052 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_aead_xchacha20poly1305.cpp b/third_party/libsodium_unit_tests/libsodium_ut_aead_xchacha20poly1305.cpp index 65142831..20af1774 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_aead_xchacha20poly1305.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_aead_xchacha20poly1305.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_aead_chacha20poly1305.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace aead_xchacha20poly1305 { @@ -17,7 +17,7 @@ namespace aead_xchacha20poly1305 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_auth.cpp b/third_party/libsodium_unit_tests/libsodium_ut_auth.cpp index 5d9cdc16..dcd7ab17 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_auth.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_auth.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_auth.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace auth { @@ -17,7 +17,7 @@ namespace auth static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_auth2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_auth2.cpp index 39c59cca..bb63360c 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_auth2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_auth2.cpp @@ -2,7 +2,7 @@ /* "Test Case AUTH256-4" from RFC 4868 */ #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace auth2 { @@ -18,7 +18,7 @@ namespace auth2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_auth3.cpp b/third_party/libsodium_unit_tests/libsodium_ut_auth3.cpp index 06c0d205..60bcafcd 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_auth3.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_auth3.cpp @@ -2,7 +2,7 @@ /* "Test Case AUTH256-4" from RFC 4868 */ #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace auth3 { @@ -18,7 +18,7 @@ namespace auth3 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) @@ -43,4 +43,4 @@ namespace auth3 { test(); } -} // namespace auth3 \ No newline at end of file +} // namespace auth3 diff --git a/third_party/libsodium_unit_tests/libsodium_ut_auth5.cpp b/third_party/libsodium_unit_tests/libsodium_ut_auth5.cpp index 02f60685..cfe72509 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_auth5.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_auth5.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_auth5.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace auth5 { @@ -17,7 +17,7 @@ namespace auth5 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_auth6.cpp b/third_party/libsodium_unit_tests/libsodium_ut_auth6.cpp index ba3958d6..1c803873 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_auth6.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_auth6.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_auth6.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace auth6 { @@ -17,7 +17,7 @@ namespace auth6 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) @@ -43,4 +43,4 @@ namespace auth6 { test(); } -} // namespace auth6 \ No newline at end of file +} // namespace auth6 diff --git a/third_party/libsodium_unit_tests/libsodium_ut_auth7.cpp b/third_party/libsodium_unit_tests/libsodium_ut_auth7.cpp index d2d2c80e..cba91a58 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_auth7.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_auth7.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_auth7.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace auth7 { @@ -17,7 +17,7 @@ namespace auth7 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box.cpp index 5f6c56b1..ec125fb0 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box { @@ -17,7 +17,7 @@ namespace box static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box2.cpp index 040d19a0..b299a6eb 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box2 { @@ -17,7 +17,7 @@ namespace box2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box7.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box7.cpp index 5197f13e..2280160c 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box7.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box7.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box7.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box7 { @@ -17,7 +17,7 @@ namespace box7 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) @@ -65,7 +65,7 @@ test(void) return 0; } - + void _libsodium_ut_box7() { test(); diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box8.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box8.cpp index bc4a1de8..97383c4d 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box8.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box8.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box8.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box8 { @@ -17,14 +17,14 @@ namespace box8 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box_easy.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box_easy.cpp index 67b9ab63..f0df2228 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box_easy.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box_easy.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box_easy.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box_easy { @@ -17,7 +17,7 @@ namespace box_easy static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box_easy2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box_easy2.cpp index 63253955..4c17afa7 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box_easy2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box_easy2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box_easy2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box_easy2 { @@ -17,7 +17,7 @@ namespace box_easy2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box_seal.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box_seal.cpp index 67b1ceb2..9c45d2b0 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box_seal.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box_seal.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box_seal.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box_seal { @@ -17,7 +17,7 @@ namespace box_seal static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_box_seed.cpp b/third_party/libsodium_unit_tests/libsodium_ut_box_seed.cpp index d368e77f..e65a388b 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_box_seed.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_box_seed.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_box_seed.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace box_seed { @@ -17,7 +17,7 @@ namespace box_seed static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) diff --git a/third_party/libsodium_unit_tests/libsodium_ut_chacha20.cpp b/third_party/libsodium_unit_tests/libsodium_ut_chacha20.cpp index 1fc74514..86aec0cc 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_chacha20.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_chacha20.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_chacha20.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace chacha20 { @@ -17,14 +17,14 @@ namespace chacha20 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv(void) { @@ -207,7 +207,7 @@ namespace chacha20 return 0; } - + void _libsodium_ut_chacha20() { test(); diff --git a/third_party/libsodium_unit_tests/libsodium_ut_codecs.cpp b/third_party/libsodium_unit_tests/libsodium_ut_codecs.cpp index 25348792..5e31df82 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_codecs.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_codecs.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_codecs.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace codecs { @@ -17,14 +17,14 @@ namespace codecs static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { @@ -273,9 +273,9 @@ namespace codecs } return 0; } - + void _libsodium_ut_codecs() { test(); } -} // namespace codecs \ No newline at end of file +} // namespace codecs diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core1.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core1.cpp index ea11e414..710a7b49 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core1.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core1.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core1.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core1 { @@ -17,14 +17,14 @@ namespace core1 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core2.cpp index 307806ee..04f225cc 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core2 { @@ -17,14 +17,14 @@ namespace core2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core3.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core3.cpp index 164fcd6c..f1d4cbcc 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core3.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core3.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core3.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core3 { @@ -17,14 +17,14 @@ namespace core3 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core4.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core4.cpp index b99c6846..03d9aef3 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core4.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core4.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core4.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core4 { @@ -17,14 +17,14 @@ namespace core4 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core5.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core5.cpp index cf52401b..922e9ce6 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core5.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core5.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core5.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core5 { @@ -17,14 +17,14 @@ namespace core5 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core6.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core6.cpp index 20f98ebe..93717419 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core6.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core6.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core6.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core6 { @@ -17,14 +17,14 @@ namespace core6 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void print(unsigned char *x, unsigned char *y) { @@ -58,7 +58,7 @@ namespace core6 return 0; } - + void _libsodium_ut_core6() { test(); diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519.cpp index 71692dd1..578193f1 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core_ed25519.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core_ed25519 { @@ -17,14 +17,14 @@ namespace core_ed25519 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void add_P(unsigned char * const S) { @@ -534,7 +534,7 @@ namespace core_ed25519 return 0; } - + void _libsodium_ut_core_ed25519() { test(); diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519_h2c.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519_h2c.cpp index 18621588..ab1439a3 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519_h2c.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core_ed25519_h2c.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core_ed25519_h2c.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core_ed25519_h2c { @@ -17,14 +17,14 @@ namespace core_ed25519_h2c static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { @@ -114,4 +114,4 @@ namespace core_ed25519_h2c { test(); } -} // namespace core_ed25519 \ No newline at end of file +} // namespace core_ed25519 diff --git a/third_party/libsodium_unit_tests/libsodium_ut_core_ristretto255.cpp b/third_party/libsodium_unit_tests/libsodium_ut_core_ristretto255.cpp index 9eda3523..3cccf11d 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_core_ristretto255.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_core_ristretto255.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_core_ristretto255.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace core_ristretto255 { @@ -17,14 +17,14 @@ namespace core_ristretto255 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv1(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_ed25519_convert.cpp b/third_party/libsodium_unit_tests/libsodium_ut_ed25519_convert.cpp index db9d8347..97034754 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_ed25519_convert.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_ed25519_convert.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_ed25519_convert.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace ed25519_convert { @@ -17,14 +17,14 @@ namespace ed25519_convert static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_generichash.cpp b/third_party/libsodium_unit_tests/libsodium_ut_generichash.cpp index a853e0e4..e4a6784f 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_generichash.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_generichash.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_generichash.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace generichash { @@ -17,14 +17,14 @@ namespace generichash static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static int tv(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_generichash2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_generichash2.cpp index 1bb88328..0ee1562e 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_generichash2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_generichash2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_generichash2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace generichash2 { @@ -17,14 +17,14 @@ namespace generichash2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_generichash3.cpp b/third_party/libsodium_unit_tests/libsodium_ut_generichash3.cpp index adc740b1..34e02461 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_generichash3.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_generichash3.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_generichash3.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace generichash3 { @@ -17,14 +17,14 @@ namespace generichash3 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_hash.cpp b/third_party/libsodium_unit_tests/libsodium_ut_hash.cpp index f67d4a53..813ea7b1 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_hash.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_hash.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_hash.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace hash { @@ -17,14 +17,14 @@ namespace hash static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_hash3.cpp b/third_party/libsodium_unit_tests/libsodium_ut_hash3.cpp index 150863ac..eee9bdad 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_hash3.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_hash3.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_hash3.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace hash3 { @@ -17,14 +17,14 @@ namespace hash3 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_kdf.cpp b/third_party/libsodium_unit_tests/libsodium_ut_kdf.cpp index 9f0e5031..1a609fa3 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_kdf.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_kdf.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_kdf.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace kdf { @@ -17,14 +17,14 @@ namespace kdf static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv_kdf(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_kdf_hkdf.cpp b/third_party/libsodium_unit_tests/libsodium_ut_kdf_hkdf.cpp index cb6a1d99..ada07454 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_kdf_hkdf.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_kdf_hkdf.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_kdf_hkdf.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace kdf_hkdf { @@ -17,14 +17,14 @@ namespace kdf_hkdf static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv_kdf_hkdf(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_keygen.cpp b/third_party/libsodium_unit_tests/libsodium_ut_keygen.cpp index d74122d9..595e1374 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_keygen.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_keygen.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_keygen.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace keygen { @@ -17,14 +17,14 @@ namespace keygen static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv_keygen(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_kx.cpp b/third_party/libsodium_unit_tests/libsodium_ut_kx.cpp index 58472549..0586dbb2 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_kx.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_kx.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_kx.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace kx { @@ -17,14 +17,14 @@ namespace kx static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv_kx(void) { @@ -169,4 +169,4 @@ namespace kx { test(); } -} // namespace \ No newline at end of file +} // namespace diff --git a/third_party/libsodium_unit_tests/libsodium_ut_metamorphic.cpp b/third_party/libsodium_unit_tests/libsodium_ut_metamorphic.cpp index d76b333f..425704e2 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_metamorphic.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_metamorphic.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_metamorphic.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace metamorphic { @@ -17,14 +17,14 @@ namespace metamorphic static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void mm_generichash(void) { @@ -210,4 +210,4 @@ namespace metamorphic { test(); } -} // namespace \ No newline at end of file +} // namespace diff --git a/third_party/libsodium_unit_tests/libsodium_ut_misuse.cpp b/third_party/libsodium_unit_tests/libsodium_ut_misuse.cpp index 28ca2f57..67879c9d 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_misuse.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_misuse.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_misuse.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace misuse { @@ -17,20 +17,20 @@ namespace misuse static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + #ifdef HAVE_CATCHABLE_ABRT # include #ifndef _WIN32 # include #endif - + static void sigabrt_handler_15(int sig) { @@ -214,4 +214,3 @@ namespace misuse test(); } } // namespace - diff --git a/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth.cpp b/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth.cpp index 4650354f..50183a29 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_onetimeauth.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace onetimeauth { @@ -17,14 +17,14 @@ namespace onetimeauth static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth2.cpp index 25af6519..7cd07bac 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_onetimeauth2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace onetimeauth2 { @@ -17,14 +17,14 @@ namespace onetimeauth2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth7.cpp b/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth7.cpp index 233c5a35..556fff49 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth7.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_onetimeauth7.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_onetimeauth7.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace onetimeauth7 { @@ -17,14 +17,14 @@ namespace onetimeauth7 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2i.cpp b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2i.cpp index 87c6a631..58cab4e9 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2i.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2i.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_pwhash_argon2i.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace pwhash_argon2i { @@ -17,14 +17,14 @@ namespace pwhash_argon2i static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2id.cpp b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2id.cpp index 51514523..0c37d075 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2id.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_argon2id.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_pwhash_argon2id.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace pwhash_argon2id { @@ -17,14 +17,14 @@ namespace pwhash_argon2id static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt.cpp b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt.cpp index 878ba80c..91fe99ca 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_pwhash_scrypt.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace pwhash_scrypt { @@ -17,14 +17,14 @@ namespace pwhash_scrypt static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt_ll.cpp b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt_ll.cpp index 42f8bbc4..72433b90 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt_ll.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_pwhash_scrypt_ll.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_pwhash_scrypt_ll.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace pwhash_scrypt_ll { @@ -17,14 +17,14 @@ namespace pwhash_scrypt_ll static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv(const char *passwd, const char *salt, uint64_t N, uint32_t r, uint32_t p) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_randombytes.cpp b/third_party/libsodium_unit_tests/libsodium_ut_randombytes.cpp index bf7ea7d6..0b8d873b 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_randombytes.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_randombytes.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_randombytes.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace randombytes_sodium { @@ -17,14 +17,14 @@ namespace randombytes_sodium static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static int compat_tests(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult.cpp index fd6428b2..c8729392 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult { @@ -17,14 +17,14 @@ namespace scalarmult static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult2.cpp index d8ee5ac0..fbb0847c 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult2 { @@ -17,14 +17,14 @@ namespace scalarmult2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult5.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult5.cpp index 32096014..0c7d5ae0 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult5.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult5.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult5.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult5 { @@ -17,14 +17,14 @@ namespace scalarmult5 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult6.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult6.cpp index 8bd87ff0..62cfa7d8 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult6.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult6.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult6.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult6 { @@ -17,14 +17,14 @@ namespace scalarmult6 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult7.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult7.cpp index bb16f875..7d0643a2 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult7.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult7.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult7.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult7 { @@ -17,14 +17,14 @@ namespace scalarmult7 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult8.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult8.cpp index 37a057ff..e9dd0026 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult8.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult8.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult8.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult8 { @@ -17,14 +17,14 @@ namespace scalarmult8 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ed25519.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ed25519.cpp index 622ebff6..88e05794 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ed25519.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ed25519.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult_ed25519.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult_ed25519 { @@ -17,14 +17,14 @@ namespace scalarmult_ed25519 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ristretto255.cpp b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ristretto255.cpp index 027e822c..ef4f2c04 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ristretto255.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_scalarmult_ristretto255.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_scalarmult_ristretto255.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace scalarmult_ristretto255 { @@ -17,14 +17,14 @@ namespace scalarmult_ristretto255 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_secretbox.cpp b/third_party/libsodium_unit_tests/libsodium_ut_secretbox.cpp index 941df635..fe37d0bd 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_secretbox.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_secretbox.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_secretbox.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace secretbox { @@ -17,14 +17,14 @@ namespace secretbox static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_secretbox2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_secretbox2.cpp index 12f3921f..3a441be8 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_secretbox2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_secretbox2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_secretbox2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace secretbox2 { @@ -17,14 +17,14 @@ namespace secretbox2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_secretbox7.cpp b/third_party/libsodium_unit_tests/libsodium_ut_secretbox7.cpp index 27946651..83a1c806 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_secretbox7.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_secretbox7.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_secretbox7.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace secretbox7 { @@ -17,14 +17,14 @@ namespace secretbox7 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_secretbox8.cpp b/third_party/libsodium_unit_tests/libsodium_ut_secretbox8.cpp index 9c791919..e6f420c3 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_secretbox8.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_secretbox8.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_secretbox8.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace secretbox8 { @@ -17,14 +17,14 @@ namespace secretbox8 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy.cpp b/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy.cpp index 072bbcde..66bb6342 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_secretbox_easy.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace secretbox_easy { @@ -17,14 +17,14 @@ namespace secretbox_easy static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { @@ -125,4 +125,4 @@ namespace secretbox_easy { test(); } -} // namespace \ No newline at end of file +} // namespace diff --git a/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy2.cpp index ffaedf59..1a98fa16 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_secretbox_easy2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_secretbox_easy2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace secretbox_easy2 { @@ -17,14 +17,14 @@ namespace secretbox_easy2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_secretstream_xchacha20poly1305.cpp b/third_party/libsodium_unit_tests/libsodium_ut_secretstream_xchacha20poly1305.cpp index 8ee76661..954d610a 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_secretstream_xchacha20poly1305.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_secretstream_xchacha20poly1305.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_secretstream_xchacha20poly1305.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace secretstream_xchacha20poly1305 { @@ -17,14 +17,14 @@ namespace secretstream_xchacha20poly1305 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_shorthash.cpp b/third_party/libsodium_unit_tests/libsodium_ut_shorthash.cpp index 6df72669..abbaa53a 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_shorthash.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_shorthash.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_shorthash.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace shorthash { @@ -17,14 +17,14 @@ namespace shorthash static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_sign.cpp b/third_party/libsodium_unit_tests/libsodium_ut_sign.cpp index f50547fe..37bf3823 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_sign.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_sign.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_sign.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace sign { @@ -17,15 +17,15 @@ namespace sign static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - - int + + int test(void) { crypto_sign_state st; diff --git a/third_party/libsodium_unit_tests/libsodium_ut_sign2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_sign2.cpp index 964e9802..713216ab 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_sign2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_sign2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_sign2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace sign2 { @@ -17,14 +17,14 @@ namespace sign2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_siphashx24.cpp b/third_party/libsodium_unit_tests/libsodium_ut_siphashx24.cpp index f7d4e3cb..d235635c 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_siphashx24.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_siphashx24.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_siphashx24.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace siphashx24 { @@ -17,14 +17,14 @@ namespace siphashx24 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils.cpp b/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils.cpp index ed59e9e9..9dc7a061 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_sodium_utils.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace sodium_utils { @@ -17,14 +17,14 @@ namespace sodium_utils static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils2.cpp index 0bac6146..1d86d767 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_sodium_utils2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace sodium_utils2 { @@ -17,14 +17,14 @@ namespace sodium_utils2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils3.cpp b/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils3.cpp index 826c9905..de3c762e 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils3.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_sodium_utils3.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_sodium_utils3.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace sodium_utils3 { @@ -17,14 +17,14 @@ namespace sodium_utils3 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_sodium_version.cpp b/third_party/libsodium_unit_tests/libsodium_ut_sodium_version.cpp index 61a8cd7f..c80bf180 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_sodium_version.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_sodium_version.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_sodium_version.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace sodium_version { @@ -17,14 +17,14 @@ namespace sodium_version static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_stream.cpp b/third_party/libsodium_unit_tests/libsodium_ut_stream.cpp index 9af5d727..e5cc78fe 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_stream.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_stream.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_stream.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace stream { @@ -17,14 +17,14 @@ namespace stream static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_stream2.cpp b/third_party/libsodium_unit_tests/libsodium_ut_stream2.cpp index d9b77f75..a3882258 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_stream2.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_stream2.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_stream2.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace stream2 { @@ -17,14 +17,14 @@ namespace stream2 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_stream3.cpp b/third_party/libsodium_unit_tests/libsodium_ut_stream3.cpp index 83016335..e1e1d7c0 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_stream3.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_stream3.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_stream3.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace stream3 { @@ -17,14 +17,14 @@ namespace stream3 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_stream4.cpp b/third_party/libsodium_unit_tests/libsodium_ut_stream4.cpp index 14a758dc..f8a33896 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_stream4.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_stream4.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_stream4.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace stream4 { @@ -17,14 +17,14 @@ namespace stream4 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_verify1.cpp b/third_party/libsodium_unit_tests/libsodium_ut_verify1.cpp index 0d1763c8..7d27a72c 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_verify1.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_verify1.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_verify1.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace verify1 { @@ -17,14 +17,14 @@ namespace verify1 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + int test(void) { diff --git a/third_party/libsodium_unit_tests/libsodium_ut_xchacha20.cpp b/third_party/libsodium_unit_tests/libsodium_ut_xchacha20.cpp index 7342ee73..5e43a903 100644 --- a/third_party/libsodium_unit_tests/libsodium_ut_xchacha20.cpp +++ b/third_party/libsodium_unit_tests/libsodium_ut_xchacha20.cpp @@ -1,7 +1,7 @@ #include "libsodium_ut_xchacha20.h" #include "unity.h" -//#include "aether/tele/tele.h" +//#include "aether/tele.h" namespace xchacha20 { @@ -17,14 +17,14 @@ namespace xchacha20 static const char *TAG = "SODIUM UNITY"; - #if DEBUG_OUT==1 + #if DEBUG_OUT==1 #define DebugPrint(format, ...) LOG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==2 #define DebugPrint(format, ...) AE_TELED_DEBUG(TAG, format, ##__VA_ARGS__) #elif DEBUG_OUT==3 #define DebugPrint(format, ...) ESP_LOGI(TAG, format, ##__VA_ARGS__) #endif - + static void tv_hchacha20(void) { From 7f0440ee855a74a2cb07f732a26882bd39bc121d Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Thu, 23 Jul 2026 12:25:50 +0500 Subject: [PATCH 5/6] split tele statistics and tele --- aether/CMakeLists.txt | 7 +- aether/ae_actions/telemetry.cpp | 11 ++- aether/ae_actions/telemetry.h | 6 +- aether/aether.h | 11 +-- aether/aether_app.cpp | 64 +++++++++++----- aether/aether_app.h | 44 +++++------ aether/all.h | 2 - aether/client.cpp | 4 +- aether/client.h | 2 +- aether/config.h | 5 ++ aether/tele/tele_init.cpp | 74 ------------------- aether/tele/tele_init.h | 32 -------- aether/tele/traps/statistics_trap.cpp | 4 +- aether/tele/traps/statistics_trap.h | 2 - aether/tele/traps/tele_statistics.cpp | 27 ------- aether/tele_compile_options.h | 23 ++++-- aether/tele_statistics.cpp | 56 ++++++++++++++ aether/{tele/traps => }/tele_statistics.h | 27 ++++--- config/user_config_hydrogen.h | 4 +- config/user_config_optimized.h | 1 + config/user_config_sodium.h | 4 +- examples/cloud/main.cpp | 1 - .../test_ds_synchronization.cpp | 11 ++- tests/test-safe-stream/main.cpp | 8 +- tests/test-serial-port/main.cpp | 8 +- tests/test-tele/test-tele.cpp | 10 +-- tools/registrator/registrator.cpp | 5 +- 27 files changed, 200 insertions(+), 253 deletions(-) delete mode 100644 aether/tele/tele_init.cpp delete mode 100644 aether/tele/tele_init.h delete mode 100644 aether/tele/traps/tele_statistics.cpp create mode 100644 aether/tele_statistics.cpp rename aether/{tele/traps => }/tele_statistics.h (82%) diff --git a/aether/CMakeLists.txt b/aether/CMakeLists.txt index 13a303d1..e5576f34 100644 --- a/aether/CMakeLists.txt +++ b/aether/CMakeLists.txt @@ -25,7 +25,8 @@ list(APPEND aether_srcs "work_cloud.cpp" "server.cpp" "server_keys.cpp" - "socket_initializer.cpp") + "socket_initializer.cpp" + "tele_statistics.cpp") list(APPEND aether_srcs "aether_c/c_uid.cpp" @@ -231,9 +232,7 @@ list(APPEND aether_srcs "channels/modem_channel.cpp") list(APPEND aether_srcs - "tele/tele_init.cpp" "tele/traps/io_stream_traps.cpp" - "tele/traps/statistics_trap.cpp" - "tele/traps/tele_statistics.cpp") + "tele/traps/statistics_trap.cpp") target_sources(${TARGET_NAME} PRIVATE ${aether_srcs}) diff --git a/aether/ae_actions/telemetry.cpp b/aether/ae_actions/telemetry.cpp index fa0348eb..2209f389 100644 --- a/aether/ae_actions/telemetry.cpp +++ b/aether/ae_actions/telemetry.cpp @@ -20,8 +20,7 @@ # include "aether-miscpp/format/format.h" # include "aether/aether.h" -# include "aether/tele.h" -# include "aether/tele/traps/tele_statistics.h" +# include "aether/tele_statistics.h" # include "aether/mstream.h" # include "aether/mstream_buffers.h" @@ -79,9 +78,9 @@ void Telemetry::OnRequestTelemetry(std::size_t server_priority) { std::optional Telemetry::CollectTelemetry( StreamInfo const& stream_info) { - auto& statistics_trap = - *tele::TeleStatistics::ptr{ae_context_.aether().tele_statistics}->trap(); - auto const& env_storage = statistics_trap.env_store(); + auto const& statistics_trap = + TeleStatistics::ptr{ae_context_.aether().tele_statistics}->trap(); + auto const& env_storage = statistics_trap->env_store(); Telemetric res{}; res.cpp.utm_id = env_storage.utm_id; res.cpp.lib_version = env_storage.library_version; @@ -97,7 +96,7 @@ std::optional Telemetry::CollectTelemetry( auto vector_writer = LimitVectorWriter<>{res.cpp.blob, res.cpp.blob.capacity()}; auto os = omstream{vector_writer}; - os << statistics_trap; + os << *statistics_trap; // TODO: should we reset stored statistics? return res; diff --git a/aether/ae_actions/telemetry.h b/aether/ae_actions/telemetry.h index fb3d1d88..a372b61b 100644 --- a/aether/ae_actions/telemetry.h +++ b/aether/ae_actions/telemetry.h @@ -18,15 +18,15 @@ #define AETHER_AE_ACTIONS_TELEMETRY_H_ #include "aether/config.h" -#if AE_TELE_ENABLED +#if AE_TELE_ENABLED && AE_TELE_LOG_TO_STATISTICS # define TELEMETRY_ENABLED 1 # include # include "aether/ae_context.h" -# include "aether/stream_api/istream.h" -# include "aether/cloud_connections/cloud_subscription.h" # include "aether/cloud_connections/cloud_server_connections.h" +# include "aether/cloud_connections/cloud_subscription.h" +# include "aether/stream_api/istream.h" # include "aether/work_cloud_api/telemetric.h" diff --git a/aether/aether.h b/aether/aether.h index 43a090fb..1aaaf89f 100644 --- a/aether/aether.h +++ b/aether/aether.h @@ -25,8 +25,8 @@ #include "aether/obj/obj.h" #include "aether/types/client_config.h" -#include "aether/ae_context.h" #include "aether/ae_actions/select_client.h" +#include "aether/ae_context.h" namespace ae { class Server; @@ -39,10 +39,7 @@ class AdapterRegistry; class ActionProcessor; class RegistrationCloud; class RegistrationCloud; - -namespace tele { class TeleStatistics; -} class Aether : public Obj { AE_OBJECT(Aether, Obj, 0) @@ -56,9 +53,9 @@ class Aether : public Obj { ~Aether() override; AE_OBJECT_REFLECT(AE_MMBRS(client_prefab, registration_cloud, crypto, - clients_, servers_, tele_statistics, poller, - dns_resolver, adapter_registry, - select_client_actions_)) + clients_, servers_, tele_statistics, poller, + dns_resolver, adapter_registry, + select_client_actions_)) template void Load(CurrentVersion, Dnv& dnv) { diff --git a/aether/aether_app.cpp b/aether/aether_app.cpp index b47023a8..ef3f084a 100644 --- a/aether/aether_app.cpp +++ b/aether/aether_app.cpp @@ -16,6 +16,9 @@ #include "aether/aether_app.h" +#include +#include + // IWYU pragma: begin_keeps #include "aether/types/address_parser.h" #include "aether/types/literal_array.h" @@ -33,28 +36,52 @@ #include "aether/dns/dns_c_ares.h" #include "aether/dns/esp32_dns_resolve.h" -// IWYU pragma: end_keeps - -#include "aether/tele/tele_init.h" #include "aether/tele.h" #include "aether/tele_compile_options.h" +// IWYU pragma: end_keeps namespace ae { -AetherAppContext::TelemetryInit::TelemetryInit() { - tele::TeleInit::Init(); - AE_TELE_ENV(kCompileOptions); +void AetherAppContext::TelemetryInit() { +#if AE_TELE_ENABLED + // Init telemetry sink + if (!TELE_SINK::Instance().trap()) { +# if AE_TELE_LOG_CONSOLE && AE_TELE_LOG_TO_STATISTICS + // telemetry to both console and statistics + auto trap = std::make_shared< + ae::tele::ProxyTrap>>( + std::make_shared(std::cout), + std::make_shared>()); +# elif AE_TELE_LOG_CONSOLE + // telemetry to console only + auto trap = std::make_shared(std::cout); +# elif AE_TELE_LOG_TO_STATISTICS + // telemetry to statistics only + auto trap = + std::make_shared>(); +# else + // NONE trap is enabled + return; +# endif + TELE_SINK::Instance().SetTrap(trap); + } +# if AE_TELE_LOG_TO_STATISTICS + else { + // TODO: is it possible to fix? + // IF AE_TELE_LOG_TO_STATISTICS is defined user are not allowed to set + // custom trap, because it's static_casts in TeleStatistics object + std::cerr + << "Custom trap are not allowed with AE_TELE_LOG_TO_STATISTICS==1\n"; + std::abort(); + } +# endif + + AE_TELE_ENV(CompileOptions()); AE_TELE_INFO(AetherStarted); Registry::GetRegistry().Log(); -} - -void AetherAppContext::TelemetryInit::operator()( - AetherAppContext const& context) const { - [[maybe_unused]] auto res = - context.tele_statistics_.Resolve(context).WithLoaded( - [](auto const& ts) { ae::tele::TeleInit::Init(ts); }); - assert(res && "Failed to initialize telemetry"); +#endif } static Aether::ptr AetherFactory(AetherAppContext const& context) { @@ -81,15 +108,14 @@ static Aether::ptr AetherFactory(AetherAppContext const& context) { #endif } -static tele::TeleStatistics::ptr TeleStatisticsFactory( +static TeleStatistics::ptr TeleStatisticsFactory( AetherAppContext const& context) { - auto tele_statistics = - tele::TeleStatistics::ptr{context.aether()->tele_statistics}; + auto tele_statistics = TeleStatistics::ptr{context.aether()->tele_statistics}; if (tele_statistics.is_valid()) { return tele_statistics; } #if AE_DISTILLATION || AE_FILTRATION - return tele::TeleStatistics::ptr::Create( + return TeleStatistics::ptr::Create( CreateWith{context.domain()}.with_id(GlobalId::kTeleStatistics)); #else assert(false && "Failed to load TeleStatistics"); @@ -301,8 +327,6 @@ RcPtr AetherApp::Construct(AetherAppContext context) { // init all the components in context context.InitComponentContext(); - context.init_tele_(context); - auto app = MakeRcPtr(); app->aether_ = context.aether(); #if AE_DISTILLATION diff --git a/aether/aether_app.h b/aether/aether_app.h index de8cbf26..d6e70f25 100644 --- a/aether/aether_app.h +++ b/aether/aether_app.h @@ -22,48 +22,41 @@ #include #include -#include "aether/config.h" #include "aether/common.h" +#include "aether/config.h" +#include "aether/obj/domain.h" #include "aether/ptr/ptr.h" #include "aether/ptr/rc_ptr.h" -#include "aether/obj/domain.h" -#include "aether-miscpp/types/small_function.h" -#include "aether/events/events.h" // IWYU pragma: keep #include "aether/actions/action.h" // IWYU pragma: keep +#include "aether/events/events.h" // IWYU pragma: keep -#include "aether/cloud.h" +#include "aether/adapter_registry.h" +#include "aether/ae_context.h" #include "aether/aether.h" -#include "aether/crypto.h" #include "aether/client.h" -#include "aether/ae_context.h" -#include "aether/poller/poller.h" +#include "aether/cloud.h" +#include "aether/crypto.h" #include "aether/dns/dns_resolve.h" -#include "aether/adapter_registry.h" #include "aether/obj/component_factory.h" -#include "aether/tele/traps/tele_statistics.h" +#include "aether/poller/poller.h" +#include "aether/tele_statistics.h" #include "aether/domain_storage/domain_storage_factory.h" namespace ae { class AetherAppContext { friend class AetherApp; - class TelemetryInit { - public: - TelemetryInit(); - void operator()(AetherAppContext const& context) const; - }; + static void TelemetryInit(); public: explicit AetherAppContext() - : AetherAppContext(DomainStorageFactory::Create, TelemetryInit{}) {} - - template - requires(std::is_invocable_r_v, Func> && - std::is_invocable_r_v) - explicit AetherAppContext(Func&& domain_storage_factory, - TeleInit const& tele_init = TelemetryInit{}) - : init_tele_{tele_init} { + : AetherAppContext(DomainStorageFactory::Create) {} + + template + requires(std::is_invocable_r_v, Func>) + explicit AetherAppContext(Func&& domain_storage_factory) { + TelemetryInit(); domain_storage_.Factory(std::forward(domain_storage_factory)); } @@ -145,10 +138,7 @@ class AetherAppContext { ComponentFactory poller_; ComponentFactory dns_resolver_; ComponentFactory client_prefab_; - ComponentFactory - tele_statistics_; - - SmallFunction init_tele_; + ComponentFactory tele_statistics_; }; /** diff --git a/aether/all.h b/aether/all.h index e18f9771..6309df8f 100644 --- a/aether/all.h +++ b/aether/all.h @@ -43,8 +43,6 @@ #include "aether/ptr/ptr_view.h" #include "aether/ptr/rc_ptr.h" -#include "aether/tele/tele_init.h" - #include "aether/domain_storage/domain_storage_factory.h" #include "aether/domain_storage/file_system_std_storage.h" #include "aether/domain_storage/ram_domain_storage.h" diff --git a/aether/client.cpp b/aether/client.cpp index 315fb153..a3b79dec 100644 --- a/aether/client.cpp +++ b/aether/client.cpp @@ -76,7 +76,7 @@ CloudServerConnections& Client::cloud_connection() { *connectivity_policy().Load()); #endif -#if AE_TELE_ENABLED +#if TELEMETRY_ENABLED // also create telemetry telemetry_ = std::make_unique(*aether_.Load().as(), *cloud_connection_); @@ -121,7 +121,7 @@ void Client::SetConfig(std::string client_id, Uid parent_uid, Uid uid, } void Client::SendTelemetry() { -#if AE_TELE_ENABLED +#if TELEMETRY_ENABLED telemetry_->SendTelemetry(); #endif } diff --git a/aether/client.h b/aether/client.h index 4a34d34f..998259c1 100644 --- a/aether/client.h +++ b/aether/client.h @@ -95,7 +95,7 @@ class Client : public Obj { #if AE_ENABLE_PING std::unique_ptr ping_cloud_servers_; #endif -#if AE_TELE_ENABLED +#if AE_TELE_ENABLED && AE_TELE_LOG_TO_STATISTICS std::unique_ptr telemetry_; #endif }; diff --git a/aether/config.h b/aether/config.h index 0dd682be..21a5605b 100644 --- a/aether/config.h +++ b/aether/config.h @@ -469,6 +469,11 @@ # define AE_TELE_LOG_CONSOLE 1 #endif // AE_TELE_LOG_CONSOLE +// enable to log telemetry to statistics +#ifndef AE_TELE_LOG_TO_STATISTICS +# define AE_TELE_LOG_TO_STATISTICS 1 +#endif // AE_TELE_LOG_TO_STATISTICS + // the maximum size of the telemetry statistics buffer #ifndef AE_STATISTICS_MAX_SIZE # define AE_STATISTICS_MAX_SIZE (10 * 1024) // 10 KB diff --git a/aether/tele/tele_init.cpp b/aether/tele/tele_init.cpp deleted file mode 100644 index 159d535f..00000000 --- a/aether/tele/tele_init.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2024 Aethernet Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "aether/tele/tele_init.h" - -#include -#include - -#include "aether/config.h" - -namespace ae::tele { - -template -static void TeleSinkInit() { -#if AE_TELE_ENABLED -# if AE_TELE_LOG_CONSOLE - // create statistics and console traps and combine them into one by proxy trap - auto console_trap = std::make_shared(std::cout); - auto statistics_trap = std::make_shared(); - - SelectedSink::Instance().SetTrap( - std::make_shared>( - std::move(console_trap), std::move(statistics_trap))); -# else - // use just statistics trap - SelectedSink::Instance().SetTrap(std::make_shared()); -# endif -#endif -} - -template -static void TeleSinkReInit( - [[maybe_unused]] Ptr const& tele_statistics) { -#if AE_TELE_ENABLED -# if AE_TELE_LOG_CONSOLE - // statistics trap + print logs to iostream - auto proxy_trap = - std::static_pointer_cast>( - SelectedSink::Instance().trap()); - auto new_tele_trap = tele_statistics->trap(); - new_tele_trap->MergeStatistics(*proxy_trap->second); - proxy_trap->second = new_tele_trap; - SelectedSink::Instance().SetTrap(std::move(proxy_trap)); -# else - // just statistics trap - auto old_trap = std::static_pointer_cast( - SelectedSink::Instance().trap()); - auto new_tele_trap = tele_statistics->trap(); - new_tele_trap->MergeStatistics(*old_trap); - - SelectedSink::Instance().SetTrap(std::move(new_tele_trap)); -# endif -#endif -} - -void TeleInit::Init() { TeleSinkInit(); } -void TeleInit::Init(Ptr const& tele_statistics) { - TeleSinkReInit(tele_statistics); -} - -} // namespace ae::tele diff --git a/aether/tele/tele_init.h b/aether/tele/tele_init.h deleted file mode 100644 index 0bbb2f3b..00000000 --- a/aether/tele/tele_init.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright 2024 Aethernet Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef AETHER_TELE_TELE_INIT_H_ -#define AETHER_TELE_TELE_INIT_H_ - -// IWYU pragma: begin_keeps -#include "aether/tele.h" -#include "aether/tele/traps/tele_statistics.h" -// IWYU pragma: end_keeps - -namespace ae::tele { -struct TeleInit { - static void Init(); - static void Init(Ptr const& tele_statistics); -}; -} // namespace ae::tele - -#endif // AETHER_TELE_TELE_INIT_H_ diff --git a/aether/tele/traps/statistics_trap.cpp b/aether/tele/traps/statistics_trap.cpp index 99c2fcef..26b97bdb 100644 --- a/aether/tele/traps/statistics_trap.cpp +++ b/aether/tele/traps/statistics_trap.cpp @@ -22,7 +22,7 @@ #include #include -namespace ae::tele::statistics { +namespace ae::tele { // print any integral to LogStorage template @@ -155,4 +155,4 @@ MetricsStore const& StatisticsTrapBasic::metrics_store() const { return metrics_store_; } -} // namespace ae::tele::statistics +} // namespace ae::tele diff --git a/aether/tele/traps/statistics_trap.h b/aether/tele/traps/statistics_trap.h index ca36a2de..ef9b847c 100644 --- a/aether/tele/traps/statistics_trap.h +++ b/aether/tele/traps/statistics_trap.h @@ -34,7 +34,6 @@ #include "aether/tele/itrap.h" namespace ae::tele { -namespace statistics { /** * \brief Map of telemetry metrics. */ @@ -223,7 +222,6 @@ class StatisticsTrap final : public StatisticsTrapBasic { private: LogStorage log_storage_; }; -} // namespace statistics } // namespace ae::tele #endif // AETHER_TELE_TRAPS_STATISTICS_TRAP_H_ diff --git a/aether/tele/traps/tele_statistics.cpp b/aether/tele/traps/tele_statistics.cpp deleted file mode 100644 index f9018e2f..00000000 --- a/aether/tele/traps/tele_statistics.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2024 Aethernet Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "aether/tele/traps/tele_statistics.h" - -namespace ae::tele { -#ifdef AE_DISTILLATION -TeleStatistics::TeleStatistics(ObjProp prop) : Obj{prop} {} -#endif - -#if AE_TELE_ENABLED -auto TeleStatistics::trap() -> std::shared_ptr const& { return trap_; } -#endif -} // namespace ae::tele diff --git a/aether/tele_compile_options.h b/aether/tele_compile_options.h index 6ffa3aa6..009e4415 100644 --- a/aether/tele_compile_options.h +++ b/aether/tele_compile_options.h @@ -127,6 +127,8 @@ constexpr inline auto _compile_options_list = std::array{ _OPTION(AE_TELE_LOG_BLOB), _OPTION(AE_TELE_LOG_BLOB_EXCLUDE), _OPTION(AE_TELE_LOG_CONSOLE), + _OPTION(AE_TELE_LOG_TO_STATISTICS), + _OPTION(AE_STATISTICS_MAX_SIZE), #if defined AE_DISTILLATION _OPTION(AE_DISTILLATION), #else @@ -147,16 +149,21 @@ constexpr inline auto _compile_options_list = std::array{ #endif }; -constexpr auto MakeCompileOptions() { - return [](std::index_sequence) noexcept { - return std::array{::ae::tele::CompileOption{ - .index = Is, - .name = _compile_options_list[Is].first, - .value = _compile_options_list[Is].second}...}; - }(std::make_index_sequence<_compile_options_list.size()>()); +template +consteval auto MakeCompileOptionsImpl(std::index_sequence) { + return std::array{ + ::ae::tele::CompileOption{.index = Is, + .name = _compile_options_list[Is].first, + .value = _compile_options_list[Is].second}...}; } -static constexpr inline auto kCompileOptions = MakeCompileOptions(); +consteval auto CompileOptions() noexcept { + return MakeCompileOptionsImpl( + std::make_index_sequence<_compile_options_list.size()>()); +} + +// static constexpr inline auto kCompileOptions = MakeCompileOptions( +// std::make_index_sequence<_compile_options_list.size()>()); } // namespace ae diff --git a/aether/tele_statistics.cpp b/aether/tele_statistics.cpp new file mode 100644 index 00000000..e46653b9 --- /dev/null +++ b/aether/tele_statistics.cpp @@ -0,0 +1,56 @@ +/* + * Copyright 2024 Aethernet Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "aether/tele_statistics.h" + +#include "aether/tele.h" + +namespace ae { +#ifdef AE_DISTILLATION +TeleStatistics::TeleStatistics(ObjProp prop) : Obj{prop} {} +#endif + +#if AE_TELE_ENABLED && AE_TELE_LOG_TO_STATISTICS +auto TeleStatistics::trap() -> std::shared_ptr const& { return trap_; } + +void TeleStatistics::OnLoaded() { + auto& sink = TELE_SINK::Instance(); + auto const& trap = sink.trap(); + if (!trap) { + sink.SetTrap(trap_); + return; + } + // !NOTICE it's error if AE_TELE_LOG_TO_STATISTICS is defined to 1 but actual + // trap is set to something different +# if AE_TELE_LOG_CONSOLE && AE_TELE_LOG_TO_STATISTICS + // if proxy trap is used + auto proxy = std::static_pointer_cast< + ae::tele::ProxyTrap>>( + trap); + auto const& current_statistics = proxy->second; + trap_->MergeStatistics(*current_statistics); + proxy->second = trap_; +# elif AE_TELE_LOG_TO_STATISTICS + auto current_statistics = std::static_pointer_cast< + ae::tele::StatisticsTrap>(trap); + trap_->MergeStatistics(*current_statistics); + sink.SetTrap(trap_); +# endif +} + +#endif +} // namespace ae diff --git a/aether/tele/traps/tele_statistics.h b/aether/tele_statistics.h similarity index 82% rename from aether/tele/traps/tele_statistics.h rename to aether/tele_statistics.h index 3f34be6a..1ebb9f62 100644 --- a/aether/tele/traps/tele_statistics.h +++ b/aether/tele_statistics.h @@ -17,49 +17,48 @@ #ifndef AETHER_TELE_TRAPS_TELE_STATISTICS_H_ #define AETHER_TELE_TRAPS_TELE_STATISTICS_H_ -#include "aether-miscpp/reflect/reflect.h" -#include "aether/config.h" -#include "aether/obj/obj.h" -#include "aether/ptr/rc_ptr.h" +#include -#include "aether/tele.h" #include "aether/tele/traps/statistics_trap.h" -namespace ae::tele { +#include "aether/config.h" +#include "aether/obj/obj.h" + +namespace ae { class TeleStatistics : public Obj { AE_OBJECT(TeleStatistics, Obj, 0) TeleStatistics() = default; public: - using Trap = statistics::StatisticsTrap; - #ifdef AE_DISTILLATION explicit TeleStatistics(ObjProp prop); #endif // AE_DISTILLATION -#if AE_TELE_ENABLED - AE_OBJECT_REFLECT(AE_MMBR(trap_)) + AE_OBJECT_REFLECT() +#if AE_TELE_ENABLED && AE_TELE_LOG_TO_STATISTICS template void Load(CurrentVersion, Dnv& dnv) { dnv(base_, *trap_); + OnLoaded(); } template void Save(CurrentVersion, Dnv& dnv) const { dnv(base_, *trap_); } -#else - AE_OBJECT_REFLECT() #endif -#if AE_TELE_ENABLED +#if AE_TELE_ENABLED && AE_TELE_LOG_TO_STATISTICS + using Trap = tele::StatisticsTrap; + std::shared_ptr const& trap(); private: + void OnLoaded(); std::shared_ptr trap_ = std::make_shared(); #endif }; -} // namespace ae::tele +} // namespace ae #endif // AETHER_TELE_TRAPS_TELE_STATISTICS_H_ diff --git a/config/user_config_hydrogen.h b/config/user_config_hydrogen.h index 981ec3b7..9e066cc3 100644 --- a/config/user_config_hydrogen.h +++ b/config/user_config_hydrogen.h @@ -36,6 +36,8 @@ // telemetry #define AE_TELE_ENABLED 1 #define AE_TELE_LOG_CONSOLE 1 +#define AE_TELE_LOG_TO_STATISTICS 1 +#define AE_STATISTICS_MAX_SIZE 1024 // all except MLog #define AE_TELE_METRICS_MODULES_EXCLUDE {AE_LOG_MODULE} @@ -55,8 +57,6 @@ #define AE_TELE_LOG_LEVEL_MODULE AE_ALL #define AE_TELE_LOG_BLOB AE_ALL -#define AE_STATISTICS_MAX_SIZE 1024 - #if AE_DISTILLATION || AE_FILTRATION # define AE_SUPPORT_REGISTRATION 1 # define AE_SUPPORT_CLOUD_DNS 1 diff --git a/config/user_config_optimized.h b/config/user_config_optimized.h index 00b8a117..ff1d0d09 100644 --- a/config/user_config_optimized.h +++ b/config/user_config_optimized.h @@ -36,6 +36,7 @@ // telemetry #define AE_TELE_ENABLED 0 #define AE_TELE_LOG_CONSOLE 0 +#define AE_TELE_LOG_TO_STATISTICS 0 #define AE_SUPPORT_REGISTRATION 1 #define AE_SUPPORT_CLOUD_DNS 1 diff --git a/config/user_config_sodium.h b/config/user_config_sodium.h index 0b080110..9f310089 100644 --- a/config/user_config_sodium.h +++ b/config/user_config_sodium.h @@ -36,6 +36,8 @@ // telemetry #define AE_TELE_ENABLED 1 #define AE_TELE_LOG_CONSOLE 1 +#define AE_TELE_LOG_TO_STATISTICS 1 +#define AE_STATISTICS_MAX_SIZE 1024 // all except MLog #define AE_TELE_METRICS_MODULES_EXCLUDE {AE_LOG_MODULE} @@ -55,8 +57,6 @@ #define AE_TELE_LOG_LEVEL_MODULE AE_ALL #define AE_TELE_LOG_BLOB AE_ALL -#define AE_STATISTICS_MAX_SIZE 1024 - #if AE_DISTILLATION || AE_FILTRATION # define AE_SUPPORT_REGISTRATION 1 # define AE_SUPPORT_CLOUD_DNS 1 diff --git a/examples/cloud/main.cpp b/examples/cloud/main.cpp index de7122cf..3973ef31 100644 --- a/examples/cloud/main.cpp +++ b/examples/cloud/main.cpp @@ -32,7 +32,6 @@ #include "aether/config.h" #include "aether/tele.h" -#include "aether/tele/tele_init.h" #if (defined(CM_ESP32)) # include diff --git a/tests/test-domain-storage/test_ds_synchronization.cpp b/tests/test-domain-storage/test_ds_synchronization.cpp index b1ddeef7..68c26565 100644 --- a/tests/test-domain-storage/test_ds_synchronization.cpp +++ b/tests/test-domain-storage/test_ds_synchronization.cpp @@ -18,16 +18,17 @@ #include #include +#include #include "aether/memory.h" -#include "aether/tele/tele_init.h" +#include "aether/tele.h" // IWYU pragma: begin_exports +#include "aether/domain_storage/file_system_std_storage.h" #include "aether/domain_storage/ram_domain_storage.h" -#include "aether/domain_storage/sync_domain_storage.h" #include "aether/domain_storage/spifs_domain_storage.h" #include "aether/domain_storage/static_domain_storage.h" -#include "aether/domain_storage/file_system_std_storage.h" +#include "aether/domain_storage/sync_domain_storage.h" // IWYU pragma: end_exports namespace ae::test_ds_synchronization { @@ -162,7 +163,9 @@ void test_SyncWithFSStorage() { } // namespace ae::test_ds_synchronization int test_ds_synchronization() { - ae::tele::TeleInit::Init(); + TELE_SINK::Instance().SetTrap( + std::make_shared(std::cout)); + UNITY_BEGIN(); RUN_TEST(ae::test_ds_synchronization::test_SyncWithRamStorage); RUN_TEST(ae::test_ds_synchronization::test_SyncWithFSStorage); diff --git a/tests/test-safe-stream/main.cpp b/tests/test-safe-stream/main.cpp index ea1a9147..089d45c2 100644 --- a/tests/test-safe-stream/main.cpp +++ b/tests/test-safe-stream/main.cpp @@ -16,9 +16,13 @@ #include -#include "aether/tele/tele_init.h" +#include +#include "aether/tele.h" -void setUp() { ae::tele::TeleInit::Init(); } +void setUp() { + TELE_SINK::Instance().SetTrap( + std::make_shared(std::cout)); +} void tearDown() {} extern int test_circular_buffer(); diff --git a/tests/test-serial-port/main.cpp b/tests/test-serial-port/main.cpp index 3d9ae81c..78ebd337 100644 --- a/tests/test-serial-port/main.cpp +++ b/tests/test-serial-port/main.cpp @@ -15,10 +15,14 @@ */ #include +#include -#include "aether/tele/tele_init.h" +#include "aether/tele.h" -void setUp() { ae::tele::TeleInit::Init(); } +void setUp() { + TELE_SINK::Instance().SetTrap( + std::make_shared(std::cout)); +} void tearDown() {} extern int test_at_support(); diff --git a/tests/test-tele/test-tele.cpp b/tests/test-tele/test-tele.cpp index 128bfe81..0e0834e3 100644 --- a/tests/test-tele/test-tele.cpp +++ b/tests/test-tele/test-tele.cpp @@ -367,7 +367,7 @@ void test_MergeStatisticsTrap() { false, false, false, false>>; #undef TELE_SINK #define TELE_SINK Sink - using Trap = statistics::StatisticsTrap<1024>; + using Trap = StatisticsTrap<1024>; auto statistics_trap1 = std::make_shared(); Sink::Instance().SetTrap(statistics_trap1); @@ -431,7 +431,7 @@ void test_MergeStatisticsTrap() { } void test_StatisticsRotation() { - using Trap = ae::tele::statistics::StatisticsTrap<1024>; + using Trap = ae::tele::StatisticsTrap<1024>; auto ts = std::make_shared(); SinkType::Instance().SetTrap(ts); @@ -453,7 +453,7 @@ void test_StatisticsRotation() { } void test_SaveLoadTeleStatistics() { - using Trap = ae::tele::statistics::StatisticsTrap<1024>; + using Trap = ae::tele::StatisticsTrap<1024>; auto ts_0 = std::make_shared(); auto ts_1 = std::make_shared(); @@ -474,8 +474,8 @@ void test_SaveLoadTeleStatistics() { auto const& metrics2 = ts_1->metrics_store().metrics; TEST_ASSERT_EQUAL(metrics1.size(), metrics2.size()); - auto log_index = ae::tele::statistics::MetricsStore::PackedIndex{ - TestObj.index_start + Test1.offset}; + auto log_index = + ae::tele::MetricsStore::PackedIndex{TestObj.index_start + Test1.offset}; // simple check with _AE_MODULE_CONFIG leads here to AST broken error for // cppcheck constexpr bool time_metrics_enabled = diff --git a/tools/registrator/registrator.cpp b/tools/registrator/registrator.cpp index 79d5dcec..31dabe83 100644 --- a/tools/registrator/registrator.cpp +++ b/tools/registrator/registrator.cpp @@ -45,10 +45,7 @@ int AetherRegistrator(const std::string& ini_file, // make special domain storage to write all state into header file [&header_file]() { return ae::make_unique(header_file); - }, - // empty tele initializer - [](auto const&) {}, - } + }} .CryptoFactory([®istrator_config]( ae::AetherAppContext const& context) { auto crypto = ae::Crypto::ptr::Create( From b87ab14883e52ea4e2ea155c179284116b26d0a1 Mon Sep 17 00:00:00 2001 From: BartolomeyKant Date: Thu, 23 Jul 2026 17:00:25 +0500 Subject: [PATCH 6/6] fix bin size growth after tele move --- aether/aether_tele.h | 116 ++++++++++++++++-------------- aether/tele/collectors.h | 68 +++++++++--------- aether/tele/configs/all_enabled.h | 34 +++++---- aether/tele/defines.h | 19 +++-- aether/tele/env_collectors.h | 15 ++-- aether/tele/sink.h | 39 ++++++++-- tests/test-tele/test-tele.cpp | 110 +++++++++++++++++----------- 7 files changed, 235 insertions(+), 166 deletions(-) diff --git a/aether/aether_tele.h b/aether/aether_tele.h index 7ae55515..2eb40307 100644 --- a/aether/aether_tele.h +++ b/aether/aether_tele.h @@ -21,6 +21,7 @@ #include "aether/config.h" #include "aether/tele/levels.h" +#include "aether/tele/sink.h" #include "aether/tele/tags.h" namespace ae { @@ -53,69 +54,78 @@ consteval bool IsAll(T const (& /* value */)[Size]) { // NOLINT(*c-arrays) // NOLINTBEGIN // OPTION equals to AE_ALL or MODULE in OPTION list and not in OPTION_EXCLUDE // list -#define _AE_MODULE_CONFIG(MODULE, OPTION) \ - (((aether_tele_internal::IsAll(OPTION) && \ - !aether_tele_internal::IsEnabled(OPTION##_EXCLUDE)) || \ - aether_tele_internal::IsEnabled(OPTION))) - -#define _AE_MODULE_DEBUG_ENABLED(MODULE) \ - _AE_MODULE_CONFIG(MODULE, AE_TELE_DEBUG_MODULES) -#define _AE_MODULE_INFO_ENABLED(MODULE) \ - _AE_MODULE_CONFIG(MODULE, AE_TELE_INFO_MODULES) -#define _AE_MODULE_WARN_ENABLED(MODULE) \ - _AE_MODULE_CONFIG(MODULE, AE_TELE_WARN_MODULES) -#define _AE_MODULE_ERROR_ENABLED(MODULE) \ - _AE_MODULE_CONFIG(MODULE, AE_TELE_ERROR_MODULES) - -// NOLINTNEXTLINE -#define _AE_LEVEL_MODULE_CONFIG(MODULE, LEVEL) \ - ((LEVEL) == ae::tele::Level::kDebug && _AE_MODULE_DEBUG_ENABLED(MODULE)) || \ - ((LEVEL) == ae::tele::Level::kInfo && \ - _AE_MODULE_INFO_ENABLED(MODULE)) || \ - ((LEVEL) == ae::tele::Level::kWarning && \ - _AE_MODULE_WARN_ENABLED(MODULE)) || \ - ((LEVEL) == ae::tele::Level::kError && _AE_MODULE_ERROR_ENABLED(MODULE)) +#define _AE_MODULE_CONFIG(MODULE, OPTION) \ + (((::ae::aether_tele_internal::IsAll(OPTION) && \ + !::ae::aether_tele_internal::IsEnabled(OPTION##_EXCLUDE)) || \ + ::ae::aether_tele_internal::IsEnabled(OPTION))) + +// NOLINTEND + +namespace aether_tele_internal { +template +consteval bool AeModuleDebugEnabled() { + return _AE_MODULE_CONFIG(M, AE_TELE_DEBUG_MODULES); +} +template +consteval bool AeModuleInfoEnabled() { + return _AE_MODULE_CONFIG(M, AE_TELE_INFO_MODULES); +} +template +consteval bool AeModuleWarnEnabled() { + return _AE_MODULE_CONFIG(M, AE_TELE_WARN_MODULES); +} +template +consteval bool AeModuleErrorEnabled() { + return _AE_MODULE_CONFIG(M, AE_TELE_ERROR_MODULES); +} + +template +consteval bool LevelModuleConfig() { + return ((L) == ae::tele::Level::kDebug && AeModuleDebugEnabled()) || + ((L) == ae::tele::Level::kInfo && AeModuleInfoEnabled()) || + ((L) == ae::tele::Level::kWarning && AeModuleWarnEnabled()) || + ((L) == ae::tele::Level::kError && AeModuleErrorEnabled()); +} +} // namespace aether_tele_internal struct AetherTeleConfig { static constexpr bool kGlobalTeleEnabled = AE_TELE_ENABLED; template - struct TeleConfig { + static consteval auto GetTeleConfig() { // IF the whole Level + Module enabled - static constexpr bool kTeleEnabled = - kGlobalTeleEnabled && _AE_LEVEL_MODULE_CONFIG(M, L); + // cppcheck-suppress-begin * + constexpr bool kTeleEnabled = + kGlobalTeleEnabled && aether_tele_internal::LevelModuleConfig(); + // cppcheck-suppress-end * - static constexpr bool kLogsEnabled = + constexpr bool kMetricsEnabled = + kTeleEnabled && _AE_MODULE_CONFIG(M, AE_TELE_METRICS_MODULES); + constexpr bool kLogsEnabled = kTeleEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_MODULES); - // count must be always enabled if metrics enabled - static constexpr bool kCountMetrics = - kTeleEnabled && _AE_MODULE_CONFIG(M, AE_TELE_METRICS_MODULES); - // time metrics - static constexpr bool kTimeMetrics = - kTeleEnabled && _AE_MODULE_CONFIG(M, AE_TELE_METRICS_MODULES) && - _AE_MODULE_CONFIG(M, AE_TELE_METRICS_DURATION); - - // start time - static constexpr bool kStartTimeLogs = - kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_TIME_POINT); - // level and module - static constexpr bool kLevelModuleLogs = - kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_LEVEL_MODULE); - // location - static constexpr bool kLocationLogs = - kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_LOCATION); - // name - static constexpr bool kNameLogs = - kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_NAME); - // blob - static constexpr bool kBlobLogs = - kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_BLOB); - }; + return tele::TeleConfig{ + .count_metrics = kMetricsEnabled, + .time_metrics = + kMetricsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_METRICS_DURATION), + + .logs_enabled = kLogsEnabled, + .start_time_logs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_TIME_POINT), + .level_module_logs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_LEVEL_MODULE), + .location_logs = + kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_LOCATION), + .name_logs = kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_NAME), + .blob_logs = kLogsEnabled && _AE_MODULE_CONFIG(M, AE_TELE_LOG_BLOB), + }; + } - struct EnvConfig { - static constexpr bool kStaticInfo = AE_TELE_COMPILATION_INFO; - static constexpr bool kRuntimeInfo = AE_TELE_RUNTIME_INFO; + static consteval auto GetEnvConfig() { + return tele::EnvConfig{ + .static_info = AE_TELE_COMPILATION_INFO, + .runtime_info = AE_TELE_RUNTIME_INFO, + }; }; }; } // namespace ae diff --git a/aether/tele/collectors.h b/aether/tele/collectors.h index 8ce3e419..fc18060f 100644 --- a/aether/tele/collectors.h +++ b/aether/tele/collectors.h @@ -29,6 +29,7 @@ #include "aether/tele/itrap.h" #include "aether/tele/levels.h" #include "aether/tele/modules.h" // IWYU pragma: keep +#include "aether/tele/sink.h" #include "aether/tele/tags.h" namespace ae::tele { @@ -65,24 +66,24 @@ struct TimedTele { std::shared_ptr trap; }; -template -static constexpr inline bool kIsAnyLogs = TConfig::kLogsEnabled; +template +static constexpr inline bool kIsAnyLogs = Config.logs_enabled; -template +template static constexpr inline bool kIsAnyMetrics = - TConfig::kCountMetrics || TConfig::kTimeMetrics; + Config.count_metrics || Config.time_metrics; -template +template static constexpr inline bool kIsAnyTele = - kIsAnyLogs || kIsAnyMetrics; + kIsAnyLogs || kIsAnyMetrics; -template +template struct TeleLogCollector; // Specialization for disabled Logs -template -struct TeleLogCollector>> - final : public ILogCollector { +template +struct TeleLogCollector>> final + : public ILogCollector { template constexpr explicit TeleLogCollector(TArgs&&...) noexcept {} @@ -90,10 +91,10 @@ struct TeleLogCollector>> }; // Specialization for enabled Logs -template -struct TeleLogCollector>> - final : public ILogCollector { - using SinkConfig = TSinkConfig; +template +struct TeleLogCollector>> final + : public ILogCollector { + static constexpr auto SinkConfig = Config; template constexpr explicit TeleLogCollector(Tag const& t, Level l, std::string_view f, @@ -102,48 +103,47 @@ struct TeleLogCollector>> : tag{t}, level{l}, file{f}, line{f_l}, blob{b} {} void WriteLine([[maybe_unused]] ILogLine& log_line) override { - if constexpr (SinkConfig::kStartTimeLogs) { + if constexpr (SinkConfig.start_time_logs) { log_line.InvokeTime(TimePoint::clock::now()); } - if constexpr (SinkConfig::kLevelModuleLogs) { + if constexpr (SinkConfig.level_module_logs) { log_line.WriteLevel(level); log_line.WriteModule(tag.module); } - if constexpr (SinkConfig::kLocationLogs) { + if constexpr (SinkConfig.location_logs) { log_line.Location(file, line); } - if constexpr (SinkConfig::kNameLogs) { + if constexpr (SinkConfig.name_logs) { log_line.TagName(tag.name); } - if constexpr (SinkConfig::kBlobLogs) { + if constexpr (SinkConfig.blob_logs) { log_line.Blob(blob); } } [[no_unique_address]] OrEmpty_t< - SinkConfig::kLevelModuleLogs || SinkConfig::kNameLogs, Tag const&> tag; - [[no_unique_address]] OrEmpty_t level; - [[no_unique_address]] OrEmpty_t + SinkConfig.level_module_logs || SinkConfig.name_logs, Tag const&> tag; + [[no_unique_address]] OrEmpty_t level; + [[no_unique_address]] OrEmpty_t file; - [[no_unique_address]] OrEmpty_t - line; - [[no_unique_address]] OrEmpty_t line; + [[no_unique_address]] OrEmpty_t> blob; }; // Dummy Tele if telemetry is disabled -template +template struct Tele { template constexpr explicit Tele(TArgs&&... /* args */) {} }; // Tele for enabled telemetry -template -struct Tele>> { +template +struct Tele>> { using Sink = TSink; - using SinkConfig = TSinkConfig; - using TimedTele = OrEmpty_t; + static constexpr auto SinkConfig = Config; + using TimedTele = OrEmpty_t; template constexpr Tele(Sink& sink, Tag const& tag, [[maybe_unused]] Level level, @@ -153,7 +153,7 @@ struct Tele>> { collectors_internal::kEmptyFormat, [[maybe_unused]] BlobArgs&&... args) noexcept : timed_tele_{std::invoke([&]() -> TimedTele { - if constexpr (SinkConfig::kTimeMetrics) { + if constexpr (SinkConfig.time_metrics) { return TimedTele{.timer = {}, .tag = tag, .trap = sink.trap()}; } else { return TimedTele{}; @@ -163,7 +163,7 @@ struct Tele>> { if (!trap) { return; } - if constexpr (SinkConfig::kCountMetrics) { + if constexpr (SinkConfig.count_metrics) { trap->AddInvoke(tag, 1); } @@ -171,7 +171,7 @@ struct Tele>> { // TODO: more effective way to make blob std::string blob_str; std::span blob{}; - if constexpr (SinkConfig::kBlobLogs) { + if constexpr (SinkConfig.blob_logs) { if (format.source != collectors_internal::kEmptyFormat.source) { FormatTo(blob_str, format, std::forward(args)...); blob = {reinterpret_cast(blob_str.data()), @@ -185,7 +185,7 @@ struct Tele>> { } ~Tele() { - if constexpr (SinkConfig::kTimeMetrics) { + if constexpr (SinkConfig.time_metrics) { if (!timed_tele_.trap) { return; } diff --git a/aether/tele/configs/all_enabled.h b/aether/tele/configs/all_enabled.h index 956947f6..5c76460e 100644 --- a/aether/tele/configs/all_enabled.h +++ b/aether/tele/configs/all_enabled.h @@ -20,25 +20,29 @@ #include #include "aether/tele/levels.h" +#include "aether/tele/sink.h" namespace ae::tele { struct AllEnabledConfig { template - struct TeleConfig { - static constexpr bool kCountMetrics = true; - static constexpr bool kTimeMetrics = true; - static constexpr bool kLogsEnabled = true; - static constexpr bool kStartTimeLogs = true; - static constexpr bool kLevelModuleLogs = true; - static constexpr bool kLocationLogs = true; - static constexpr bool kNameLogs = true; - static constexpr bool kBlobLogs = true; - }; - - struct EnvConfig { - static constexpr bool kStaticInfo = true; - static constexpr bool kRuntimeInfo = true; - }; + static consteval auto GetTeleConfig() { + return TeleConfig{ + .count_metrics = true, + .time_metrics = true, + .logs_enabled = true, + .start_time_logs = true, + .level_module_logs = true, + .location_logs = true, + .name_logs = true, + .blob_logs = true, + }; + } + static consteval auto GetEnvConfig() { + return EnvConfig{ + .static_info = true, + .runtime_info = true, + }; + } }; } // namespace ae::tele diff --git a/aether/tele/defines.h b/aether/tele/defines.h index 5384013f..d7582d3c 100644 --- a/aether/tele/defines.h +++ b/aether/tele/defines.h @@ -42,12 +42,11 @@ AE_TELE_MODULE(MLog, AE_LOG_MODULE, AE_LOG_MODULE, AE_LOG_MODULE); AE_TAG(kLog, MLog) -#define AE_TELE_(TAG_NAME, TAG, LEVEL, ...) \ - [[maybe_unused]] auto TAG_NAME = \ - ::ae::tele::Tele> { \ - TELE_SINK::Instance(), TAG, ::ae::tele::Level{LEVEL}, __FILE__, __LINE__, \ - __VA_ARGS__ \ +#define AE_TELE_(TAG_NAME, TAG, LEVEL, ...) \ + [[maybe_unused]] auto TAG_NAME = ::ae::tele::Tele< \ + TELE_SINK, TELE_SINK::template GetTeleConfig()> { \ + TELE_SINK::Instance(), TAG, ::ae::tele::Level{LEVEL}, __FILE__, __LINE__, \ + __VA_ARGS__ \ } #define AE_TELE_DEBUG(TAG, ...) \ @@ -74,10 +73,10 @@ AE_TAG(kLog, MLog) __VA_ARGS__) // Log environment data -#define AE_TELE_ENV(...) \ - [[maybe_unused]] auto AETE_UNIQUE_NAME(TELE_ENV_) = \ - ::ae::tele::EnvTele { \ - TELE_SINK::Instance(), UTM_ID, __VA_ARGS__ \ +#define AE_TELE_ENV(...) \ + [[maybe_unused]] auto AETE_UNIQUE_NAME(TELE_ENV_) = \ + ::ae::tele::EnvTele { \ + TELE_SINK::Instance(), UTM_ID, __VA_ARGS__ \ } #endif // AETHER_TELE_DEFINES_H_ */ diff --git a/aether/tele/env_collectors.h b/aether/tele/env_collectors.h index c6900b90..1f21adc6 100644 --- a/aether/tele/env_collectors.h +++ b/aether/tele/env_collectors.h @@ -28,6 +28,7 @@ #include "aether/tele/env/library_version.h" #include "aether/tele/env/platform_type.h" #include "aether/tele/itrap.h" +#include "aether/tele/sink.h" namespace ae::tele { /** @@ -55,17 +56,17 @@ constexpr Endianness PlatformEndianness() { } constexpr auto CpuType() { return AE_CPU_TYPE; } -template +template struct EnvTele { template constexpr explicit EnvTele(TArgs&&... /* args */) {} }; -template -struct EnvTele> { +template +struct EnvTele> { using Sink = TSink; - using SinkConfig = typename Sink::EnvConfig; + static constexpr auto SinkConfig = Config; template explicit EnvTele( @@ -76,7 +77,7 @@ struct EnvTele #include #include "aether/tele/itrap.h" @@ -24,15 +25,43 @@ #include "aether/tele/modules.h" // IWYU pragma: keep namespace ae::tele { -template +struct TeleConfig { + bool count_metrics = true; + bool time_metrics = true; + + bool logs_enabled = true; + bool start_time_logs = true; + bool level_module_logs = true; + bool location_logs = true; + bool name_logs = true; + bool blob_logs = true; +}; + +struct EnvConfig { + bool static_info = true; + bool runtime_info = true; +}; + +template +concept ConfigProvider = requires() { + { + T::template GetTeleConfig() + } -> std::same_as; + { T::GetEnvConfig() } -> std::same_as; +}; + +template class TeleSink { public: - using ConfigProviderType = ConfigProvider; + using ConfigProviderType = CP; template - using TeleConfig = typename ConfigProviderType::template TeleConfig; - - using EnvConfig = typename ConfigProviderType::EnvConfig; + static consteval auto GetTeleConfig() { + return ConfigProviderType::template GetTeleConfig(); + } + static consteval auto GetEnvConfig() { + return ConfigProviderType::GetEnvConfig(); + } static TeleSink& Instance() { static TeleSink sink; diff --git a/tests/test-tele/test-tele.cpp b/tests/test-tele/test-tele.cpp index 0e0834e3..376ea54b 100644 --- a/tests/test-tele/test-tele.cpp +++ b/tests/test-tele/test-tele.cpp @@ -202,21 +202,22 @@ template struct ConfigProvider { template - struct TeleConfig { - static constexpr bool kCountMetrics = Count; - static constexpr bool kTimeMetrics = Time; - static constexpr bool kLogsEnabled = LogsEnabled; - static constexpr bool kStartTimeLogs = StartTime; - static constexpr bool kLevelModuleLogs = LevelModule; - static constexpr bool kLocationLogs = Location; - static constexpr bool kNameLogs = TagName; - static constexpr bool kBlobLogs = Blob; + static consteval auto GetTeleConfig() { + return TeleConfig{ + .count_metrics = Count, + .time_metrics = Time, + .logs_enabled = LogsEnabled, + .start_time_logs = StartTime, + .level_module_logs = LevelModule, + .location_logs = Location, + .name_logs = TagName, + .blob_logs = Blob, + }; }; - struct EnvConfig { - static constexpr bool kStaticInfo = true; - static constexpr bool kRuntimeInfo = true; - }; + static consteval auto GetEnvConfig() { + return EnvConfig{.static_info = true, .runtime_info = true}; + } }; } // namespace tele_configuration @@ -229,10 +230,16 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { - auto t = Tele>{ - Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, - "message {}", 12, - }; + auto t = + Tele()>{ + Sink::Instance(), + TestTag, + Level{Level::kDebug}, + "test-tele.cpp", + 8, + "message {}", + 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT_EQUAL(1, tele_trap->metric_data_.size()); @@ -259,10 +266,16 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { - auto t = Tele>{ - Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, - "message {}", 12, - }; + auto t = + Tele()>{ + Sink::Instance(), + TestTag, + Level{Level::kDebug}, + "test-tele.cpp", + 8, + "message {}", + 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT_EQUAL(1, tele_trap->metric_data_.size()); @@ -278,10 +291,16 @@ void test_TeleConfigurations() { auto tele_trap = std::make_shared(); Sink::Instance().SetTrap(tele_trap); { - auto t = Tele>{ - Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, - "message {}", 12, - }; + auto t = + Tele()>{ + Sink::Instance(), + TestTag, + Level{Level::kDebug}, + "test-tele.cpp", + 8, + "message {}", + 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT_EQUAL(1, tele_trap->metric_data_.size()); @@ -298,10 +317,16 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { - auto t = Tele>{ - Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, - "message {}", 12, - }; + auto t = + Tele()>{ + Sink::Instance(), + TestTag, + Level{Level::kDebug}, + "test-tele.cpp", + 8, + "message {}", + 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } TEST_ASSERT(tele_trap->metric_data_.empty()); @@ -316,10 +341,16 @@ void test_TeleConfigurations() { Sink::Instance().SetTrap(tele_trap); { - auto t = Tele>{ - Sink::Instance(), TestTag, Level{Level::kDebug}, "test-tele.cpp", 8, - "message {}", 12, - }; + auto t = + Tele()>{ + Sink::Instance(), + TestTag, + Level{Level::kDebug}, + "test-tele.cpp", + 8, + "message {}", + 12, + }; std::this_thread::sleep_for(std::chrono::milliseconds(10)); } @@ -478,19 +509,14 @@ void test_SaveLoadTeleStatistics() { ae::tele::MetricsStore::PackedIndex{TestObj.index_start + Test1.offset}; // simple check with _AE_MODULE_CONFIG leads here to AST broken error for // cppcheck - constexpr bool time_metrics_enabled = - TELE_SINK::ConfigProviderType::TeleConfig::kTimeMetrics; - if constexpr (time_metrics_enabled) { + if constexpr (TELE_SINK::GetTeleConfig() + .time_metrics) { TEST_ASSERT_EQUAL(metrics1.at(log_index).sum_duration, metrics2.at(log_index).sum_duration); } - constexpr bool count_metrics_enabled = - TELE_SINK::ConfigProviderType::TeleConfig::kCountMetrics; - - if constexpr (count_metrics_enabled) { + if constexpr (TELE_SINK::GetTeleConfig() + .count_metrics) { TEST_ASSERT_EQUAL(metrics1.at(log_index).invocations_count, metrics2.at(log_index).invocations_count); }