From ae14eff1f60134690912a7533dafd452557670f6 Mon Sep 17 00:00:00 2001 From: Christian Kreibich Date: Mon, 28 Apr 2025 17:51:20 -0700 Subject: [PATCH] Add event observer via Broker's new API This is a heavily modified version of 30615f425ef956755f4660a6b11fa3effc3e3c24, part of PR #3998, removing all of the logging-specific parts. It only establishes the basic adapter and the broker::logging() call to register it. --- src/broker/Manager.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index b5407d413a..b2443efb0e 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -3,6 +3,8 @@ #include #include #include +#include +#include #include #include #include @@ -112,6 +114,11 @@ void print_escaped(std::string& buf, std::string_view str) { buf.push_back('"'); } +class LoggerAdapter : public broker::event_observer { +public: + explicit LoggerAdapter() {} +}; + } // namespace namespace zeek::Broker { @@ -361,6 +368,9 @@ void Manager::InitPostScript() { config.set("caf.work-stealing.moderate-steal-interval", get_option("Broker::moderate_interval")->AsCount()); config.set("caf.work-stealing.relaxed-steal-interval", get_option("Broker::relaxed_interval")->AsCount()); + auto adapter = std::make_shared(); + broker::logger(adapter); // *must* be called before creating the BrokerState + auto cqs = get_option("Broker::congestion_queue_size")->AsCount(); bstate = std::make_shared(std::move(config), cqs);