diff --git a/src/Options.cc b/src/Options.cc index 1bac746291..747591a19b 100644 --- a/src/Options.cc +++ b/src/Options.cc @@ -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"); diff --git a/src/Stmt.cc b/src/Stmt.cc index 95105e8066..77e0afed29 100644 --- a/src/Stmt.cc +++ b/src/Stmt.cc @@ -235,7 +235,7 @@ static void print_log(const std::vector& vals) record->Assign(0, zeek::make_intrusive(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 vals, diff --git a/src/broker/Manager.cc b/src/broker/Manager.cc index c83b75abde..9cbbc51d1f 100644 --- a/src/broker/Manager.cc +++ b/src/broker/Manager.cc @@ -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(new logging::WriterBackend::WriterInfo); + auto writer_info = std::make_unique(); 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,8 +1362,8 @@ bool bro_broker::Manager::ProcessLogWrite(broker::zeek::LogWrite lw) } } - log_mgr->WriteFromRemote(stream_id->AsEnumVal(), writer_id->AsEnumVal(), - std::move(*path), num_fields, vals); + 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; diff --git a/src/broker/Manager.h b/src/broker/Manager.h index 953bdd1aa7..d8a461b625 100644 --- a/src/broker/Manager.h +++ b/src/broker/Manager.h @@ -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); diff --git a/src/logging/Component.cc b/src/logging/Component.cc index d3f5807307..644bc83c11 100644 --- a/src/logging/Component.cc +++ b/src/logging/Component.cc @@ -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 diff --git a/src/logging/Component.h b/src/logging/Component.h index 8a98f9afa1..d0cb52615f 100644 --- a/src/logging/Component.h +++ b/src/logging/Component.h @@ -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 { + public zeek::plugin::TaggedComponent { public: typedef WriterBackend* (*factory_callback)(WriterFrontend* frontend); @@ -60,4 +60,4 @@ private: factory_callback factory; }; -} +} // namespace zeek::logging diff --git a/src/logging/Manager.cc b/src/logging/Manager.cc index 690099cb11..3257855bef 100644 --- a/src/logging/Manager.cc +++ b/src/logging/Manager.cc @@ -28,7 +28,8 @@ #include 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 diff --git a/src/logging/Manager.h b/src/logging/Manager.h index 60bf4819da..042686a80a 100644 --- a/src/logging/Manager.h +++ b/src/logging/Manager.h @@ -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 { +class Manager : public zeek::plugin::ComponentManager { 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; +} diff --git a/src/logging/Tag.cc b/src/logging/Tag.cc index ffe366f48d..7600ebbf31 100644 --- a/src/logging/Tag.cc +++ b/src/logging/Tag.cc @@ -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 diff --git a/src/logging/Tag.h b/src/logging/Tag.h index b3a05920e9..daf5fc152b 100644 --- a/src/logging/Tag.h +++ b/src/logging/Tag.h @@ -20,10 +20,10 @@ namespace plugin { zeek::plugin::ComponentManager; } -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; } diff --git a/src/logging/WriterBackend.cc b/src/logging/WriterBackend.cc index 9bb691c594..336bc59d75 100644 --- a/src/logging/WriterBackend.cc +++ b/src/logging/WriterBackend.cc @@ -14,7 +14,7 @@ using threading::Value; using threading::Field; -namespace logging { +namespace zeek::logging { class RotationFinishedMessage final : public threading::OutputMessage { @@ -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 diff --git a/src/logging/WriterBackend.h b/src/logging/WriterBackend.h index 14fe515dbf..899c25e2e2 100644 --- a/src/logging/WriterBackend.h +++ b/src/logging/WriterBackend.h @@ -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; } diff --git a/src/logging/WriterFrontend.cc b/src/logging/WriterFrontend.cc index 60c432b07e..129507c5e6 100644 --- a/src/logging/WriterFrontend.cc +++ b/src/logging/WriterFrontend.cc @@ -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 diff --git a/src/logging/WriterFrontend.h b/src/logging/WriterFrontend.h index d2e5b846d6..a1b21c9b60 100644 --- a/src/logging/WriterFrontend.h +++ b/src/logging/WriterFrontend.h @@ -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; } diff --git a/src/logging/logging.bif b/src/logging/logging.bif index eb2d8c6efc..82d8e0047c 100644 --- a/src/logging/logging.bif +++ b/src/logging/logging.bif @@ -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); %} diff --git a/src/logging/writers/ascii/Ascii.cc b/src/logging/writers/ascii/Ascii.cc index 6a3256daba..991efd2599 100644 --- a/src/logging/writers/ascii/Ascii.cc +++ b/src/logging/writers/ascii/Ascii.cc @@ -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 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,8 +784,8 @@ void Ascii::RotateLeftoverLogs() ll.filename.data(), ll.post_proc_func.data()); } - auto rotation_path = log_mgr->FormatRotationPath( - writer_val, ll.Path(), ll.open_time, ll.close_time, false, ppf); + 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 diff --git a/src/logging/writers/ascii/Ascii.h b/src/logging/writers/ascii/Ascii.h index 5f3ba6663b..547770a516 100644 --- a/src/logging/writers/ascii/Ascii.h +++ b/src/logging/writers/ascii/Ascii.h @@ -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 diff --git a/src/logging/writers/ascii/Plugin.cc b/src/logging/writers/ascii/Plugin.cc index 4692a9828a..c005ce5e2f 100644 --- a/src/logging/writers/ascii/Plugin.cc +++ b/src/logging/writers/ascii/Plugin.cc @@ -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 diff --git a/src/logging/writers/none/None.cc b/src/logging/writers/none/None.cc index b8a4d8aa71..21e81472a8 100644 --- a/src/logging/writers/none/None.cc +++ b/src/logging/writers/none/None.cc @@ -1,13 +1,11 @@ #include +#include #include "None.h" #include "none.bif.h" -#include - -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 diff --git a/src/logging/writers/none/None.h b/src/logging/writers/none/None.h index b00616f597..6b45587770 100644 --- a/src/logging/writers/none/None.h +++ b/src/logging/writers/none/None.h @@ -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 diff --git a/src/logging/writers/none/Plugin.cc b/src/logging/writers/none/Plugin.cc index e767fc28d3..b30cafd715 100644 --- a/src/logging/writers/none/Plugin.cc +++ b/src/logging/writers/none/Plugin.cc @@ -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 diff --git a/src/logging/writers/sqlite/Plugin.cc b/src/logging/writers/sqlite/Plugin.cc index 906407b673..86a033a1e2 100644 --- a/src/logging/writers/sqlite/Plugin.cc +++ b/src/logging/writers/sqlite/Plugin.cc @@ -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 diff --git a/src/logging/writers/sqlite/SQLite.cc b/src/logging/writers/sqlite/SQLite.cc index 5305eef58d..ebfb18bf53 100644 --- a/src/logging/writers/sqlite/SQLite.cc +++ b/src/logging/writers/sqlite/SQLite.cc @@ -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( @@ -112,7 +112,7 @@ bool SQLite::checkError(int code) } bool SQLite::DoInit(const WriterInfo& info, int arg_num_fields, - const Field* const * arg_fields) + const Field* const * arg_fields) { if ( sqlite3_threadsafe() == 0 ) { @@ -365,3 +365,5 @@ bool SQLite::DoRotate(const char* rotated_path, double open, double close, bool return true; } + +} // namespace zeek::logging::writer::detail diff --git a/src/logging/writers/sqlite/SQLite.h b/src/logging/writers/sqlite/SQLite.h index 6d6914be1f..856a4a6388 100644 --- a/src/logging/writers/sqlite/SQLite.h +++ b/src/logging/writers/sqlite/SQLite.h @@ -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 diff --git a/src/zeek-setup.cc b/src/zeek-setup.cc index 728914e4d1..10cb67ef02 100644 --- a/src/zeek-setup.cc +++ b/src/zeek-setup.cc @@ -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();