mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Updating thread naming.
Also includes experimental code to adapt the thread name as shown by top, but it's untested.
This commit is contained in:
parent
cf6a346b86
commit
70fe7876a1
12 changed files with 81 additions and 14 deletions
|
@ -480,6 +480,8 @@ WriterBackend* Manager::CreateBackend(WriterFrontend* frontend, bro_int_t type)
|
|||
|
||||
WriterBackend* backend = (*ld->factory)(frontend);
|
||||
assert(backend);
|
||||
|
||||
frontend->ty_name = ld->name;
|
||||
return backend;
|
||||
}
|
||||
|
||||
|
|
|
@ -55,13 +55,15 @@ public:
|
|||
|
||||
using namespace logging;
|
||||
|
||||
WriterBackend::WriterBackend(WriterFrontend* arg_frontend, const string& name) : MsgThread(name)
|
||||
WriterBackend::WriterBackend(WriterFrontend* arg_frontend) : MsgThread()
|
||||
{
|
||||
path = "<not set>";
|
||||
num_fields = 0;
|
||||
fields = 0;
|
||||
buffering = true;
|
||||
frontend = arg_frontend;
|
||||
|
||||
SetName(frontend->Name());
|
||||
}
|
||||
|
||||
WriterBackend::~WriterBackend()
|
||||
|
@ -107,6 +109,8 @@ bool WriterBackend::Init(string arg_path, int arg_num_fields, const Field* const
|
|||
num_fields = arg_num_fields;
|
||||
fields = arg_fields;
|
||||
|
||||
SetName(frontend->Name());
|
||||
|
||||
if ( ! DoInit(arg_path, arg_num_fields, arg_fields) )
|
||||
{
|
||||
DisableFrontend();
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
* @param name A descriptive name for writer's type (e.g., \c Ascii).
|
||||
*
|
||||
*/
|
||||
WriterBackend(WriterFrontend* frontend, const string& name);
|
||||
WriterBackend(WriterFrontend* frontend);
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
|
|
|
@ -99,6 +99,7 @@ WriterFrontend::WriterFrontend(bro_int_t type)
|
|||
buf = true;
|
||||
write_buffer = 0;
|
||||
write_buffer_pos = 0;
|
||||
ty_name = "<not set>";
|
||||
backend = log_mgr->CreateBackend(this, type);
|
||||
|
||||
assert(backend);
|
||||
|
@ -109,6 +110,14 @@ WriterFrontend::~WriterFrontend()
|
|||
{
|
||||
}
|
||||
|
||||
string WriterFrontend::Name() const
|
||||
{
|
||||
if ( path.size() )
|
||||
return ty_name;
|
||||
|
||||
return ty_name + "/" + path;
|
||||
}
|
||||
|
||||
void WriterFrontend::Stop()
|
||||
{
|
||||
FlushWriteBuffer();
|
||||
|
|
|
@ -30,6 +30,9 @@ public:
|
|||
* frontend will internally instantiate a WriterBackend of the
|
||||
* corresponding type.
|
||||
*
|
||||
* name: A descriptive name for the backend wroter type (e.g., \c
|
||||
* Ascii).
|
||||
*
|
||||
* Frontends must only be instantiated by the main thread.
|
||||
*/
|
||||
WriterFrontend(bro_int_t type);
|
||||
|
@ -171,6 +174,14 @@ public:
|
|||
*/
|
||||
int NumFields() const { return num_fields; }
|
||||
|
||||
/**
|
||||
* Returns a descriptive name for the writer, including the type of
|
||||
* the backend and the path used.
|
||||
*
|
||||
* This method is safe to call from any thread.
|
||||
*/
|
||||
string Name() const;
|
||||
|
||||
/**
|
||||
* Returns the log fields as passed into the constructor.
|
||||
*/
|
||||
|
@ -184,6 +195,7 @@ protected:
|
|||
bool initialized; // True if initialized.
|
||||
bool buf; // True if buffering is enabled (default).
|
||||
|
||||
string ty_name; // Name of the backend type. Set by the manager.
|
||||
string path; // The log path.
|
||||
int num_fields; // The number of log fields.
|
||||
const Field* const* fields; // The log fields.
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
using namespace logging;
|
||||
using namespace writer;
|
||||
|
||||
Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend, "Ascii")
|
||||
Ascii::Ascii(WriterFrontend* frontend) : WriterBackend(frontend)
|
||||
{
|
||||
file = 0;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ namespace logging { namespace writer {
|
|||
|
||||
class None : public WriterBackend {
|
||||
public:
|
||||
None(WriterFrontend* frontend) : WriterBackend(frontend, "None") {}
|
||||
None(WriterFrontend* frontend) : WriterBackend(frontend) {}
|
||||
~None() {};
|
||||
|
||||
static WriterBackend* Instantiate(WriterFrontend* frontend)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue