From 04a4e5db8eeb1744d668353366bf5e98491550d5 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Tue, 17 Oct 2017 19:19:51 +0200 Subject: [PATCH] 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. --- dss.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) 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); -- 2.30.2