From e870fe53f71c88c636b7c4aadd5655c0fe15bde3 Mon Sep 17 00:00:00 2001 From: Uros Majstorovic Date: Wed, 15 May 2024 13:21:17 +0200 Subject: fixed server logging --- ecp/build.sh | 4 ++++ ecp/server/acl.c | 4 ++-- ecp/server/dir.c | 4 ++-- ecp/server/server.c | 10 +++++----- ecp/server/server.h | 8 +++----- ecp/server/sig.c | 1 + ecp/server/timer.c | 2 ++ ecp/server/vlink.c | 3 ++- 8 files changed, 21 insertions(+), 15 deletions(-) (limited to 'ecp') diff --git a/ecp/build.sh b/ecp/build.sh index a050e85..5cc3a3e 100755 --- a/ecp/build.sh +++ b/ecp/build.sh @@ -7,6 +7,10 @@ else fi +if [ -z $MAKE ]; then + MAKE=`which gmake` +fi + if [ -z $MAKE ]; then MAKE=make fi diff --git a/ecp/server/acl.c b/ecp/server/acl.c index 826b292..3341886 100644 --- a/ecp/server/acl.c +++ b/ecp/server/acl.c @@ -1,8 +1,8 @@ #include #include -#include +#include #include -#include +#include #include #include diff --git a/ecp/server/dir.c b/ecp/server/dir.c index 91d364f..13bea68 100644 --- a/ecp/server/dir.c +++ b/ecp/server/dir.c @@ -1,7 +1,7 @@ #include -#include #include -#include +#include +#include #include #include diff --git a/ecp/server/server.c b/ecp/server/server.c index 59b1c60..1ec55f8 100644 --- a/ecp/server/server.c +++ b/ecp/server/server.c @@ -1,12 +1,11 @@ #include -#include -#include #include +#include +#include #include #include #include #include -#include #include #include @@ -26,9 +25,9 @@ static SRVConfig srv_config; static int proc_forked = 0; static FILE *log_file = NULL; static const char *log_level_str[] = { - "DEBUG", + "ERROR", "INFO", - "ERROR" + "DEBUG" }; SRVConfig *srv_get_config(void) { @@ -209,6 +208,7 @@ static void daemonize(void) { if (pid < 0) fail("fork2 failed\n"); if (pid > 0) exit(0); + /* redirect stdio to /dev/null */ null_rd = open("/dev/null", O_RDONLY); if (null_rd == -1) fail("open (r) /dev/null failed\n"); null_wr = open("/dev/null", O_WRONLY); diff --git a/ecp/server/server.h b/ecp/server/server.h index 652bd04..47c3a8c 100644 --- a/ecp/server/server.h +++ b/ecp/server/server.h @@ -1,11 +1,9 @@ -#include - -#define LOG_DEBUG 0 +#define LOG_ERR 0 #define LOG_INFO 1 -#define LOG_ERR 2 +#define LOG_DEBUG 2 #define LOG_LEVEL LOG_DEBUG -#define LOG(l, ...) log_printf(l, __VA_ARGS__); +#define LOG(l, ...) { if (l <= LOG_LEVEL) log_printf(l, __VA_ARGS__); } typedef struct SRVConfig { ECPDHKey key_perma; diff --git a/ecp/server/sig.c b/ecp/server/sig.c index bf6edbd..6128838 100644 --- a/ecp/server/sig.c +++ b/ecp/server/sig.c @@ -1,4 +1,5 @@ #include +#include #include #include diff --git a/ecp/server/timer.c b/ecp/server/timer.c index 7a477ab..efd0847 100644 --- a/ecp/server/timer.c +++ b/ecp/server/timer.c @@ -1,5 +1,7 @@ #include +#include #include +#include #include #include diff --git a/ecp/server/vlink.c b/ecp/server/vlink.c index 17c84ad..fcb9a5c 100644 --- a/ecp/server/vlink.c +++ b/ecp/server/vlink.c @@ -1,6 +1,7 @@ #include -#include #include +#include +#include #include #include -- cgit v1.2.3