]> git.itanic.dy.fi Git - glucose/commitdiff
Tweaked progress tracing.
authorSteve Sloan <steve@finagle.org>
Sat, 24 Mar 2012 19:40:28 +0000 (12:40 -0700)
committerSteve Sloan <steve@finagle.org>
Sat, 24 Mar 2012 19:40:28 +0000 (12:40 -0700)
main.c

diff --git a/main.c b/main.c
index f11ec8f6e266327a1f2051bf7b75de16ebbf2296..d1b586c343c8bd1ac06e4407aca4eb9764221970 100644 (file)
--- a/main.c
+++ b/main.c
@@ -66,10 +66,10 @@ int main(int argc, char *argv[])
                fd = hiddev_open(opts.usbdev, &usage_code);
        if (fd < 0)
                return 1;
                fd = hiddev_open(opts.usbdev, &usage_code);
        if (fd < 0)
                return 1;
-       trace(0, "Initializing\n");
+       trace(0, "Initializing ...\n");
        contour_initialize(fd, usage_code);
 
        contour_initialize(fd, usage_code);
 
-       trace(0, "Done! Reading data\n");
+       trace(0, "Reading data ...\n");
        if ( opts.output_format == CSV )
                fprintf(outf, "#,Time,Type,Value,Unit,\"Before meal\",\"After meal\",Stress,Sick,\"Dont feel right\",Activity,\"Control test\"\n");
 
        if ( opts.output_format == CSV )
                fprintf(outf, "#,Time,Type,Value,Unit,\"Before meal\",\"After meal\",Stress,Sick,\"Dont feel right\",Activity,\"Control test\"\n");
 
@@ -107,12 +107,14 @@ int main(int argc, char *argv[])
                }
 
                entries++;
                }
 
                entries++;
-               if (outf != stdout) {
-                       trace(0, "\r%d", entries);
+               fflush(outf);
+
+               if ((outf != stdout) || !isatty(fileno(stdout))) {
+                       trace(0, "\r%d entries", entries);
                        fflush(stdout);
                }
        }
                        fflush(stdout);
                }
        }
-       trace(0, "\n");
+       trace(0, "\nDone.\n");
 
        return 0;
 }
 
        return 0;
 }