mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 08:08:19 +00:00
Add reporter hook.
The hook being added is: bool HookReporter(const std::string& prefix, const EventHandlerPtr event, const Connection* conn, const val_list* addl, bool location, const Location* location1, const Location* location2, bool time, const std::string& buffer) override; This hook gives access to basically all information that is available in the function in Reporter.cc that performs the logging. The hook is called each time when anything passes through the reporter in the cases in which an event usually would be called. This includes weirds. The hook can return false to prevent the normal reporter events from being raised.
This commit is contained in:
parent
bde4404b5e
commit
b852437126
11 changed files with 275 additions and 2 deletions
|
@ -853,6 +853,52 @@ bool Manager::HookLogWrite(const std::string& writer,
|
|||
return result;
|
||||
}
|
||||
|
||||
bool Manager::HookReporter(const std::string& prefix, const EventHandlerPtr event,
|
||||
const Connection* conn, const val_list* addl, bool location,
|
||||
const Location* location1, const Location* location2,
|
||||
bool time, const std::string& message)
|
||||
|
||||
{
|
||||
HookArgumentList args;
|
||||
|
||||
if ( HavePluginForHook(META_HOOK_PRE) )
|
||||
{
|
||||
args.push_back(HookArgument(prefix));
|
||||
args.push_back(HookArgument(conn));
|
||||
args.push_back(HookArgument(addl));
|
||||
args.push_back(HookArgument(location1));
|
||||
args.push_back(HookArgument(location2));
|
||||
args.push_back(HookArgument(location));
|
||||
args.push_back(HookArgument(time));
|
||||
args.push_back(HookArgument(message));
|
||||
MetaHookPre(HOOK_REPORTER, args);
|
||||
}
|
||||
|
||||
hook_list* l = hooks[HOOK_REPORTER];
|
||||
|
||||
bool result = true;
|
||||
|
||||
if ( l )
|
||||
{
|
||||
for ( hook_list::iterator i = l->begin(); i != l->end(); ++i )
|
||||
{
|
||||
Plugin* p = (*i).second;
|
||||
|
||||
if ( ! p->HookReporter(prefix, event, conn, addl, location, location1, location2, time, message) )
|
||||
{
|
||||
result = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( HavePluginForHook(META_HOOK_POST) )
|
||||
MetaHookPost(HOOK_REPORTER, args, HookArgument(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void Manager::MetaHookPre(HookType hook, const HookArgumentList& args) const
|
||||
{
|
||||
hook_list* l = hooks[HOOK_CALL_FUNCTION];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue