diff --git a/print.c b/print.c index c4b1e6a..00af86f 100644 --- a/print.c +++ b/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; diff --git a/print.h b/print.h index 6c16315..eeb868e 100644 --- a/print.h +++ b/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) diff --git a/ptp4l.c b/ptp4l.c index a54dee8..c75e8ce 100644 --- a/ptp4l.c +++ b/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;