]> git.neil.brown.name Git - edlib.git/commitdiff
Suppress LOG timestamps when testing.
authorNeilBrown <neil@brown.name>
Wed, 30 Aug 2023 22:38:53 +0000 (08:38 +1000)
committerNeilBrown <neil@brown.name>
Wed, 30 Aug 2023 22:47:28 +0000 (08:47 +1000)
The time stamps are less helpful when testing, and they make it hard to
diff outputs between different runs.

Signed-off-by: NeilBrown <neil@brown.name>
core-log.c

index 0a4464fa8162f21720952c0402aabcfa5dc497ac..681b12c3aff881aa4236647eea5c06eba901212b 100644 (file)
@@ -86,8 +86,12 @@ void LOG(char *fmt, ...)
        gettimeofday(&now, NULL);
        b = get_buf(log_doc);
        va_start(ap, fmt);
-       n = snprintf(b->text + b->end, LBSIZE - b->end - 1, "%ld.%03ld:",
-                    now.tv_sec % 10000, now.tv_usec / 1000);
+       if (log_pane && edlib_testing(log_pane))
+               n = 0;
+       else
+               n = snprintf(b->text + b->end, LBSIZE - b->end - 1,
+                            "%ld.%03ld:",
+                            now.tv_sec % 10000, now.tv_usec / 1000);
        if (n < LBSIZE - b->end - 1)
                n += vsnprintf(b->text + b->end + n, LBSIZE - b->end - 1 - n,
                               fmt, ap);
@@ -97,8 +101,12 @@ void LOG(char *fmt, ...)
                /* Didn't fit, allocate new buf */
                b = get_new_buf(log_doc);
                va_start(ap, fmt);
-               n = snprintf(b->text, LBSIZE - 1, "%ld.%03ld:",
-                            now.tv_sec % 10000, now.tv_usec / 1000);
+               if (log_pane && edlib_testing(log_pane))
+                       n = 0;
+               else
+                       n = snprintf(b->text, LBSIZE - 1, "%ld.%03ld:",
+                                    now.tv_sec % 10000,
+                                    now.tv_usec / 1000);
                if (n < LBSIZE - 1)
                        n += vsnprintf(b->text + n, LBSIZE - 1 - n, fmt, ap);
                va_end(ap);