On Mon, Oct 17, 2016 at 04:33:30PM +0200, Miroslav Lichvar wrote: > When running multiple instances of ptp4l or phc2sys, it's difficult to > tell which log message belongs to which instance. Add new options to > ptp4l and phc2sys which can specify a prefix for all messages printed to > the standard output or system log, so messages from different instances > can have different prefixes.
This is a useful feature, but ... > +.BI \-o " print-prefix" > +Specifies a prefix for messages printed to the standard output or system log. > +The default is empty string. Here we should add: Omit this option from the configuration file in order to set the tag to the empty string. I said "tag" and not "prefix". See below... > @@ -67,13 +73,17 @@ void print(int level, char const *format, ...) > > if (verbose) { > f = level >= LOG_NOTICE ? stdout : stderr; > - fprintf(f, "%s[%ld.%03ld]: %s\n", > + fprintf(f, "%s[%ld.%03ld]: %s%s%s\n", The string comes after the time stamp and after the program name. So it really isn't a prefix at all. Maybe this should be called "tag" instead? > progname ? progname : "", > - ts.tv_sec, ts.tv_nsec / 1000000, buf); > + ts.tv_sec, ts.tv_nsec / 1000000, > + prefix ? prefix : "", prefix ? " " : "", > + buf); > fflush(f); > } > if (use_syslog) { > - syslog(level, "[%ld.%03ld] %s", > - ts.tv_sec, ts.tv_nsec / 1000000, buf); > + syslog(level, "[%ld.%03ld] %s%s%s", > + ts.tv_sec, ts.tv_nsec / 1000000, > + prefix ? prefix : "", prefix ? " " : "", > + buf); > } > } > diff --git a/ptp4l.c b/ptp4l.c > index a87e7e6..c4813cb 100644 > --- a/ptp4l.c > +++ b/ptp4l.c > @@ -62,6 +62,7 @@ static void usage(char *progname) > " (ignored for SOFTWARE/LEGACY HW time stamping)\n" > " -s slave only mode (overrides configuration file)\n" > " -l [num] set the logging level to 'num'\n" > + " -o [str] set prefix for log messages\n" Do we really have to have a new command line option? I don't want another one of these, especially not for ptp4l, and not even for phc2sys or pmc. It just gets unwieldy and confusing. Instead we should add '-f config' for phc2sys and pmc. > " -m print messages to stdout\n" > " -q do not print messages to the syslog\n" > " -v prints the software version and exits\n" Thanks, Richard ------------------------------------------------------------------------------ Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE. Training and support from Colfax. Order your platform today. http://sdm.link/xeonphi _______________________________________________ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel