aboutsummaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2020-06-30 22:04:29 +0200
committerToni Uhlig <matzeton@googlemail.com>2020-06-30 22:04:29 +0200
commit4035f4900d7db34785433b53c4ec1da046b55868 (patch)
tree3b86e9847a8a7b27d8b7aa9d7da0c551752133d7 /main.c
parent4ca38c90cfe529e9fdd6f843680820074a869149 (diff)
init/close syslog logging
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'main.c')
-rw-r--r--main.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/main.c b/main.c
index 685f90aee..39deba28a 100644
--- a/main.c
+++ b/main.c
@@ -10,6 +10,7 @@
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
+#include <syslog.h>
#include <unistd.h>
#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;
}