adds debug log level srvctrl

Sun, 29 Jan 2017 09:04:06 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 29 Jan 2017 09:04:06 +0100
branch
srvctrl
changeset 166
c07122f66676
parent 158
77f4f0079428
child 167
4be7dd2b75b9

adds debug log level

src/server/daemon/log.c file | annotate | diff | comparison | revisions
src/server/daemon/srvctrl.c file | annotate | diff | comparison | revisions
src/server/plugins/java/Makefile file | annotate | diff | comparison | revisions
src/server/public/nsapi.h file | annotate | diff | comparison | revisions
src/server/util/system.c file | annotate | diff | comparison | revisions
--- a/src/server/daemon/log.c	Wed Jan 25 11:50:19 2017 +0100
+++ b/src/server/daemon/log.c	Sun Jan 29 09:04:06 2017 +0100
@@ -84,7 +84,8 @@
     "failure",
     "catastrophe",
     "info",
-    "verbose"
+    "verbose",
+    "debug"
 };
 
 static int can_log[] = {
@@ -94,7 +95,8 @@
     1, // failure
     1, // catastrophe
     1, // info
-    0  // verbose
+    0, // verbose
+    0  // debug
 };
 
 int init_log_file(LogConfig *cfg) {
@@ -114,10 +116,11 @@
         can_log[LOG_INFORM] = 0;
     } else if(!strcmp(cfg->level, "WARNING")) {
         can_log[LOG_INFORM] = 0;
-    } else if(!strcmp(cfg->level, "INFO")) {
-        
     } else if(!strcmp(cfg->level, "VERBOSE")) {
         can_log[LOG_VERBOSE] = 1;
+    } else if(!strcmp(cfg->level, "DEBUG")) {
+        can_log[LOG_VERBOSE] = 1;
+        can_log[LOG_DEBUG] = 1;
     }
     
     if(cfg->log_stdout) {
@@ -225,10 +228,10 @@
 }
 
 int log_ereport_v(int degree, const char *format, va_list args) { 
-    if(degree > 6) {
+    if(degree < 0 || degree > 7) {
         return 0;
     }
-    if(degree > 0 && !can_log[degree]) {
+    if(!can_log[degree]) {
         return 0;
     }
     
--- a/src/server/daemon/srvctrl.c	Wed Jan 25 11:50:19 2017 +0100
+++ b/src/server/daemon/srvctrl.c	Sun Jan 29 09:04:06 2017 +0100
@@ -41,29 +41,31 @@
 #define SRVCTRL_THREAD_STACKSIZE 8192
 
 static int srvctrl;
+static sstr_t srvctrl_path;
+
 static WSBool srv_shutdown;
 
 int srvctrl_init(ServerConfiguration *cfg) {
     // create srvctrl unix domain socket
     // this socket is used for stop, reconfigure and other operations
-    sstr_t uds_path = ucx_sprintf("%s/private/srvctrl.sock", cfg->tmp.ptr);
+    srvctrl_path = ucx_sprintf("%s/private/srvctrl.sock", cfg->tmp.ptr);
     struct sockaddr_un addr;
-    if(uds_path.length > sizeof(addr.sun_path)-1) {
+    if(srvctrl_path.length > sizeof(addr.sun_path)-1) {
         log_ereport(
                 LOG_CATASTROPHE,
                 "path '%s' too long for unix domain socket",
-                uds_path.ptr);
+                srvctrl_path.ptr);
         return -1;
     }
     
     // make sure there is no old srvctrl socket file
     // otherweise bind would fail
-    if(unlink(uds_path.ptr)) {
+    if(unlink(srvctrl_path.ptr)) {
         if(errno != ENOENT) {
             log_ereport(
                     LOG_CATASTROPHE,
                     "cannot unlink old srvctrl socket '%s': %s",
-                    uds_path.ptr,
+                    srvctrl_path.ptr,
                     strerror(errno));
             return -1;
         }
@@ -71,7 +73,7 @@
 
     ZERO(&addr, sizeof(addr));
     addr.sun_family = AF_UNIX;
-    memcpy(addr.sun_path, uds_path.ptr, uds_path.length);
+    memcpy(addr.sun_path, srvctrl_path.ptr, srvctrl_path.length);
     
     srvctrl = socket(AF_UNIX, SOCK_STREAM, 0);
     if(srvctrl == -1) {
@@ -89,8 +91,6 @@
         return -1;
     }
     
-    free(uds_path.ptr);
-    
     return 0;
 }
 
@@ -120,6 +120,11 @@
         systhread_detach(t);
         
     }
+    
+    unlink(srvctrl_path.ptr);
+    free(srvctrl_path.ptr);
+    
+    return 0;
 }
 
 void srvctrl_shutdown() {
--- a/src/server/plugins/java/Makefile	Wed Jan 25 11:50:19 2017 +0100
+++ b/src/server/plugins/java/Makefile	Sun Jan 29 09:04:06 2017 +0100
@@ -60,7 +60,7 @@
 	$(CC) -o $(NSAPI_JNI_LIB) $(JNI_OBJS) $(LDFLAGS)
 
 $(JAVA_WSRT): $(JAVASRC)
-	ant -Dbuild.compiler=javac1.7 compile jar
+	ant compile jar
 
 
 ../../../../build/server/plugins/java/%.o: %.c
--- a/src/server/public/nsapi.h	Wed Jan 25 11:50:19 2017 +0100
+++ b/src/server/public/nsapi.h	Sun Jan 29 09:04:06 2017 +0100
@@ -176,6 +176,9 @@
  */
 #define LOG_VERBOSE 6
 
+// new
+#define LOG_DEBUG 7
+
 /*
  * The time format to use in the error log
  */
--- a/src/server/util/system.c	Wed Jan 25 11:50:19 2017 +0100
+++ b/src/server/util/system.c	Sun Jan 29 09:04:06 2017 +0100
@@ -390,4 +390,4 @@
 #endif
 }
 
-*/
\ No newline at end of file
+*/

mercurial