commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r1198399 - in /commons/proper/daemon/trunk/src/native/unix/native: debug.c jsvc-unix.c
Date Sun, 06 Nov 2011 16:20:44 GMT
Author: mturk
Date: Sun Nov  6 16:20:44 2011
New Revision: 1198399

URL: http://svn.apache.org/viewvc?rev=1198399&view=rev
Log:
Use ISO 8601 date format when logging

Modified:
    commons/proper/daemon/trunk/src/native/unix/native/debug.c
    commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c

Modified: commons/proper/daemon/trunk/src/native/unix/native/debug.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/debug.c?rev=1198399&r1=1198398&r2=1198399&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/debug.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/debug.c Sun Nov  6 16:20:44 2011
@@ -32,7 +32,7 @@ bool log_stdout_syslog_flag = false;
 /* The name of the jsvc binary. */
 char *log_prog = "jsvc";
 
-/* Dump a debug message to stderr */
+/* Dump a debug trace message to stderr */
 void log_debug(const char *fmt, ...)
 {
     va_list ap;
@@ -45,13 +45,16 @@ void log_debug(const char *fmt, ...)
     if (fmt == NULL)
         return;
 
+    now   = time(NULL);
+    nowtm = localtime(&now);
+    strftime(buff, sizeof(buff), "%Y-%m-%d %T", nowtm);
     va_start(ap, fmt);
-    if (log_stderr_syslog_flag) {
-        now   = time(NULL);
-        nowtm = localtime(&now);
-        strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
+    if (log_stderr_syslog_flag)
         fprintf(stderr, "%s %d %s debug: ", buff, getpid(), log_prog);
-    }
+#if defined(DEBUG) || defined(_DEBUG)
+    else
+        fprintf(stderr, "[debug] %s %d ", buff, getpid());
+#endif
     vfprintf(stderr, fmt, ap);
     fprintf(stderr, "\n");
     fflush(stderr);
@@ -73,7 +76,7 @@ void log_error(const char *fmt, ...)
     if (log_stderr_syslog_flag) {
         now   = time(NULL);
         nowtm = localtime(&now);
-        strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
+        strftime(buff, sizeof(buff), "%Y-%m-%d %T", nowtm);
         fprintf(stderr, "%s %d %s error: ", buff, getpid(), log_prog);
     }
     vfprintf(stderr, fmt, ap);

Modified: commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c
URL: http://svn.apache.org/viewvc/commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c?rev=1198399&r1=1198398&r2=1198399&view=diff
==============================================================================
--- commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c (original)
+++ commons/proper/daemon/trunk/src/native/unix/native/jsvc-unix.c Sun Nov  6 16:20:44 2011
@@ -467,14 +467,15 @@ static int check_pid(arg_data *args)
 /*
  * read the pid from the pidfile
  */
-static int get_pidf(arg_data *args)
+static int get_pidf(arg_data *args, bool quiet)
 {
     int fd;
     int i;
     char buff[80];
 
     fd = open(args->pidf, O_RDONLY, 0);
-    log_debug("get_pidf: %d in %s", fd, args->pidf);
+    if (!quiet)
+        log_debug("get_pidf: %d in %s", fd, args->pidf);
     if (fd < 0) {
         /* something has gone wrong the JVM has stopped */
         return -1;
@@ -486,7 +487,8 @@ static int get_pidf(arg_data *args)
     if (i > 0) {
         buff[i] = '\0';
         i = atoi(buff);
-        log_debug("get_pidf: pid %d", i);
+        if (!quiet)
+            log_debug("get_pidf: pid %d", i);
         if (kill(i, 0) == 0)
             return i;
     }
@@ -507,7 +509,7 @@ static int check_tmp_file(arg_data *args
     char buff[80];
     int fd;
 
-    pid = get_pidf(args);
+    pid = get_pidf(args, false);
     if (pid < 0)
         return -1;
     sprintf(buff, "/tmp/%d.jsvc_up", pid);
@@ -610,8 +612,8 @@ static int wait_child(arg_data *args, in
  */
 static int stop_child(arg_data *args)
 {
-    int pid = get_pidf(args);
-    int count = 10;
+    int pid = get_pidf(args, false);
+    int count = 60;
 
     if (pid > 0) {
         /* kill the process and wait until the pidfile has been
@@ -619,8 +621,8 @@ static int stop_child(arg_data *args)
          */
         kill(pid, SIGTERM);
         while (count > 0) {
-            sleep(6);
-            pid = get_pidf(args);
+            sleep(1);
+            pid = get_pidf(args, true);
             if (pid <= 0) {
                 /* JVM has stopped */
                 return 0;



Mime
View raw message