.RI [ args ]...]
.br
.B tripectl
-.RB [ \-Dl ]
+.RB [ \-Dlt ]
.RB [ \-f
.IR file ]
.RB [ \-\fIoptions ]
.BI "\-f, \-\-logfile=" file
Write warnings and trace messages to
.IR file .
-On receipt of a
+The
+.I file
+may be
+.RB ` \- '
+to request output to stdout, or
+.RB ` ! '
+to request output to stderr. If a proper filename is given (rather than
+one of these special tokens), then on receipt of a
.B SIGHUP
signal,
.B tripectl
-will close its log file and reopen a new one with the same name. This
-is useful when you rotate logs.
+will close its log file and reopen a new one with the same name; this is
+useful when you rotate logs.
+.TP
+.B "\-t, \-\-no-timestamp"
+When logging to a file (with
+.BR \-f ),
+don't prefix log items with a timestamp. This is useful when the log
+output is being captured by some process which will add its own
+timestamps anyway.
.TP
.B "\-w, \-\-warnings"
Write warnings to standard error even when running noninteractively.
#define f_warn 128u
#define f_uclose 256u
#define f_losing 512u
+#define f_nostamp 1024u
/*----- Main code ---------------------------------------------------------*/
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)
{
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;
\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);
}
{ "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) {
logname = optarg;
f |= f_noinput;
break;
+ case 't':
+ f |= f_nostamp;
+ break;
case 'P':
pidfile = optarg;
break;
export PATH TRIPEDIR TRIPESOCK TRIPE_SLIPIF
## Start the server, passing lots of arguments.
+ logopt=
+ case ${syslogp-nil} in nil) ;; *) logopt="$logopt -l" ;; esac
+ case ${logfile+t},${syslogp-nil} in
+ t,*) logopt="$logopt -f$logfile" ;;
+ ,nil) logopt="$logopt -f@logfile@" ;;
+ esac
$tripectl -s -p$tripe \
-P$pidfile \
- -f${logfile-@logfile@} \
+ $logopt \
${keytag+-S-t$keytag} \
${addr+-S-b$addr} ${port+-S-p$port} \
${user+-U$user} ${group+-G$group} \
fi
## Start the server, passing lots of arguments.
+ logopt=
+ case ${syslogp-nil} in nil) ;; *) logopt="$logopt -l" ;; esac
+ case ${logfile+t},${syslogp-nil} in
+ t,*) logopt="$logopt -f$logfile" ;;
+ ,nil) logopt="$logopt -f@logfile@" ;;
+ esac
$tripectl -D -s -p$tripe \
-P$pidfile \
- -f${logfile-@logfile@} \
+ $logopt \
${keytag+-S-t$keytag} \
${addr+-S-b$addr} ${port+-S-p$port} \
${user+-U$user} ${group+-G$group} \
#miscopts=
## Logfile to write to. The default is determined by the `--with-logfile'
-## configure option, which defaults to `./tripe.log' (relative to $TRIPEDIR).
+## configure option, which defaults to `./tripe.log' (relative to
+## $TRIPEDIR). This may be set to `-' to write the log to stdout, or `!' to
+## write to stderr.
##
#logfile=/var/log/tripe
+## Whether to write a log to syslog. If this is something other than `nil',
+## then logs are written to syslog. If `syslogp' is non-nil and `logfile'
+## above is unset then no logs are written to files.
+#syslogp=nil
+
## Where to put tripectl's pidfile when it starts up. The default is
## determined by the `--with-pidfile' configure option, which defaults to
## `./tripectl.pid' (relative to $TRIPEDIR).