diff options
author | Clifford Wolf <clifford@clifford.at> | 2014-08-16 15:34:00 +0200 |
---|---|---|
committer | Clifford Wolf <clifford@clifford.at> | 2014-08-16 15:34:00 +0200 |
commit | dbdf89c7054a3f249d7579cb50d10b72b1ac592d (patch) | |
tree | 2af0cc960e08ff95065ea308d801a78e48b6c373 /kernel/log.cc | |
parent | 674f421b476295d3376ec00644181fc9be02ccaf (diff) | |
download | yosys-dbdf89c7054a3f249d7579cb50d10b72b1ac592d.tar.gz yosys-dbdf89c7054a3f249d7579cb50d10b72b1ac592d.tar.bz2 yosys-dbdf89c7054a3f249d7579cb50d10b72b1ac592d.zip |
Added log_spacer()
Diffstat (limited to 'kernel/log.cc')
-rw-r--r-- | kernel/log.cc | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/kernel/log.cc b/kernel/log.cc index 1f0826039..b742a5495 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -45,6 +45,7 @@ int string_buf_size = 0; static struct timeval initial_tv = { 0, 0 }; static bool next_print_log = false; +static int log_newline_count = 0; void logv(const char *format, va_list ap) { @@ -55,6 +56,15 @@ void logv(const char *format, va_list ap) std::string str = vstringf(format, ap); + if (str.empty()) + return; + + size_t nnl_pos = str.find_last_not_of('\n'); + if (nnl_pos == std::string::npos) + log_newline_count += SIZE(str); + else + log_newline_count = SIZE(str) - nnl_pos - 1; + if (log_hasher) log_hasher->update(str); @@ -92,7 +102,7 @@ void logv_header(const char *format, va_list ap) { bool pop_errfile = false; - log("\n"); + log_spacer(); if (header_count.size() > 0) header_count.back()++; @@ -160,6 +170,12 @@ void log_cmd_error(const char *format, ...) logv_error(format, ap); } +void log_spacer() +{ + while (log_newline_count < 2) + log("\n"); +} + void log_push() { header_count.push_back(0); |