From 4035f4900d7db34785433b53c4ec1da046b55868 Mon Sep 17 00:00:00 2001 From: Toni Uhlig Date: Tue, 30 Jun 2020 22:04:29 +0200 Subject: init/close syslog logging Signed-off-by: Toni Uhlig --- main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/main.c b/main.c index 685f90aee..39deba28a 100644 --- a/main.c +++ b/main.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #if (NDPI_MAJOR == 3 && NDPI_MINOR < 3) || NDPI_MAJOR < 3 @@ -111,6 +112,7 @@ static struct nDPId_reader_thread reader_threads[MAX_READER_THREADS] = {}; static int reader_thread_count = MAX_READER_THREADS; static int main_thread_shutdown = 0; static uint32_t flow_id = 0; +static int log_to_stderr = 0; static void free_workflow(struct nDPId_workflow ** const workflow); @@ -1201,9 +1203,13 @@ int main(int argc, char ** argv) "----------------------------------\n" "nDPI version: %s\n" " API version: %u\n" + "pcap version: %s\n" "----------------------------------\n", argv[0], - ndpi_revision(), ndpi_get_api_version()); + ndpi_revision(), ndpi_get_api_version(), + pcap_lib_version() + strlen("libpcap version ")); + + openlog("nDPId", LOG_CONS | (log_to_stderr != 0 ? LOG_PERROR : 0), LOG_DAEMON); if (setup_reader_threads((argc >= 2 ? argv[1] : NULL)) != 0) { fprintf(stderr, "%s: setup_reader_threads failed\n", argv[0]); @@ -1226,5 +1232,7 @@ int main(int argc, char ** argv) return 1; } + closelog(); + return 0; } -- cgit v1.2.3