commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jfcl...@apache.org
Subject svn commit: r165119 - /jakarta/commons/proper/daemon/trunk/src/native/unix/native/debug.c
Date Thu, 28 Apr 2005 09:00:09 GMT
Author: jfclere
Date: Thu Apr 28 02:00:08 2005
New Revision: 165119

URL: http://svn.apache.org/viewcvs?rev=165119&view=rev
Log:
Add date, time and pid to the printed messages.

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

Modified: jakarta/commons/proper/daemon/trunk/src/native/unix/native/debug.c
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/daemon/trunk/src/native/unix/native/debug.c?rev=165119&r1=165118&r2=165119&view=diff
==============================================================================
--- jakarta/commons/proper/daemon/trunk/src/native/unix/native/debug.c (original)
+++ jakarta/commons/proper/daemon/trunk/src/native/unix/native/debug.c Thu Apr 28 02:00:08
2005
@@ -15,6 +15,9 @@
 */
 /* @version $Id$ */
 #include "jsvc.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <time.h> 
 
 /* Wether debug is enabled or not */
 bool log_debug_flag = false;
@@ -25,12 +28,19 @@
 /* Dump a debug message to stderr */
 void log_debug(const char *fmt, ...) {
     va_list ap;
+    time_t now;
+    struct tm *nowtm;
+    char buff[80];
 
     if (log_debug_flag==false) return;
     if (fmt==NULL) return;
 
+    now = time(NULL);
+    nowtm = localtime(&now);
+    strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
+
     va_start(ap,fmt);
-    fprintf(stderr,"%s debug: ",log_prog);
+    fprintf(stderr,"%s %d %s debug: ", buff,  getpid(), log_prog);
     vfprintf(stderr,fmt,ap);
     fprintf(stderr,"\n");
     fflush(stderr);
@@ -40,11 +50,18 @@
 /* Dump an error message to stderr */
 void log_error(const char *fmt, ...) {
     va_list ap;
+    time_t now;
+    struct tm *nowtm;
+    char buff[80];
 
     if (fmt==NULL) return;
 
+    now = time(NULL);
+    nowtm = localtime(&now);
+    strftime(buff, sizeof(buff), "%d/%m/%Y %T", nowtm);
+
     va_start(ap,fmt);
-    fprintf(stderr,"%s error: ",log_prog);
+    fprintf(stderr,"%s %d %s error: ", buff, getpid(), log_prog);
     vfprintf(stderr,fmt,ap);
     fprintf(stderr,"\n");
     fflush(stderr);



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message