Subcommand sensitive logging.
authorAndre Noll <maan@tuebingen.mpg.de>
Tue, 17 Oct 2017 17:19:51 +0000 (19:19 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Sat, 28 Oct 2017 09:25:12 +0000 (11:25 +0200)
It's kind of silly to log the current time and the function name for
subcommands other than "run", since these commands run only for a
short time.

This commit changes dss_log() to only print this additional information
when dss run is being executed.

dss.c

diff --git a/dss.c b/dss.c
index 54d6e42..c6c48f5 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -244,16 +244,19 @@ __printf_1_2 void dss_log(const char* fmt,...)
        if (loglevel < lpr_ll)
                return;
        outfd = logfile? logfile : stderr;
-       time(&t1);
-       tm = localtime(&t1);
-       strftime(str, sizeof(str), "%b %d %H:%M:%S", tm);
-       fprintf(outfd, "%s ", str);
-       if (lpr_ll <= INFO)
-               fprintf(outfd, "%i: ", loglevel);
+       if (subcmd == CMD_PTR(RUN)) {
+               time(&t1);
+               tm = localtime(&t1);
+               strftime(str, sizeof(str), "%b %d %H:%M:%S", tm);
+               fprintf(outfd, "%s ", str);
+               if (lpr_ll <= INFO)
+                       fprintf(outfd, "%i: ", loglevel);
+       }
+       if (subcmd == CMD_PTR(RUN))
 #ifdef DSS_NO_FUNC_NAMES
-       fprintf(outfd, "%s:%d: ", location_file, location_line);
+               fprintf(outfd, "%s:%d: ", location_file, location_line);
 #else
-       fprintf(outfd, "%s: ", location_func);
+               fprintf(outfd, "%s: ", location_func);
 #endif
        va_start(argp, fmt);
        vfprintf(outfd, fmt, argp);