mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 06:38:20 +00:00
Reporter: Add dedicated Deprecation() method
Minimally, provide a way to funnel all deprecations through reporter->Deprecation() instead of various Warning() invocations.
This commit is contained in:
parent
c18366eacf
commit
2f93592c6f
2 changed files with 26 additions and 0 deletions
|
@ -59,6 +59,8 @@ Reporter::Reporter(bool arg_abort_on_scripting_errors)
|
||||||
weird_sampling_duration = 0;
|
weird_sampling_duration = 0;
|
||||||
weird_sampling_threshold = 0;
|
weird_sampling_threshold = 0;
|
||||||
|
|
||||||
|
ignore_deprecations = false;
|
||||||
|
|
||||||
syslog_open = false;
|
syslog_open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,6 +534,21 @@ void Reporter::Weird(const IPAddr& orig, const IPAddr& resp, const char* name, c
|
||||||
"%s", name);
|
"%s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reporter::Deprecation(std::string_view msg, const detail::Location* loc1,
|
||||||
|
const detail::Location* loc2)
|
||||||
|
{
|
||||||
|
if ( ignore_deprecations )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if ( loc1 || loc2 )
|
||||||
|
PushLocation(loc1, loc2);
|
||||||
|
|
||||||
|
Warning("%s", msg.data());
|
||||||
|
|
||||||
|
if ( loc1 || loc2 )
|
||||||
|
PopLocation();
|
||||||
|
}
|
||||||
|
|
||||||
void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connection* conn,
|
void Reporter::DoLog(const char* prefix, EventHandlerPtr event, FILE* out, Connection* conn,
|
||||||
ValPList* addl, bool location, bool time, const char* postfix, const char* fmt,
|
ValPList* addl, bool location, bool time, const char* postfix, const char* fmt,
|
||||||
va_list ap)
|
va_list ap)
|
||||||
|
|
|
@ -133,6 +133,13 @@ public:
|
||||||
void Weird(const IPAddr& orig, const IPAddr& resp, const char* name, const char* addl = "",
|
void Weird(const IPAddr& orig, const IPAddr& resp, const char* name, const char* addl = "",
|
||||||
const char* source = ""); // Raises flow_weird().
|
const char* source = ""); // Raises flow_weird().
|
||||||
|
|
||||||
|
// Report a deprecation. The message should contain a version.
|
||||||
|
void Deprecation(std::string_view msg, const detail::Location* loc1 = nullptr,
|
||||||
|
const detail::Location* loc2 = nullptr);
|
||||||
|
|
||||||
|
// Whether or not deprecations are logged when calling Deprecation()
|
||||||
|
void SetIgnoreDeprecations(bool arg) { ignore_deprecations = arg; }
|
||||||
|
|
||||||
// Syslog a message. This methods does nothing if we're running
|
// Syslog a message. This methods does nothing if we're running
|
||||||
// offline from a trace.
|
// offline from a trace.
|
||||||
void Syslog(const char* fmt, ...) FMT_ATTR;
|
void Syslog(const char* fmt, ...) FMT_ATTR;
|
||||||
|
@ -345,6 +352,8 @@ private:
|
||||||
uint64_t weird_sampling_threshold;
|
uint64_t weird_sampling_threshold;
|
||||||
uint64_t weird_sampling_rate;
|
uint64_t weird_sampling_rate;
|
||||||
double weird_sampling_duration;
|
double weird_sampling_duration;
|
||||||
|
|
||||||
|
bool ignore_deprecations;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Reporter* reporter;
|
extern Reporter* reporter;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue