mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 20:48:21 +00:00
Merge branch 'robin/topic/writer-info'
* robin/topic/writer-info: Extending the log writer DoInit() API. Reworking log writer API to make it easier to pass additional information to a writer's initialization method. Conflicts: src/logging/WriterBackend.cc src/logging/WriterBackend.h src/logging/WriterFrontend.cc
This commit is contained in:
commit
90763bb2f2
27 changed files with 371 additions and 92 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "Net.h"
|
||||
#include "threading/SerialTypes.h"
|
||||
|
||||
#include "Manager.h"
|
||||
#include "WriterFrontend.h"
|
||||
#include "WriterBackend.h"
|
||||
|
||||
|
@ -15,15 +16,15 @@ namespace logging {
|
|||
class InitMessage : public threading::InputMessage<WriterBackend>
|
||||
{
|
||||
public:
|
||||
InitMessage(WriterBackend* backend, const string path, const int num_fields, const Field* const* fields, string frontend_name)
|
||||
InitMessage(WriterBackend* backend, const WriterBackend::WriterInfo& info, const int num_fields, const Field* const* fields, const string& frontend_name)
|
||||
: threading::InputMessage<WriterBackend>("Init", backend),
|
||||
path(path), num_fields(num_fields), fields(fields),
|
||||
info(info), num_fields(num_fields), fields(fields),
|
||||
frontend_name(frontend_name) { }
|
||||
|
||||
virtual bool Process() { return Object()->Init(path, num_fields, fields, frontend_name); }
|
||||
virtual bool Process() { return Object()->Init(info, num_fields, fields); }
|
||||
|
||||
private:
|
||||
const string path;
|
||||
WriterBackend::WriterInfo info;
|
||||
const int num_fields;
|
||||
const Field * const* fields;
|
||||
const string frontend_name;
|
||||
|
@ -136,10 +137,10 @@ WriterFrontend::~WriterFrontend()
|
|||
|
||||
string WriterFrontend::Name() const
|
||||
{
|
||||
if ( path.size() )
|
||||
if ( info.path.size() )
|
||||
return ty_name;
|
||||
|
||||
return ty_name + "/" + path;
|
||||
return ty_name + "/" + info.path;
|
||||
}
|
||||
|
||||
void WriterFrontend::Stop()
|
||||
|
@ -151,7 +152,7 @@ void WriterFrontend::Stop()
|
|||
backend->Stop();
|
||||
}
|
||||
|
||||
void WriterFrontend::Init(string arg_path, int arg_num_fields, const Field* const * arg_fields)
|
||||
void WriterFrontend::Init(const WriterBackend::WriterInfo& arg_info, int arg_num_fields, const Field* const * arg_fields)
|
||||
{
|
||||
if ( disabled )
|
||||
return;
|
||||
|
@ -159,19 +160,19 @@ void WriterFrontend::Init(string arg_path, int arg_num_fields, const Field* cons
|
|||
if ( initialized )
|
||||
reporter->InternalError("writer initialize twice");
|
||||
|
||||
path = arg_path;
|
||||
info = arg_info;
|
||||
num_fields = arg_num_fields;
|
||||
fields = arg_fields;
|
||||
|
||||
initialized = true;
|
||||
|
||||
if ( backend )
|
||||
backend->SendIn(new InitMessage(backend, arg_path, arg_num_fields, arg_fields, Name()));
|
||||
backend->SendIn(new InitMessage(backend, arg_info, arg_num_fields, arg_fields, Name()));
|
||||
|
||||
if ( remote )
|
||||
remote_serializer->SendLogCreateWriter(stream,
|
||||
writer,
|
||||
arg_path,
|
||||
arg_info,
|
||||
arg_num_fields,
|
||||
arg_fields);
|
||||
|
||||
|
@ -185,7 +186,7 @@ void WriterFrontend::Write(int num_fields, Value** vals)
|
|||
if ( remote )
|
||||
remote_serializer->SendLogWrite(stream,
|
||||
writer,
|
||||
path,
|
||||
info.path,
|
||||
num_fields,
|
||||
vals);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue