From: Andre Noll Date: Tue, 17 Oct 2017 17:19:51 +0000 (+0200) Subject: Subcommand sensitive logging. X-Git-Tag: v1.0.0~11^2 X-Git-Url: http://git.tuebingen.mpg.de/?p=dss.git;a=commitdiff_plain;h=04a4e5db8eeb1744d668353366bf5e98491550d5 Subcommand sensitive logging. 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. --- diff --git a/dss.c b/dss.c index 54d6e42..c6c48f5 100644 --- 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);