mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Report suppressed warnings count
This also triggers if there is one warning, which seems a little weird, but it seems mostly reasonable.
This commit is contained in:
parent
6e8d43a552
commit
ecabf882ac
4 changed files with 17 additions and 8 deletions
|
@ -250,13 +250,17 @@ void ReaderBackend::Info(const char* msg) {
|
||||||
MsgThread::Info(msg);
|
MsgThread::Info(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReaderBackend::StopWarningSuppression() {
|
||||||
|
suppress_warnings = false;
|
||||||
|
if ( warnings_suppressed > 0 )
|
||||||
|
Warning(Fmt("Suppressed %zu warning(s)", warnings_suppressed));
|
||||||
|
warnings_suppressed = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void ReaderBackend::FailWarn(bool is_error, const char* msg, bool suppress_future) {
|
void ReaderBackend::FailWarn(bool is_error, const char* msg, bool suppress_future) {
|
||||||
if ( is_error )
|
if ( is_error )
|
||||||
Error(msg);
|
Error(msg);
|
||||||
else {
|
else {
|
||||||
// suppress error message when we are already in error mode.
|
|
||||||
// There is no reason to repeat it every second.
|
|
||||||
if ( ! suppress_warnings )
|
|
||||||
Warning(msg);
|
Warning(msg);
|
||||||
|
|
||||||
if ( suppress_future )
|
if ( suppress_future )
|
||||||
|
@ -264,8 +268,10 @@ void ReaderBackend::FailWarn(bool is_error, const char* msg, bool suppress_futur
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void ReaderBackend::Warning(const char* msg) {
|
void ReaderBackend::Warning(const char* msg) {
|
||||||
if ( suppress_warnings )
|
if ( suppress_warnings ) {
|
||||||
|
warnings_suppressed++;
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
SendOut(new ReaderErrorMessage(frontend, ReaderErrorMessage::WARNING, msg));
|
SendOut(new ReaderErrorMessage(frontend, ReaderErrorMessage::WARNING, msg));
|
||||||
MsgThread::Warning(msg);
|
MsgThread::Warning(msg);
|
||||||
|
|
|
@ -203,7 +203,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void FailWarn(bool is_error, const char* msg, bool suppress_future = false);
|
void FailWarn(bool is_error, const char* msg, bool suppress_future = false);
|
||||||
|
|
||||||
inline void StopWarningSuppression() { suppress_warnings = false; };
|
void StopWarningSuppression();
|
||||||
|
|
||||||
// Overridden from MsgThread.
|
// Overridden from MsgThread.
|
||||||
bool OnHeartbeat(double network_time, double current_time) override;
|
bool OnHeartbeat(double network_time, double current_time) override;
|
||||||
|
@ -365,6 +365,7 @@ private:
|
||||||
// this is an internal indicator in case the read is currently in a failed state
|
// this is an internal indicator in case the read is currently in a failed state
|
||||||
// it's used to suppress duplicate error messages.
|
// it's used to suppress duplicate error messages.
|
||||||
bool suppress_warnings = false;
|
bool suppress_warnings = false;
|
||||||
|
size_t warnings_suppressed = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace zeek::input
|
} // namespace zeek::input
|
||||||
|
|
|
@ -139,14 +139,14 @@ bool Ascii::OpenFile() {
|
||||||
if ( ! file.is_open() ) {
|
if ( ! file.is_open() ) {
|
||||||
FailWarn(fail_on_file_problem, Fmt("Init: cannot open %s", fname.c_str()), true);
|
FailWarn(fail_on_file_problem, Fmt("Init: cannot open %s", fname.c_str()), true);
|
||||||
|
|
||||||
return ! fail_on_file_problem;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ReadHeader(false) == false ) {
|
if ( ReadHeader(false) == false ) {
|
||||||
FailWarn(fail_on_file_problem, Fmt("Init: cannot open %s; problem reading file header", fname.c_str()), true);
|
FailWarn(fail_on_file_problem, Fmt("Init: cannot open %s; problem reading file header", fname.c_str()), true);
|
||||||
|
|
||||||
file.close();
|
file.close();
|
||||||
return ! fail_on_file_problem;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! read_location ) {
|
if ( ! read_location ) {
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
### BTest baseline data generated by btest-diff. Do not edit. Use "btest -U/-u" to update. Requires BTest >= 0.63.
|
||||||
warning: ..<...>/Input::READER_ASCII: ../input.log, line 3: Not enough fields in line 'hello' of ../input.log. Found 0 fields, want positions 1 and -1
|
warning: ..<...>/Input::READER_ASCII: ../input.log, line 3: Not enough fields in line 'hello' of ../input.log. Found 0 fields, want positions 1 and -1
|
||||||
|
warning: ..<...>/Input::READER_ASCII: ../input.log, line 9: Suppressed 5 warning(s)
|
||||||
warning: ..<...>/Input::READER_ASCII: ../input.log, line 10: Not enough fields in line 'hello' of ../input.log. Found 0 fields, want positions 1 and -1
|
warning: ..<...>/Input::READER_ASCII: ../input.log, line 10: Not enough fields in line 'hello' of ../input.log. Found 0 fields, want positions 1 and -1
|
||||||
|
warning: ..<...>/Input::READER_ASCII: ../input.log, line 16: Suppressed 6 warning(s)
|
||||||
received termination signal
|
received termination signal
|
||||||
>>>
|
>>>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue