Always emit scripting errors to stderr during zeek_init

Otherwise, setting Reporter::errors_to_stderr=F causes important
error messages to be lost (and this setting is the default for
ZeekCtl).  E.g. now that we terminate if there's errors during
zeek_init, GH-369 shows that the only error message given was
"fatal error: errors occurred while initializing", which is not
helpful in determining the actual issue.
This commit is contained in:
Jon Siwek 2019-05-17 14:13:46 -07:00
parent 9d07e4f0b8
commit dd173f4961
6 changed files with 34 additions and 9 deletions

View file

@ -233,6 +233,13 @@ public:
this->weird_sampling_duration = weird_sampling_duration;
}
/**
* Called after zeek_init() and toggles whether messages may stop being
* emitted to stderr.
*/
void ZeekInitDone()
{ after_zeek_init = true; }
private:
void DoLog(const char* prefix, EventHandlerPtr event, FILE* out,
Connection* conn, val_list* addl, bool location, bool time,
@ -248,12 +255,16 @@ private:
bool PermitNetWeird(const char* name);
bool PermitFlowWeird(const char* name, const IPAddr& o, const IPAddr& r);
bool EmitToStderr(bool flag)
{ return flag || ! after_zeek_init; }
int errors;
bool via_events;
int in_error_handler;
bool info_to_stderr;
bool warnings_to_stderr;
bool errors_to_stderr;
bool after_zeek_init;
std::list<std::pair<const Location*, const Location*> > locations;