printf(" Use 'ALL' as <header_id> to dump at every header.\n");
printf("\n");
printf(" -W regex\n");
- printf(" print a warning for all log messages matching the regex \n");
+ printf(" print a warning for all log messages matching the regex.\n");
+ printf("\n");
+ printf(" -w regex\n");
+ printf(" if a warning message matches the regex, it is printes as regular\n");
+ printf(" message instead.\n");
printf("\n");
printf(" -V\n");
printf(" print version information and exit\n");
}
int opt;
- while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:W:D:")) != -1)
+ while ((opt = getopt(argc, argv, "MXAQTVSm:f:Hh:b:o:p:l:L:qv:tds:c:W:w:D:")) != -1)
{
switch (opt)
{
std::regex_constants::optimize |
std::regex_constants::egrep));
break;
+ case 'w':
+ log_nowarn_regexes.push_back(std::regex(optarg,
+ std::regex_constants::nosubs |
+ std::regex_constants::optimize |
+ std::regex_constants::egrep));
+ break;
case 'D':
{
auto args = split_tokens(optarg, ":");
std::vector<FILE*> log_files;
std::vector<std::ostream*> log_streams;
std::map<std::string, std::set<std::string>> log_hdump;
-std::vector<std::regex> log_warn_regexes;
+std::vector<std::regex> log_warn_regexes, log_nowarn_regexes;
bool log_hdump_all = false;
FILE *log_errfile = NULL;
SHA1 *log_hasher = NULL;
void logv_warning(const char *format, va_list ap)
{
- if (log_errfile != NULL && !log_quiet_warnings)
- log_files.push_back(log_errfile);
+ std::string message = vstringf(format, ap);
+ bool suppressed = false;
- log("Warning: ");
- logv(format, ap);
- log_flush();
+ for (auto &re : log_nowarn_regexes)
+ if (std::regex_search(message, re))
+ suppressed = true;
- if (log_errfile != NULL && !log_quiet_warnings)
- log_files.pop_back();
+ if (suppressed)
+ {
+ log("Suppressed warning: %s", message.c_str());
+ }
+ else
+ {
+ if (log_errfile != NULL && !log_quiet_warnings)
+ log_files.push_back(log_errfile);
+
+ log("Warning: %s", message.c_str());
+ log_flush();
+
+ if (log_errfile != NULL && !log_quiet_warnings)
+ log_files.pop_back();
+ }
}
void logv_error(const char *format, va_list ap)
extern std::vector<FILE*> log_files;
extern std::vector<std::ostream*> log_streams;
extern std::map<std::string, std::set<std::string>> log_hdump;
-extern std::vector<std::regex> log_warn_regexes;
+extern std::vector<std::regex> log_warn_regexes, log_nowarn_regexes;
extern bool log_hdump_all;
extern FILE *log_errfile;
extern SHA1 *log_hasher;