mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Move DebugLogger to zeek namespaces
This commit is contained in:
parent
a2a435360a
commit
886fc102b8
40 changed files with 358 additions and 317 deletions
|
@ -143,7 +143,7 @@ Manager::~Manager()
|
|||
|
||||
void Manager::InitPostScript()
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Initializing");
|
||||
DBG_LOG(zeek::DBG_BROKER, "Initializing");
|
||||
|
||||
log_batch_size = get_option("Broker::log_batch_size")->AsCount();
|
||||
default_log_topic_prefix =
|
||||
|
@ -355,7 +355,7 @@ uint16_t Manager::Listen(const string& addr, uint16_t port)
|
|||
// Register as a "does-count" source now.
|
||||
iosource_mgr->Register(this, false);
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Listening on %s:%" PRIu16,
|
||||
DBG_LOG(zeek::DBG_BROKER, "Listening on %s:%" PRIu16,
|
||||
addr.empty() ? "INADDR_ANY" : addr.c_str(), port);
|
||||
|
||||
return bound_port;
|
||||
|
@ -366,7 +366,7 @@ void Manager::Peer(const string& addr, uint16_t port, double retry)
|
|||
if ( bstate->endpoint.is_shutdown() )
|
||||
return;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Starting to peer with %s:%" PRIu16,
|
||||
DBG_LOG(zeek::DBG_BROKER, "Starting to peer with %s:%" PRIu16,
|
||||
addr.c_str(), port);
|
||||
|
||||
auto e = zeekenv("ZEEK_DEFAULT_CONNECT_RETRY");
|
||||
|
@ -393,7 +393,7 @@ void Manager::Unpeer(const string& addr, uint16_t port)
|
|||
if ( bstate->endpoint.is_shutdown() )
|
||||
return;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Stopping to peer with %s:%" PRIu16,
|
||||
DBG_LOG(zeek::DBG_BROKER, "Stopping to peer with %s:%" PRIu16,
|
||||
addr.c_str(), port);
|
||||
|
||||
FlushLogBuffers();
|
||||
|
@ -421,7 +421,7 @@ bool Manager::PublishEvent(string topic, std::string name, broker::vector args)
|
|||
if ( peer_count == 0 )
|
||||
return true;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Publishing event: %s",
|
||||
DBG_LOG(zeek::DBG_BROKER, "Publishing event: %s",
|
||||
RenderEvent(topic, name, args).c_str());
|
||||
broker::zeek::Event ev(std::move(name), std::move(args));
|
||||
bstate->endpoint.publish(move(topic), ev.move_data());
|
||||
|
@ -485,7 +485,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
|
|||
}
|
||||
|
||||
broker::zeek::IdentifierUpdate msg(move(id), move(*data));
|
||||
DBG_LOG(DBG_BROKER, "Publishing id-update: %s",
|
||||
DBG_LOG(zeek::DBG_BROKER, "Publishing id-update: %s",
|
||||
RenderMessage(topic, msg.as_data()).c_str());
|
||||
bstate->endpoint.publish(move(topic), msg.move_data());
|
||||
++statistics.num_ids_outgoing;
|
||||
|
@ -537,7 +537,7 @@ bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer,
|
|||
auto bwriter_id = broker::enum_value(move(writer_id));
|
||||
broker::zeek::LogCreate msg(move(bstream_id), move(bwriter_id), move(writer_info), move(fields_data));
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Publishing log creation: %s", RenderMessage(topic, msg.as_data()).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Publishing log creation: %s", RenderMessage(topic, msg.as_data()).c_str());
|
||||
|
||||
if ( peer.node != NoPeer.node )
|
||||
// Direct message.
|
||||
|
@ -622,7 +622,7 @@ bool Manager::PublishLogWrite(zeek::EnumVal* stream, zeek::EnumVal* writer, stri
|
|||
broker::zeek::LogWrite msg(move(bstream_id), move(bwriter_id), move(path),
|
||||
move(serial_data));
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Buffering log record: %s", RenderMessage(topic, msg.as_data()).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Buffering log record: %s", RenderMessage(topic, msg.as_data()).c_str());
|
||||
|
||||
if ( log_buffers.size() <= (unsigned int)stream_id_num )
|
||||
log_buffers.resize(stream_id_num + 1);
|
||||
|
@ -665,7 +665,7 @@ size_t Manager::LogBuffer::Flush(broker::endpoint& endpoint, size_t log_batch_si
|
|||
|
||||
size_t Manager::FlushLogBuffers()
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Flushing all log buffers");
|
||||
DBG_LOG(zeek::DBG_BROKER, "Flushing all log buffers");
|
||||
auto rval = 0u;
|
||||
|
||||
for ( auto& lb : log_buffers )
|
||||
|
@ -711,7 +711,7 @@ bool Manager::AutoPublishEvent(string topic, zeek::Val* event)
|
|||
return false;
|
||||
}
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Enabling auto-publising of event %s to topic %s", handler->Name(), topic.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Enabling auto-publising of event %s to topic %s", handler->Name(), topic.c_str());
|
||||
handler->AutoPublish(move(topic));
|
||||
|
||||
return true;
|
||||
|
@ -743,7 +743,7 @@ bool Manager::AutoUnpublishEvent(const string& topic, zeek::Val* event)
|
|||
}
|
||||
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Disabling auto-publishing of event %s to topic %s", handler->Name(), topic.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Disabling auto-publishing of event %s to topic %s", handler->Name(), topic.c_str());
|
||||
handler->AutoUnpublish(topic);
|
||||
|
||||
return true;
|
||||
|
@ -827,7 +827,7 @@ zeek::RecordVal* Manager::MakeEvent(val_list* args, zeek::detail::Frame* frame)
|
|||
|
||||
bool Manager::Subscribe(const string& topic_prefix)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Subscribing to topic prefix %s", topic_prefix.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Subscribing to topic prefix %s", topic_prefix.c_str());
|
||||
bstate->subscriber.add_topic(topic_prefix, ! after_zeek_init);
|
||||
|
||||
// For backward compatibility, we also may receive messages on
|
||||
|
@ -847,7 +847,7 @@ bool Manager::Forward(string topic_prefix)
|
|||
if ( prefix == topic_prefix )
|
||||
return false;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Forwarding topic prefix %s", topic_prefix.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Forwarding topic prefix %s", topic_prefix.c_str());
|
||||
Subscribe(topic_prefix);
|
||||
forwarded_prefixes.emplace_back(std::move(topic_prefix));
|
||||
return true;
|
||||
|
@ -858,12 +858,12 @@ bool Manager::Unsubscribe(const string& topic_prefix)
|
|||
for ( size_t i = 0; i < forwarded_prefixes.size(); ++i )
|
||||
if ( forwarded_prefixes[i] == topic_prefix )
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Unforwading topic prefix %s", topic_prefix.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Unforwading topic prefix %s", topic_prefix.c_str());
|
||||
forwarded_prefixes.erase(forwarded_prefixes.begin() + i);
|
||||
break;
|
||||
}
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Unsubscribing from topic prefix %s", topic_prefix.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Unsubscribing from topic prefix %s", topic_prefix.c_str());
|
||||
bstate->subscriber.remove_topic(topic_prefix, ! after_zeek_init);
|
||||
return true;
|
||||
}
|
||||
|
@ -1016,11 +1016,11 @@ void Manager::ProcessStoreEventInsertUpdate(const zeek::TableValPtr& table,
|
|||
|
||||
if ( insert )
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Store %s: Insert: %s:%s (%s:%s)", store_id.c_str(), to_string(key).c_str(), to_string(data).c_str(), key.get_type_name(), data.get_type_name());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Store %s: Insert: %s:%s (%s:%s)", store_id.c_str(), to_string(key).c_str(), to_string(data).c_str(), key.get_type_name(), data.get_type_name());
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Store %s: Update: %s->%s (%s)", store_id.c_str(), to_string(old_value).c_str(), to_string(data).c_str(), data.get_type_name());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Store %s: Update: %s->%s (%s)", store_id.c_str(), to_string(old_value).c_str(), to_string(data).c_str(), data.get_type_name());
|
||||
}
|
||||
|
||||
if ( table->GetType()->IsSet() && data.get_type() != broker::data::type::none )
|
||||
|
@ -1104,7 +1104,7 @@ void Manager::ProcessStoreEvent(broker::data msg)
|
|||
return;
|
||||
|
||||
auto key = erase.key();
|
||||
DBG_LOG(DBG_BROKER, "Store %s: Erase key %s", erase.store_id().c_str(), to_string(key).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Store %s: Erase key %s", erase.store_id().c_str(), to_string(key).c_str());
|
||||
const auto& its = table->GetType()->AsTableType()->GetIndexTypes();
|
||||
assert( its.size() == 1 );
|
||||
auto zeek_key = data_to_val(key, its[0].get());
|
||||
|
@ -1129,7 +1129,7 @@ void Manager::ProcessStoreEvent(broker::data msg)
|
|||
if ( ! table )
|
||||
return;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Store %s: Store expired key %s", expire.store_id().c_str(), to_string(expire.key()).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Store %s: Store expired key %s", expire.store_id().c_str(), to_string(expire.key()).c_str());
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
else
|
||||
|
@ -1150,7 +1150,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
|||
auto name = std::move(ev.name());
|
||||
auto args = std::move(ev.args());
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Process event: %s %s",
|
||||
DBG_LOG(zeek::DBG_BROKER, "Process event: %s %s",
|
||||
name.data(), RenderMessage(args).data());
|
||||
++statistics.num_events_incoming;
|
||||
auto handler = zeek::event_registry->Lookup(name);
|
||||
|
@ -1168,7 +1168,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
|||
if ( strncmp(p.data(), topic_string.data(), p.size()) != 0 )
|
||||
continue;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Skip processing of forwarded event: %s %s",
|
||||
DBG_LOG(zeek::DBG_BROKER, "Skip processing of forwarded event: %s %s",
|
||||
name.data(), RenderMessage(args).data());
|
||||
return;
|
||||
}
|
||||
|
@ -1221,7 +1221,7 @@ void Manager::ProcessEvent(const broker::topic& topic, broker::zeek::Event ev)
|
|||
|
||||
bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received log-create: %s", RenderMessage(lc.as_data()).c_str());
|
||||
if ( ! lc.valid() )
|
||||
{
|
||||
zeek::reporter->Warning("received invalid broker LogCreate: %s",
|
||||
|
@ -1286,7 +1286,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
|||
|
||||
bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Received log-write: %s", RenderMessage(lw.as_data()).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received log-write: %s", RenderMessage(lw.as_data()).c_str());
|
||||
|
||||
if ( ! lw.valid() )
|
||||
{
|
||||
|
@ -1370,7 +1370,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
|
|||
|
||||
bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Received id-update: %s", RenderMessage(iu.as_data()).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received id-update: %s", RenderMessage(iu.as_data()).c_str());
|
||||
|
||||
if ( ! iu.valid() )
|
||||
{
|
||||
|
@ -1406,7 +1406,7 @@ bool Manager::ProcessIdentifierUpdate(broker::zeek::IdentifierUpdate iu)
|
|||
|
||||
void Manager::ProcessStatus(broker::status stat)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Received status message: %s", RenderMessage(stat).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received status message: %s", RenderMessage(stat).c_str());
|
||||
|
||||
auto ctx = stat.context<broker::endpoint_info>();
|
||||
|
||||
|
@ -1474,7 +1474,7 @@ void Manager::ProcessStatus(broker::status stat)
|
|||
|
||||
void Manager::ProcessError(broker::error err)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Received error message: %s", RenderMessage(err).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received error message: %s", RenderMessage(err).c_str());
|
||||
|
||||
if ( ! Broker::error )
|
||||
return;
|
||||
|
@ -1509,7 +1509,7 @@ void Manager::ProcessError(broker::error err)
|
|||
|
||||
void Manager::ProcessStoreResponse(StoreHandleVal* s, broker::store::response response)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Received store response: %s", RenderMessage(response).c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Received store response: %s", RenderMessage(response).c_str());
|
||||
|
||||
auto request = pending_queries.find(std::make_pair(response.id, s));
|
||||
|
||||
|
@ -1561,7 +1561,7 @@ StoreHandleVal* Manager::MakeMaster(const string& name, broker::backend type,
|
|||
if ( LookupStore(name) )
|
||||
return nullptr;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Creating master for data store %s", name.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Creating master for data store %s", name.c_str());
|
||||
|
||||
auto it = opts.find("path");
|
||||
|
||||
|
@ -1679,7 +1679,7 @@ StoreHandleVal* Manager::MakeClone(const string& name, double resync_interval,
|
|||
if ( LookupStore(name) )
|
||||
return nullptr;
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Creating clone for data store %s", name.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Creating clone for data store %s", name.c_str());
|
||||
|
||||
auto result = bstate->endpoint.attach_clone(name, resync_interval,
|
||||
stale_interval,
|
||||
|
@ -1708,7 +1708,7 @@ StoreHandleVal* Manager::LookupStore(const string& name)
|
|||
|
||||
bool Manager::CloseStore(const string& name)
|
||||
{
|
||||
DBG_LOG(DBG_BROKER, "Closing data store %s", name.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Closing data store %s", name.c_str());
|
||||
|
||||
auto s = data_stores.find(name);
|
||||
if ( s == data_stores.end() )
|
||||
|
@ -1764,7 +1764,7 @@ bool Manager::AddForwardedStore(const std::string& name, zeek::TableValPtr table
|
|||
return false;
|
||||
}
|
||||
|
||||
DBG_LOG(DBG_BROKER, "Adding table forward for data store %s", name.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Adding table forward for data store %s", name.c_str());
|
||||
forwarded_stores.emplace(name, std::move(table));
|
||||
|
||||
PrepareForwarding(name);
|
||||
|
@ -1781,7 +1781,7 @@ void Manager::PrepareForwarding(const std::string &name)
|
|||
return;
|
||||
|
||||
handle->forward_to = forwarded_stores.at(name);
|
||||
DBG_LOG(DBG_BROKER, "Resolved table forward for data store %s", name.c_str());
|
||||
DBG_LOG(zeek::DBG_BROKER, "Resolved table forward for data store %s", name.c_str());
|
||||
}
|
||||
|
||||
} // namespace bro_broker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue