mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Add event observer via Broker's new API
This is a heavily modified version of 30615f425e
,
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.
This commit is contained in:
parent
6e8906c0d8
commit
ae14eff1f6
1 changed files with 10 additions and 0 deletions
|
@ -3,6 +3,8 @@
|
||||||
#include <broker/broker.hh>
|
#include <broker/broker.hh>
|
||||||
#include <broker/config.hh>
|
#include <broker/config.hh>
|
||||||
#include <broker/configuration.hh>
|
#include <broker/configuration.hh>
|
||||||
|
#include <broker/event_observer.hh>
|
||||||
|
#include <broker/logger.hh>
|
||||||
#include <broker/zeek.hh>
|
#include <broker/zeek.hh>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -112,6 +114,11 @@ void print_escaped(std::string& buf, std::string_view str) {
|
||||||
buf.push_back('"');
|
buf.push_back('"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class LoggerAdapter : public broker::event_observer {
|
||||||
|
public:
|
||||||
|
explicit LoggerAdapter() {}
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
namespace zeek::Broker {
|
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.moderate-steal-interval", get_option("Broker::moderate_interval")->AsCount());
|
||||||
config.set("caf.work-stealing.relaxed-steal-interval", get_option("Broker::relaxed_interval")->AsCount());
|
config.set("caf.work-stealing.relaxed-steal-interval", get_option("Broker::relaxed_interval")->AsCount());
|
||||||
|
|
||||||
|
auto adapter = std::make_shared<LoggerAdapter>();
|
||||||
|
broker::logger(adapter); // *must* be called before creating the BrokerState
|
||||||
|
|
||||||
auto cqs = get_option("Broker::congestion_queue_size")->AsCount();
|
auto cqs = get_option("Broker::congestion_queue_size")->AsCount();
|
||||||
bstate = std::make_shared<BrokerState>(std::move(config), cqs);
|
bstate = std::make_shared<BrokerState>(std::move(config), cqs);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue