Add error events to input framework.

This change introduces error events for Table and Event readers. Users
can now specify an event that is called when an info, warning, or error
is emitted by their input reader. This can, e.g., be used to raise
notices in case errors occur when reading an important input stream.

Example:

event error_event(desc: Input::TableDescription, msg: string, level: Reporter::Level)
	{
	...
	}

event bro_init()
	{
	Input::add_table([$source="a", $error_ev=error_event, ...]);
	}

For the moment, this converts all errors in the Asciiformatter into
warnings (to show that they are non-fatal) - the Reader itself also has
to throw an Error to show that a fatal error occurred and processing
will be abort.

It might be nicer to change this and require readers to mark fatal
errors as such when throwing them.

Addresses BIT-1181
This commit is contained in:
Johanna Amann 2016-07-22 17:33:42 -07:00
parent 697b59cdc8
commit 6b9abe85a7
29 changed files with 458 additions and 150 deletions

View file

@ -64,7 +64,7 @@ public:
*
* @param msg The message. It will be prefixed with the thread's name.
*/
void Info(const char* msg);
virtual void Info(const char* msg);
/**
* Reports a warning from the child thread that may indicate a
@ -73,9 +73,14 @@ public:
*
* Only the child thread may call this method.
*
* Can be overriden in derived classed to hook into the error handling
* but must should generally also call the parent implementation. Note
* that this method is always called by the child thread and must not access
* data or datastructures of the main thread directly.
*
* @param msg The message. It will be prefixed with the thread's name.
*/
void Warning(const char* msg);
virtual void Warning(const char* msg);
/**
* Reports a non-fatal error from the child thread. The main thread
@ -84,9 +89,14 @@ public:
*
* Only the child thread may call this method.
*
* Can be overriden in derived classed to hook into the error handling
* but must should generally also call the parent implementation. Note
* that this method is always called by the child thread and must not access
* data or datastructures of the main thread directly.
*
* @param msg The message. It will be prefixed with the thread's name.
*/
void Error(const char* msg);
virtual void Error(const char* msg);
/**
* Reports a fatal error from the child thread. The main thread will
@ -223,10 +233,10 @@ protected:
* Overriden from BasicThread.
*
*/
virtual void Run();
virtual void OnWaitForStop();
virtual void OnSignalStop();
virtual void OnKill();
void Run() override;
void OnWaitForStop() override;
void OnSignalStop() override;
void OnKill() override;
private:
/**