mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Reporter: Add ScriptLocationScope helper
This commit is contained in:
parent
c7c96610e3
commit
27e6d87331
2 changed files with 23 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
#include "zeek/Event.h"
|
#include "zeek/Event.h"
|
||||||
#include "zeek/EventHandler.h"
|
#include "zeek/EventHandler.h"
|
||||||
#include "zeek/Expr.h"
|
#include "zeek/Expr.h"
|
||||||
|
#include "zeek/Frame.h"
|
||||||
#include "zeek/ID.h"
|
#include "zeek/ID.h"
|
||||||
#include "zeek/NetVar.h"
|
#include "zeek/NetVar.h"
|
||||||
#include "zeek/RunState.h"
|
#include "zeek/RunState.h"
|
||||||
|
@ -649,4 +650,10 @@ void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Conne
|
||||||
|
|
||||||
bool Reporter::EmitToStderr(bool flag) { return flag || ! run_state::detail::zeek_init_done; }
|
bool Reporter::EmitToStderr(bool flag) { return flag || ! run_state::detail::zeek_init_done; }
|
||||||
|
|
||||||
|
ScriptLocationScope::ScriptLocationScope(const zeek::detail::Frame* frame) {
|
||||||
|
zeek::reporter->PushLocation(frame->GetCallLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
ScriptLocationScope::~ScriptLocationScope() { zeek::reporter->PopLocation(); }
|
||||||
|
|
||||||
} // namespace zeek
|
} // namespace zeek
|
||||||
|
|
|
@ -31,8 +31,9 @@ using StringValPtr = IntrusivePtr<StringVal>;
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
|
||||||
class AssertStmt;
|
class AssertStmt;
|
||||||
class Location;
|
|
||||||
class Expr;
|
class Expr;
|
||||||
|
class Frame;
|
||||||
|
class Location;
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
|
@ -334,6 +335,20 @@ private:
|
||||||
bool ignore_deprecations;
|
bool ignore_deprecations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper class pushing the frame's call location onto
|
||||||
|
* the reporter's location stack, associating the caller's
|
||||||
|
* location with subsequent output.
|
||||||
|
*
|
||||||
|
* The frame's location must remain valid until the object
|
||||||
|
* is destroyed.
|
||||||
|
*/
|
||||||
|
class ScriptLocationScope {
|
||||||
|
public:
|
||||||
|
ScriptLocationScope(const zeek::detail::Frame* frame);
|
||||||
|
~ScriptLocationScope();
|
||||||
|
};
|
||||||
|
|
||||||
extern Reporter* reporter;
|
extern Reporter* reporter;
|
||||||
|
|
||||||
} // namespace zeek
|
} // namespace zeek
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue