diff options
author | Andrew Zonenberg <azonenberg@drawersteak.com> | 2016-12-23 12:32:55 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-23 12:32:55 -0800 |
commit | 5ffede5c0e81b682268129b79f305733e11242be (patch) | |
tree | a0e70a25f3b4090912866264431662de67e1f226 /kernel/log.cc | |
parent | a44cc7a3d1c21c37c7dfb88b92bb479389dfce16 (diff) | |
parent | 9f69a70d746e7907eed494941bc89a18159caa1b (diff) | |
download | yosys-5ffede5c0e81b682268129b79f305733e11242be.tar.gz yosys-5ffede5c0e81b682268129b79f305733e11242be.tar.bz2 yosys-5ffede5c0e81b682268129b79f305733e11242be.zip |
Merge pull request #1 from azonenberg-hk/master
Pull changes from HK trip
Diffstat (limited to 'kernel/log.cc')
-rw-r--r-- | kernel/log.cc | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/kernel/log.cc b/kernel/log.cc index abc401f55..cd16bb344 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -41,6 +41,7 @@ YOSYS_NAMESPACE_BEGIN 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; bool log_hdump_all = false; FILE *log_errfile = NULL; SHA1 *log_hasher = NULL; @@ -136,6 +137,32 @@ void logv(const char *format, va_list ap) for (auto f : log_streams) *f << str; + + static std::string linebuffer; + static bool log_warn_regex_recusion_guard = false; + + if (!log_warn_regex_recusion_guard) + { + log_warn_regex_recusion_guard = true; + + if (log_warn_regexes.empty()) + { + linebuffer.clear(); + } + else + { + linebuffer += str; + + if (!linebuffer.empty() && linebuffer.back() == '\n') { + for (auto &re : log_warn_regexes) + if (std::regex_search(linebuffer, re)) + log_warning("Found log message matching -W regex:\n%s", str.c_str()); + linebuffer.clear(); + } + } + + log_warn_regex_recusion_guard = false; + } } void logv_header(RTLIL::Design *design, const char *format, va_list ap) @@ -262,8 +289,8 @@ void log_cmd_error(const char *format, ...) void log_spacer() { - while (log_newline_count < 2) - log("\n"); + if (log_newline_count < 2) log("\n"); + if (log_newline_count < 2) log("\n"); } void log_push() |