mirror of
https://github.com/zeek/zeek.git
synced 2025-10-06 00:28:21 +00:00
Reworking log writer API to make it easier to pass additional
information to a writer's initialization method. However, for now the information provided is still the same.
This commit is contained in:
parent
0ca0119f2a
commit
b38d1e1ec2
14 changed files with 112 additions and 70 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "bro_inet_ntop.h"
|
||||
#include "threading/SerialTypes.h"
|
||||
|
||||
#include "Manager.h"
|
||||
#include "WriterBackend.h"
|
||||
#include "WriterFrontend.h"
|
||||
|
||||
|
@ -60,14 +61,25 @@ public:
|
|||
|
||||
using namespace logging;
|
||||
|
||||
bool WriterBackend::WriterInfo::Read(SerializationFormat* fmt)
|
||||
{
|
||||
return fmt->Read(&path, "path");
|
||||
}
|
||||
|
||||
bool WriterBackend::WriterInfo::Write(SerializationFormat* fmt) const
|
||||
{
|
||||
return fmt->Write(path, "path");
|
||||
}
|
||||
|
||||
WriterBackend::WriterBackend(WriterFrontend* arg_frontend) : MsgThread()
|
||||
{
|
||||
path = "<path not yet set>";
|
||||
num_fields = 0;
|
||||
fields = 0;
|
||||
buffering = true;
|
||||
frontend = arg_frontend;
|
||||
|
||||
info.path = "<path not yet set>";
|
||||
|
||||
SetName(frontend->Name());
|
||||
}
|
||||
|
||||
|
@ -108,17 +120,17 @@ void WriterBackend::DisableFrontend()
|
|||
SendOut(new DisableMessage(frontend));
|
||||
}
|
||||
|
||||
bool WriterBackend::Init(string arg_path, int arg_num_fields, const Field* const* arg_fields)
|
||||
bool WriterBackend::Init(const WriterInfo& arg_info, int arg_num_fields, const Field* const* arg_fields)
|
||||
{
|
||||
path = arg_path;
|
||||
info = arg_info;
|
||||
num_fields = arg_num_fields;
|
||||
fields = arg_fields;
|
||||
|
||||
string name = Fmt("%s/%s", path.c_str(), frontend->Name().c_str());
|
||||
string name = Fmt("%s/%s", info.path.c_str(), frontend->Name().c_str());
|
||||
|
||||
SetName(name);
|
||||
|
||||
if ( ! DoInit(arg_path, arg_num_fields, arg_fields) )
|
||||
if ( ! DoInit(arg_info, arg_num_fields, arg_fields) )
|
||||
{
|
||||
DisableFrontend();
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue