diff --git a/http_server.c b/http_server.c index 345aa19..f1a560c 100644 --- a/http_server.c +++ b/http_server.c @@ -161,6 +161,10 @@ static int config_handler(void *conf, const char *section, const char *name, { pconfig->n_workers = atoi(value); } + else if (MATCH("SERVER", "debug_enable")) + { + pconfig->debug_enable = atoi(value); + } #ifdef USE_ZLIB else if (MATCH("SERVER", "gzip_enable")) { @@ -269,6 +273,7 @@ void load_config(const char *file) server_config.ssl_cipher = NULL; server_config.gzip_enable = 0; server_config.gzip_types = NULL; + server_config.debug_enable = 0; // put it default mimes for (int i = 0; _mimes[i].type != NULL; i++) { diff --git a/httpd.c b/httpd.c index e14930e..61e8a1f 100644 --- a/httpd.c +++ b/httpd.c @@ -339,7 +339,14 @@ int main(int argc, char *argv[]) config_t *conf = config(); // start syslog - setlogmask(LOG_UPTO(LOG_NOTICE)); + if(conf->debug_enable == 1) + { + setlogmask(LOG_UPTO(LOG_NOTICE)); + } + else + { + setlogmask(LOG_UPTO(LOG_ERR)); + } openlog(SERVER_NAME, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_DAEMON); #ifdef USE_OPENSSL diff --git a/lib/handle.h b/lib/handle.h index fdbb923..d35eeae 100644 --- a/lib/handle.h +++ b/lib/handle.h @@ -93,6 +93,7 @@ typedef struct char *sslkey; char *ssl_cipher; int gzip_enable; + int debug_enable; list_t gzip_types; dictionary_t mimes; dictionary_t ports; diff --git a/lib/utils.h b/lib/utils.h index b84adc4..864e95e 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -43,12 +43,8 @@ THE SOFTWARE. #define true 1 #define false 0 -#ifdef DEBUG - #define LOG(a,...) syslog (LOG_NOTICE,"ANTD_LOG@[%s: %d]: " a "\n", __FILE__, \ +#define LOG(a,...) syslog (LOG_NOTICE,"ANTD_LOG@[%s: %d]: " a "\n", __FILE__, \ __LINE__, ##__VA_ARGS__) -#else - #define LOG(a,...) do{}while(0) -#endif #define ERROR(a,...) syslog (LOG_ERR, "ANTD_ERROR@[%s: %d]: " a "\n", __FILE__, \ __LINE__, ##__VA_ARGS__) // add this to the utils