Print messages to the syslog by default.
Signed-off-by: Richard Cochran <richardcochran@gmail.com>master
parent
222c9bb62b
commit
86ddff4a0a
18
print.c
18
print.c
|
@ -19,18 +19,30 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <syslog.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "print.h"
|
||||
|
||||
static int verbose = 1;
|
||||
static int verbose;
|
||||
static int print_level = LOG_INFO;
|
||||
static int use_syslog = 1;
|
||||
|
||||
void print_no_syslog(void)
|
||||
{
|
||||
use_syslog = 0;
|
||||
}
|
||||
|
||||
void print_set_level(int level)
|
||||
{
|
||||
print_level = level;
|
||||
}
|
||||
|
||||
void print_verbose(void)
|
||||
{
|
||||
verbose = 1;
|
||||
}
|
||||
|
||||
void print(int level, char const *format, ...)
|
||||
{
|
||||
pid_t pid;
|
||||
|
@ -48,5 +60,9 @@ void print(int level, char const *format, ...)
|
|||
|
||||
if (verbose) {
|
||||
fprintf(stdout, "ptp4l[%d]: %s\n", pid, buf);
|
||||
fflush(stdout);
|
||||
}
|
||||
if (use_syslog) {
|
||||
syslog(level, "[%d] %s", pid, buf);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue