X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/blobdiff_plain/85b239ad6c917a76b8ab81fc182c03d28255bdcb..ae8928d2ffbfa3b9dba70bc2f70379ddc20947dc:/client/tripectl.c diff --git a/client/tripectl.c b/client/tripectl.c index 95f95f44..f14c137e 100644 --- a/client/tripectl.c +++ b/client/tripectl.c @@ -94,6 +94,7 @@ static const char *bgtag = 0; #define f_warn 128u #define f_uclose 256u #define f_losing 512u +#define f_nostamp 1024u /*----- Main code ---------------------------------------------------------*/ @@ -110,8 +111,9 @@ static void writelog(const char *cat, const char *msg) char buf[256]; time_t t = time(0); struct tm *tm = localtime(&t); - strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S", tm); - fprintf(logfp, "%s %s: %s\n", buf, cat, msg); + if (f & f_nostamp) buf[0] = 0; + else strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S ", tm); + fprintf(logfp, "%s%s: %s\n", buf, cat, msg); } static void checkbg(char **p) @@ -274,7 +276,11 @@ static void logfile(const char *name) { FILE *fp; - if ((fp = fopen(name, "a")) != 0) { + if (strcmp(name, "-") == 0) + logfp = stdout; + else if (strcmp(name, "!") == 0) + logfp = stderr; + else if ((fp = fopen(name, "a")) != 0) { if (logfp) fclose(logfp); logfp = fp; @@ -354,6 +360,7 @@ Options in full:\n\ \n\ -l, --syslog Log messages to system log.\n\ -f, --logfile=FILE Log messages to FILE.\n\ +-t, --no-timestamp When logging to a file, don't emit timestamps.\n\ -w, --warnings Show warnings when running commands.\n\ ", fp); } @@ -406,12 +413,13 @@ int main(int argc, char *argv[]) { "spawn-args", OPTF_ARGREQ, 0, 'S' }, { "syslog", 0, 0, 'l' }, { "logfile", OPTF_ARGREQ, 0, 'f' }, + { "no-timestamp", 0, 0, 't' }, { "warnings", 0, 0, 'w' }, { "pidfile", OPTF_ARGREQ, 0, 'P' }, { 0, 0, 0, 0 } }; - i = mdwopt(argc, argv, "+hvuDU:G:d:a:sp:S:lwf:nP:", opts, 0, 0, 0); + i = mdwopt(argc, argv, "+hvuDU:G:d:a:sp:S:lwf:nP:t", opts, 0, 0, 0); if (i < 0) break; switch (i) { @@ -461,6 +469,9 @@ int main(int argc, char *argv[]) logname = optarg; f |= f_noinput; break; + case 't': + f |= f_nostamp; + break; case 'P': pidfile = optarg; break;