summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-08-16 15:34:00 +0200
committerClifford Wolf <clifford@clifford.at>2014-08-16 15:34:00 +0200
commitdbdf89c7054a3f249d7579cb50d10b72b1ac592d (patch)
tree2af0cc960e08ff95065ea308d801a78e48b6c373
parent674f421b476295d3376ec00644181fc9be02ccaf (diff)
Added log_spacer()
-rw-r--r--kernel/driver.cc3
-rw-r--r--kernel/log.cc18
-rw-r--r--kernel/log.h1
3 files changed, 20 insertions, 2 deletions
diff --git a/kernel/driver.cc b/kernel/driver.cc
index 6f976423..d59e68a5 100644
--- a/kernel/driver.cc
+++ b/kernel/driver.cc
@@ -274,7 +274,8 @@ int main(int argc, char **argv)
struct rusage ru_buffer;
getrusage(RUSAGE_SELF, &ru_buffer);
- log("\nEnd of script. Logfile hash: %s, CPU: user %.2fs system %.2fs\n", hash.c_str(),
+ log_spacer();
+ log("End of script. Logfile hash: %s, CPU: user %.2fs system %.2fs\n", hash.c_str(),
ru_buffer.ru_utime.tv_sec + 1e-6 * ru_buffer.ru_utime.tv_usec,
ru_buffer.ru_stime.tv_sec + 1e-6 * ru_buffer.ru_stime.tv_usec);
log("%s\n", yosys_version_str);
diff --git a/kernel/log.cc b/kernel/log.cc
index 1f082603..b742a549 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);
diff --git a/kernel/log.h b/kernel/log.h
index 037a62a3..b1c44b46 100644
--- a/kernel/log.h
+++ b/kernel/log.h
@@ -51,6 +51,7 @@ void log_header(const char *format, ...) __attribute__ ((format (printf, 1, 2)))
void log_error(const char *format, ...) __attribute__ ((format (printf, 1, 2))) __attribute__ ((noreturn));
void log_cmd_error(const char *format, ...) __attribute__ ((format (printf, 1, 2))) __attribute__ ((noreturn));
+void log_spacer();
void log_push();
void log_pop();