Add a command line option to set the message level.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
f135133a88
commit
32ee558ef8
5
print.c
5
print.c
|
@ -26,6 +26,11 @@
|
|||
static int verbose = 1;
|
||||
static int print_level = LOG_INFO;
|
||||
|
||||
void print_set_level(int level)
|
||||
{
|
||||
print_level = level;
|
||||
}
|
||||
|
||||
void print(int level, char const *format, ...)
|
||||
{
|
||||
pid_t pid;
|
||||
|
|
2
print.h
2
print.h
|
@ -24,6 +24,8 @@
|
|||
|
||||
void print(int level, char const *format, ...);
|
||||
|
||||
void print_set_level(int level);
|
||||
|
||||
#define pr_emerg(x...) print(LOG_EMERG, x)
|
||||
#define pr_alert(x...) print(LOG_ALERT, x)
|
||||
#define pr_crit(x...) print(LOG_CRIT, x)
|
||||
|
|
6
ptp4l.c
6
ptp4l.c
|
@ -63,6 +63,7 @@ static void usage(char *progname)
|
|||
" -h prints this message and exits\n"
|
||||
" -i [dev] interface device to use, for example 'eth0'\n"
|
||||
" (may be specified multiple times)\n"
|
||||
" -l [num] set the logging level to 'num'\n"
|
||||
" -m slave only mode\n"
|
||||
" -p [dev] PTP hardware clock device to use, default '%s'\n"
|
||||
" (ignored for SOFTWARE/LEGACY HW time stamping)\n\n",
|
||||
|
@ -81,7 +82,7 @@ int main(int argc, char *argv[])
|
|||
/* Process the command line arguments. */
|
||||
progname = strrchr(argv[0], '/');
|
||||
progname = progname ? 1+progname : argv[0];
|
||||
while (EOF != (c = getopt(argc, argv, "246hi:mp:rsz"))) {
|
||||
while (EOF != (c = getopt(argc, argv, "246hi:l:mp:rsz"))) {
|
||||
switch (c) {
|
||||
case '2':
|
||||
transport = TRANS_IEEE_802_3;
|
||||
|
@ -100,6 +101,9 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
print_set_level(atoi(optarg));
|
||||
break;
|
||||
case 'm':
|
||||
slaveonly = 1;
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue