mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Move logging code to zeek namespaces
This commit is contained in:
parent
9a800265ff
commit
45b5c6e619
25 changed files with 135 additions and 114 deletions
|
@ -127,7 +127,7 @@ void zeek::usage(const char* prog, int code)
|
|||
fprintf(stderr, " $ZEEK_PREFIXES | prefix list (%s)\n", bro_prefixes().c_str());
|
||||
fprintf(stderr, " $ZEEK_DNS_FAKE | disable DNS lookups (%s)\n", zeek::fake_dns() ? "on" : "off");
|
||||
fprintf(stderr, " $ZEEK_SEED_FILE | file to load seeds from (not set)\n");
|
||||
fprintf(stderr, " $ZEEK_LOG_SUFFIX | ASCII log file extension (.%s)\n", logging::writer::Ascii::LogExt().c_str());
|
||||
fprintf(stderr, " $ZEEK_LOG_SUFFIX | ASCII log file extension (.%s)\n", zeek::logging::writer::detail::Ascii::LogExt().c_str());
|
||||
fprintf(stderr, " $ZEEK_PROFILER_FILE | Output file for script execution statistics (not set)\n");
|
||||
fprintf(stderr, " $ZEEK_DISABLE_ZEEKYGEN | Disable Zeekygen documentation support (%s)\n", zeekenv("ZEEK_DISABLE_ZEEKYGEN") ? "set" : "not set");
|
||||
fprintf(stderr, " $ZEEK_DNS_RESOLVER | IPv4/IPv6 address of DNS resolver to use (%s)\n", zeekenv("ZEEK_DNS_RESOLVER") ? zeekenv("ZEEK_DNS_RESOLVER") : "not set, will use first IPv4 address from /etc/resolv.conf");
|
||||
|
|
|
@ -235,7 +235,7 @@ static void print_log(const std::vector<ValPtr>& vals)
|
|||
|
||||
record->Assign(0, zeek::make_intrusive<zeek::TimeVal>(network_time));
|
||||
record->Assign(1, std::move(vec));
|
||||
log_mgr->Write(plval.get(), record.get());
|
||||
zeek::log_mgr->Write(plval.get(), record.get());
|
||||
}
|
||||
|
||||
ValPtr PrintStmt::DoExec(std::vector<ValPtr> vals,
|
||||
|
|
|
@ -493,7 +493,7 @@ bool Manager::PublishIdentifier(std::string topic, std::string id)
|
|||
}
|
||||
|
||||
bool Manager::PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer,
|
||||
const logging::WriterBackend::WriterInfo& info,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info,
|
||||
int num_fields, const threading::Field* const * fields,
|
||||
const broker::endpoint_info& peer)
|
||||
{
|
||||
|
@ -1243,7 +1243,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
|||
return false;
|
||||
}
|
||||
|
||||
auto writer_info = std::unique_ptr<logging::WriterBackend::WriterInfo>(new logging::WriterBackend::WriterInfo);
|
||||
auto writer_info = std::make_unique<zeek::logging::WriterBackend::WriterInfo>();
|
||||
if ( ! writer_info->FromBroker(std::move(lc.writer_info())) )
|
||||
{
|
||||
zeek::reporter->Warning("failed to unpack remote log writer info");
|
||||
|
@ -1274,7 +1274,7 @@ bool bro_broker::Manager::ProcessLogCreate(broker::zeek::LogCreate lc)
|
|||
}
|
||||
}
|
||||
|
||||
if ( ! log_mgr->CreateWriterForRemoteLog(stream_id->AsEnumVal(), writer_id->AsEnumVal(), writer_info.release(), num_fields, fields) )
|
||||
if ( ! zeek::log_mgr->CreateWriterForRemoteLog(stream_id->AsEnumVal(), writer_id->AsEnumVal(), writer_info.release(), num_fields, fields) )
|
||||
{
|
||||
zeek::ODesc d;
|
||||
stream_id->Describe(&d);
|
||||
|
@ -1362,7 +1362,7 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw)
|
|||
}
|
||||
}
|
||||
|
||||
log_mgr->WriteFromRemote(stream_id->AsEnumVal(), writer_id->AsEnumVal(),
|
||||
zeek::log_mgr->WriteFromRemote(stream_id->AsEnumVal(), writer_id->AsEnumVal(),
|
||||
std::move(*path), num_fields, vals);
|
||||
fmt.EndRead();
|
||||
return true;
|
||||
|
@ -1419,7 +1419,7 @@ void Manager::ProcessStatus(broker::status stat)
|
|||
case broker::sc::peer_added:
|
||||
++peer_count;
|
||||
assert(ctx);
|
||||
log_mgr->SendAllWritersTo(*ctx);
|
||||
zeek::log_mgr->SendAllWritersTo(*ctx);
|
||||
event = Broker::peer_added;
|
||||
break;
|
||||
|
||||
|
|
|
@ -187,7 +187,7 @@ public:
|
|||
* @return true if the message is sent successfully.
|
||||
*/
|
||||
bool PublishLogCreate(zeek::EnumVal* stream, zeek::EnumVal* writer,
|
||||
const logging::WriterBackend::WriterInfo& info,
|
||||
const zeek::logging::WriterBackend::WriterInfo& info,
|
||||
int num_fields,
|
||||
const threading::Field* const * fields,
|
||||
const broker::endpoint_info& peer = NoPeer);
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#include "../Desc.h"
|
||||
#include "../util.h"
|
||||
|
||||
using namespace logging;
|
||||
namespace zeek::logging {
|
||||
|
||||
Component::Component(const std::string& name, factory_callback arg_factory)
|
||||
: zeek::plugin::Component(zeek::plugin::component::WRITER, name)
|
||||
|
@ -28,3 +28,5 @@ void Component::DoDescribe(zeek::ODesc* d) const
|
|||
d->Add("Log::WRITER_");
|
||||
d->Add(CanonicalName());
|
||||
}
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
|
|
@ -6,16 +6,16 @@
|
|||
#include "plugin/Component.h"
|
||||
#include "plugin/TaggedComponent.h"
|
||||
|
||||
namespace logging {
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(WriterFrontend, zeek, logging);
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(WriterBackend, zeek, logging);
|
||||
|
||||
class WriterFrontend;
|
||||
class WriterBackend;
|
||||
namespace zeek::logging {
|
||||
|
||||
/**
|
||||
* Component description for plugins providing log writers.
|
||||
*/
|
||||
class Component : public zeek::plugin::Component,
|
||||
public plugin::TaggedComponent<logging::Tag> {
|
||||
public zeek::plugin::TaggedComponent<logging::Tag> {
|
||||
public:
|
||||
typedef WriterBackend* (*factory_callback)(WriterFrontend* frontend);
|
||||
|
||||
|
@ -60,4 +60,4 @@ private:
|
|||
factory_callback factory;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace zeek::logging
|
||||
|
|
|
@ -28,7 +28,8 @@
|
|||
#include <broker/endpoint_info.hh>
|
||||
|
||||
using namespace std;
|
||||
using namespace logging;
|
||||
|
||||
namespace zeek::logging {
|
||||
|
||||
struct Manager::Filter {
|
||||
zeek::Val* fval;
|
||||
|
@ -1621,3 +1622,5 @@ bool Manager::FinishedRotation(WriterFrontend* writer, const char* new_name, con
|
|||
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
|
|
@ -16,17 +16,19 @@
|
|||
|
||||
namespace broker { struct endpoint_info; }
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(SerializationFormat, zeek::detail);
|
||||
class RotationTimer;
|
||||
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(WriterFrontend, zeek, logging);
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(RotationFinishedMessage, zeek, logging);
|
||||
|
||||
namespace zeek {
|
||||
namespace logging {
|
||||
|
||||
class WriterFrontend;
|
||||
class RotationFinishedMessage;
|
||||
class RotationTimer;
|
||||
|
||||
/**
|
||||
* Singleton class for managing log streams.
|
||||
*/
|
||||
class Manager : public plugin::ComponentManager<Tag, Component> {
|
||||
class Manager : public zeek::plugin::ComponentManager<Tag, Component> {
|
||||
public:
|
||||
|
||||
/**
|
||||
|
@ -251,7 +253,7 @@ protected:
|
|||
friend class WriterFrontend;
|
||||
friend class RotationFinishedMessage;
|
||||
friend class RotationFailedMessage;
|
||||
friend class ::RotationTimer;
|
||||
friend class RotationTimer;
|
||||
|
||||
// Instantiates a new WriterBackend of the given type (note that
|
||||
// doing so creates a new thread!).
|
||||
|
@ -298,6 +300,14 @@ private:
|
|||
zeek::FuncPtr rotation_format_func;
|
||||
};
|
||||
|
||||
}
|
||||
} // namespace logging;
|
||||
|
||||
extern logging::Manager* log_mgr;
|
||||
|
||||
} // namespace zeek
|
||||
|
||||
extern zeek::logging::Manager*& log_mgr [[deprecated("Remove in v4.1. Use zeek::log_mgr.")]];
|
||||
|
||||
namespace logging {
|
||||
using Manager [[deprecated("Remove in v4.1. Use zeek::logging::Manager.")]] = zeek::logging::Manager;
|
||||
}
|
||||
|
|
|
@ -3,39 +3,43 @@
|
|||
#include "Tag.h"
|
||||
#include "Manager.h"
|
||||
|
||||
const logging::Tag logging::Tag::Error;
|
||||
namespace zeek::logging {
|
||||
|
||||
logging::Tag::Tag(type_t type, subtype_t subtype)
|
||||
const Tag Tag::Error;
|
||||
|
||||
Tag::Tag(type_t type, subtype_t subtype)
|
||||
: zeek::Tag(log_mgr->GetTagType(), type, subtype)
|
||||
{
|
||||
}
|
||||
|
||||
logging::Tag& logging::Tag::operator=(const logging::Tag& other)
|
||||
Tag& Tag::operator=(const Tag& other)
|
||||
{
|
||||
zeek::Tag::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
logging::Tag& logging::Tag::operator=(const logging::Tag&& other) noexcept
|
||||
Tag& Tag::operator=(const Tag&& other) noexcept
|
||||
{
|
||||
zeek::Tag::operator=(other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
const zeek::EnumValPtr& logging::Tag::AsVal() const
|
||||
const zeek::EnumValPtr& Tag::AsVal() const
|
||||
{
|
||||
return zeek::Tag::AsVal(log_mgr->GetTagType());
|
||||
}
|
||||
|
||||
zeek::EnumVal* logging::Tag::AsEnumVal() const
|
||||
zeek::EnumVal* Tag::AsEnumVal() const
|
||||
{
|
||||
return AsVal().get();
|
||||
}
|
||||
|
||||
logging::Tag::Tag(zeek::EnumValPtr val)
|
||||
Tag::Tag(zeek::EnumValPtr val)
|
||||
: zeek::Tag(std::move(val))
|
||||
{ }
|
||||
|
||||
logging::Tag::Tag(zeek::EnumVal* val)
|
||||
Tag::Tag(zeek::EnumVal* val)
|
||||
: zeek::Tag({zeek::NewRef{}, val})
|
||||
{ }
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
|
|
@ -20,10 +20,10 @@ namespace plugin {
|
|||
zeek::plugin::ComponentManager<T, C>;
|
||||
}
|
||||
|
||||
namespace logging {
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(Manager, zeek, logging);
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(Component, zeek, logging);
|
||||
|
||||
class Manager;
|
||||
class Component;
|
||||
namespace zeek::logging {
|
||||
|
||||
/**
|
||||
* Class to identify a writer type.
|
||||
|
@ -128,4 +128,8 @@ protected:
|
|||
explicit Tag(zeek::EnumVal* val);
|
||||
};
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
||||
namespace logging {
|
||||
using Tag [[deprecated("Remove in v4.1. Use zeek::logging::Tag.")]] = zeek::logging::Tag;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
using threading::Value;
|
||||
using threading::Field;
|
||||
|
||||
namespace logging {
|
||||
namespace zeek::logging {
|
||||
|
||||
class RotationFinishedMessage final : public threading::OutputMessage<WriterFrontend>
|
||||
{
|
||||
|
@ -63,12 +63,8 @@ public:
|
|||
bool Process() override { Object()->SetDisable(); return true; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Backend methods.
|
||||
|
||||
using namespace logging;
|
||||
|
||||
broker::data WriterBackend::WriterInfo::ToBroker() const
|
||||
{
|
||||
auto t = broker::table();
|
||||
|
@ -331,3 +327,5 @@ bool WriterBackend::OnHeartbeat(double network_time, double current_time)
|
|||
SendOut(new FlushWriteBufferMessage(frontend));
|
||||
return DoHeartbeat(network_time, current_time);
|
||||
}
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace broker { class data; }
|
||||
|
||||
namespace logging {
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(WriterFrontend, zeek, logging);
|
||||
|
||||
class WriterFrontend;
|
||||
namespace zeek::logging {
|
||||
|
||||
/**
|
||||
* Base class for writer implementation. When the logging::Manager creates a
|
||||
|
@ -398,5 +398,8 @@ private:
|
|||
int rotation_counter; // Tracks FinishedRotation() calls.
|
||||
};
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
||||
namespace logging {
|
||||
using WriterBackend [[deprecated("Remove in v4.1. Use zeek::logging::WriterBackend.")]] = zeek::logging::WriterBackend;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
using threading::Value;
|
||||
using threading::Field;
|
||||
|
||||
namespace logging {
|
||||
namespace zeek::logging {
|
||||
|
||||
// Messages sent from frontend to backend (i.e., "InputMessages").
|
||||
|
||||
|
@ -22,7 +22,6 @@ public:
|
|||
num_fields(num_fields), fields(fields)
|
||||
{}
|
||||
|
||||
|
||||
bool Process() override { return Object()->Init(num_fields, fields); }
|
||||
|
||||
private:
|
||||
|
@ -92,12 +91,8 @@ private:
|
|||
double network_time;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// Frontend methods.
|
||||
|
||||
using namespace logging;
|
||||
|
||||
WriterFrontend::WriterFrontend(const WriterBackend::WriterInfo& arg_info, zeek::EnumVal* arg_stream,
|
||||
zeek::EnumVal* arg_writer, bool arg_local, bool arg_remote)
|
||||
{
|
||||
|
@ -299,3 +294,5 @@ void WriterFrontend::DeleteVals(int num_fields, Value** vals)
|
|||
|
||||
delete [] vals;
|
||||
}
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
|
||||
#include "WriterBackend.h"
|
||||
|
||||
namespace logging {
|
||||
ZEEK_FORWARD_DECLARE_NAMESPACED(Manager, zeek, logging);
|
||||
|
||||
class Manager;
|
||||
namespace zeek::logging {
|
||||
|
||||
/**
|
||||
* Bridge class between the logging::Manager and backend writer threads. The
|
||||
|
@ -209,4 +209,8 @@ protected:
|
|||
threading::Value*** write_buffer; // Buffer of size WRITER_BUFFER_SIZE.
|
||||
};
|
||||
|
||||
} // namespace zeek::logging
|
||||
|
||||
namespace logging {
|
||||
using WriterFrontend [[deprecated("Remove in v4.1. Use zeek::logging::WriterFrontend.")]] = zeek::logging::WriterFrontend;
|
||||
}
|
||||
|
|
|
@ -19,54 +19,54 @@ enum PrintLogType %{
|
|||
|
||||
function Log::__create_stream%(id: Log::ID, stream: Log::Stream%) : bool
|
||||
%{
|
||||
bool result = log_mgr->CreateStream(id->AsEnumVal(), stream->AsRecordVal());
|
||||
bool result = zeek::log_mgr->CreateStream(id->AsEnumVal(), stream->AsRecordVal());
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__remove_stream%(id: Log::ID%) : bool
|
||||
%{
|
||||
bool result = log_mgr->RemoveStream(id->AsEnumVal());
|
||||
bool result = zeek::log_mgr->RemoveStream(id->AsEnumVal());
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__enable_stream%(id: Log::ID%) : bool
|
||||
%{
|
||||
bool result = log_mgr->EnableStream(id->AsEnumVal());
|
||||
bool result = zeek::log_mgr->EnableStream(id->AsEnumVal());
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__disable_stream%(id: Log::ID%) : bool
|
||||
%{
|
||||
bool result = log_mgr->DisableStream(id->AsEnumVal());
|
||||
bool result = zeek::log_mgr->DisableStream(id->AsEnumVal());
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__add_filter%(id: Log::ID, filter: Log::Filter%) : bool
|
||||
%{
|
||||
bool result = log_mgr->AddFilter(id->AsEnumVal(), filter->AsRecordVal());
|
||||
bool result = zeek::log_mgr->AddFilter(id->AsEnumVal(), filter->AsRecordVal());
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__remove_filter%(id: Log::ID, name: string%) : bool
|
||||
%{
|
||||
bool result = log_mgr->RemoveFilter(id->AsEnumVal(), name);
|
||||
bool result = zeek::log_mgr->RemoveFilter(id->AsEnumVal(), name);
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__write%(id: Log::ID, columns: any%) : bool
|
||||
%{
|
||||
bool result = log_mgr->Write(id->AsEnumVal(), columns->AsRecordVal());
|
||||
bool result = zeek::log_mgr->Write(id->AsEnumVal(), columns->AsRecordVal());
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__set_buf%(id: Log::ID, buffered: bool%): bool
|
||||
%{
|
||||
bool result = log_mgr->SetBuf(id->AsEnumVal(), buffered);
|
||||
bool result = zeek::log_mgr->SetBuf(id->AsEnumVal(), buffered);
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
||||
function Log::__flush%(id: Log::ID%): bool
|
||||
%{
|
||||
bool result = log_mgr->Flush(id->AsEnumVal());
|
||||
bool result = zeek::log_mgr->Flush(id->AsEnumVal());
|
||||
return zeek::val_mgr->Bool(result);
|
||||
%}
|
||||
|
|
|
@ -23,13 +23,14 @@
|
|||
#include "ascii.bif.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace logging::writer;
|
||||
using namespace threading;
|
||||
using threading::Value;
|
||||
using threading::Field;
|
||||
|
||||
static constexpr auto shadow_file_prefix = ".shadow.";
|
||||
|
||||
namespace zeek::logging::writer::detail {
|
||||
|
||||
/**
|
||||
* Information about an leftover log file: that is, one that a previous
|
||||
* process was in the middle of writing, but never completed a rotation
|
||||
|
@ -190,7 +191,7 @@ static std::optional<LeftoverLog> parse_shadow_log(const std::string& fname)
|
|||
return rval;
|
||||
}
|
||||
|
||||
Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
|
||||
Ascii::Ascii(zeek::logging::WriterFrontend* frontend) : zeek::logging::WriterBackend(frontend)
|
||||
{
|
||||
fd = 0;
|
||||
ascii_done = false;
|
||||
|
@ -783,7 +784,7 @@ void Ascii::RotateLeftoverLogs()
|
|||
ll.filename.data(), ll.post_proc_func.data());
|
||||
}
|
||||
|
||||
auto rotation_path = log_mgr->FormatRotationPath(
|
||||
auto rotation_path = zeek::log_mgr->FormatRotationPath(
|
||||
writer_val, ll.Path(), ll.open_time, ll.close_time, false, ppf);
|
||||
|
||||
rotation_path += ll.extension;
|
||||
|
@ -908,3 +909,5 @@ bool Ascii::InternalClose(int fd)
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace zeek::logging::writer::detail
|
||||
|
|
|
@ -10,18 +10,18 @@
|
|||
#include "Desc.h"
|
||||
#include "zlib.h"
|
||||
|
||||
namespace plugin::Zeek_AsciiWriter { class Plugin; }
|
||||
namespace zeek::plugin::Zeek_AsciiWriter { class Plugin; }
|
||||
|
||||
namespace logging { namespace writer {
|
||||
namespace zeek::logging::writer::detail {
|
||||
|
||||
class Ascii : public WriterBackend {
|
||||
class Ascii : public zeek::logging::WriterBackend {
|
||||
public:
|
||||
explicit Ascii(WriterFrontend* frontend);
|
||||
explicit Ascii(zeek::logging::WriterFrontend* frontend);
|
||||
~Ascii() override;
|
||||
|
||||
static std::string LogExt();
|
||||
|
||||
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
||||
static zeek::logging::WriterBackend* Instantiate(zeek::logging::WriterFrontend* frontend)
|
||||
{ return new Ascii(frontend); }
|
||||
|
||||
protected:
|
||||
|
@ -79,5 +79,4 @@ private:
|
|||
bool init_options;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace zeek::logging::writer::detail
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
|
||||
#include "Ascii.h"
|
||||
|
||||
namespace plugin {
|
||||
namespace Zeek_AsciiWriter {
|
||||
namespace zeek::plugin::Zeek_AsciiWriter {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
public:
|
||||
zeek::plugin::Configuration Configure() override
|
||||
{
|
||||
AddComponent(new ::logging::Component("Ascii", ::logging::writer::Ascii::Instantiate));
|
||||
AddComponent(new zeek::logging::Component("Ascii", zeek::logging::writer::detail::Ascii::Instantiate));
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Zeek::AsciiWriter";
|
||||
|
@ -20,13 +19,11 @@ public:
|
|||
return config;
|
||||
}
|
||||
protected:
|
||||
void InitPostScript() override;
|
||||
void InitPostScript() override
|
||||
{
|
||||
zeek::logging::writer::detail::Ascii::RotateLeftoverLogs();
|
||||
}
|
||||
|
||||
} plugin;
|
||||
|
||||
void Plugin::InitPostScript()
|
||||
{
|
||||
::logging::writer::Ascii::RotateLeftoverLogs();
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace zeek::plugin::Zeek_AsciiWriter
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
|
||||
#include "None.h"
|
||||
#include "none.bif.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace logging;
|
||||
using namespace writer;
|
||||
namespace zeek::logging::writer::detail {
|
||||
|
||||
bool None::DoInit(const WriterInfo& info, int num_fields,
|
||||
const threading::Field* const * fields)
|
||||
|
@ -54,3 +52,5 @@ bool None::DoRotate(const char* rotated_path, double open, double close, bool te
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace zeek::logging::writer::detail
|
||||
|
|
|
@ -6,14 +6,14 @@
|
|||
|
||||
#include "logging/WriterBackend.h"
|
||||
|
||||
namespace logging { namespace writer {
|
||||
namespace zeek::logging::writer::detail {
|
||||
|
||||
class None : public WriterBackend {
|
||||
class None : public zeek::logging::WriterBackend {
|
||||
public:
|
||||
explicit None(WriterFrontend* frontend) : WriterBackend(frontend) {}
|
||||
explicit None(zeek::logging::WriterFrontend* frontend) : zeek::logging::WriterBackend(frontend) {}
|
||||
~None() override {};
|
||||
|
||||
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
||||
static zeek::logging::WriterBackend* Instantiate(zeek::logging::WriterFrontend* frontend)
|
||||
{ return new None(frontend); }
|
||||
|
||||
protected:
|
||||
|
@ -29,5 +29,4 @@ protected:
|
|||
bool DoHeartbeat(double network_time, double current_time) override { return true; }
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace zeek::logging::writer::detail
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
|
||||
#include "None.h"
|
||||
|
||||
namespace plugin {
|
||||
namespace Zeek_NoneWriter {
|
||||
namespace zeek::plugin::Zeek_NoneWriter {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
public:
|
||||
zeek::plugin::Configuration Configure() override
|
||||
{
|
||||
AddComponent(new ::logging::Component("None", ::logging::writer::None::Instantiate));
|
||||
AddComponent(new zeek::logging::Component("None", zeek::logging::writer::detail::None::Instantiate));
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Zeek::NoneWriter";
|
||||
|
@ -21,5 +20,4 @@ public:
|
|||
}
|
||||
} plugin;
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace zeek::plugin::Zeek_NoneWriter
|
||||
|
|
|
@ -5,14 +5,13 @@
|
|||
|
||||
#include "SQLite.h"
|
||||
|
||||
namespace plugin {
|
||||
namespace Zeek_SQLiteWriter {
|
||||
namespace zeek::plugin::Zeek_SQLiteWriter {
|
||||
|
||||
class Plugin : public zeek::plugin::Plugin {
|
||||
public:
|
||||
zeek::plugin::Configuration Configure() override
|
||||
{
|
||||
AddComponent(new ::logging::Component("SQLite", ::logging::writer::SQLite::Instantiate));
|
||||
AddComponent(new zeek::logging::Component("SQLite", zeek::logging::writer::detail::SQLite::Instantiate));
|
||||
|
||||
zeek::plugin::Configuration config;
|
||||
config.name = "Zeek::SQLiteWriter";
|
||||
|
@ -21,5 +20,4 @@ public:
|
|||
}
|
||||
} plugin;
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace zeek::plugin::Zeek_SQLiteWriter
|
||||
|
|
|
@ -12,13 +12,13 @@
|
|||
#include "sqlite.bif.h"
|
||||
|
||||
using namespace std;
|
||||
using namespace logging;
|
||||
using namespace writer;
|
||||
using threading::Value;
|
||||
using threading::Field;
|
||||
|
||||
SQLite::SQLite(WriterFrontend* frontend)
|
||||
: WriterBackend(frontend),
|
||||
namespace zeek::logging::writer::detail {
|
||||
|
||||
SQLite::SQLite(zeek::logging::WriterFrontend* frontend)
|
||||
: zeek::logging::WriterBackend(frontend),
|
||||
fields(), num_fields(), db(), st()
|
||||
{
|
||||
set_separator.assign(
|
||||
|
@ -365,3 +365,5 @@ bool SQLite::DoRotate(const char* rotated_path, double open, double close, bool
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace zeek::logging::writer::detail
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
#include "3rdparty/sqlite3.h"
|
||||
#include "Desc.h"
|
||||
|
||||
namespace logging { namespace writer {
|
||||
namespace zeek::logging::writer::detail {
|
||||
|
||||
class SQLite : public WriterBackend {
|
||||
class SQLite : public zeek::logging::WriterBackend {
|
||||
public:
|
||||
explicit SQLite(WriterFrontend* frontend);
|
||||
explicit SQLite(zeek::logging::WriterFrontend* frontend);
|
||||
~SQLite() override;
|
||||
|
||||
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
||||
static zeek::logging::WriterBackend* Instantiate(zeek::logging::WriterFrontend* frontend)
|
||||
{ return new SQLite(frontend); }
|
||||
|
||||
protected:
|
||||
|
@ -52,5 +52,4 @@ private:
|
|||
threading::formatter::Ascii* io;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace zeek::logging::writer::detail
|
||||
|
|
|
@ -102,7 +102,8 @@ zeek::detail::DNS_Mgr*& dns_mgr = zeek::detail::dns_mgr;
|
|||
zeek::detail::TimerMgr* zeek::detail::timer_mgr = nullptr;
|
||||
zeek::detail::TimerMgr*& timer_mgr = zeek::detail::timer_mgr;
|
||||
|
||||
logging::Manager* log_mgr = nullptr;
|
||||
zeek::logging::Manager* zeek::log_mgr = nullptr;
|
||||
zeek::logging::Manager*& log_mgr = zeek::log_mgr;
|
||||
threading::Manager* thread_mgr = nullptr;
|
||||
zeek::input::Manager* zeek::input_mgr = nullptr;
|
||||
zeek::input::Manager*& input_mgr = zeek::input_mgr;
|
||||
|
@ -305,7 +306,7 @@ void terminate_bro()
|
|||
zeek::event_mgr.Drain();
|
||||
|
||||
notifier::registry.Terminate();
|
||||
log_mgr->Terminate();
|
||||
zeek::log_mgr->Terminate();
|
||||
zeek::input_mgr->Terminate();
|
||||
thread_mgr->Terminate();
|
||||
broker_mgr->Terminate();
|
||||
|
@ -321,7 +322,7 @@ void terminate_bro()
|
|||
// broker_mgr, timer_mgr, and supervisor are deleted via iosource_mgr
|
||||
delete iosource_mgr;
|
||||
delete zeek::event_registry;
|
||||
delete log_mgr;
|
||||
delete zeek::log_mgr;
|
||||
delete zeek::reporter;
|
||||
delete zeek::plugin_mgr;
|
||||
delete zeek::val_mgr;
|
||||
|
@ -581,7 +582,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
iosource_mgr = new iosource::Manager();
|
||||
event_registry = new EventRegistry();
|
||||
zeek::analyzer_mgr = new analyzer::Manager();
|
||||
log_mgr = new logging::Manager();
|
||||
zeek::log_mgr = new logging::Manager();
|
||||
zeek::input_mgr = new input::Manager();
|
||||
zeek::file_mgr = new file_analysis::Manager();
|
||||
auto broker_real_time = ! options.pcap_file && ! options.deterministic_mode;
|
||||
|
@ -659,7 +660,7 @@ zeek::detail::SetupResult zeek::detail::setup(int argc, char** argv,
|
|||
exit(1);
|
||||
|
||||
iosource_mgr->InitPostScript();
|
||||
log_mgr->InitPostScript();
|
||||
zeek::log_mgr->InitPostScript();
|
||||
zeek::plugin_mgr->InitPostScript();
|
||||
zeekygen_mgr->InitPostScript();
|
||||
broker_mgr->InitPostScript();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue