tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r559205 - /tomcat/connectors/trunk/jk/native/common/jk_util.c
Date Tue, 24 Jul 2007 21:01:15 GMT
Author: rjung
Date: Tue Jul 24 14:01:14 2007
New Revision: 559205

URL: http://svn.apache.org/viewvc?view=rev&rev=559205
Log:
Minor reorg of log line building.
Drop fixed 8 bytes length for log level strings, because
the variing length of correct thread ids breaks
alignment of log messages anyways.

Modified:
    tomcat/connectors/trunk/jk/native/common/jk_util.c

Modified: tomcat/connectors/trunk/jk/native/common/jk_util.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_util.c?view=diff&rev=559205&r1=559204&r2=559205
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_util.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_util.c Tue Jul 24 14:01:14 2007
@@ -286,12 +286,11 @@
     MAINTAIN_PROPERTY_NAME
 };
 
-/* All entries need to have fixed length 8 chars! */
 static const char *jk_level_verbs[] = {
     "[" JK_LOG_TRACE_VERB "] ",
     "[" JK_LOG_DEBUG_VERB "] ",
-    "[" JK_LOG_INFO_VERB "]  ",
-    "[" JK_LOG_WARN_VERB "]  ",
+    "[" JK_LOG_INFO_VERB "] ",
+    "[" JK_LOG_WARN_VERB "] ",
     "[" JK_LOG_ERROR_VERB "] ",
     "[" JK_LOG_EMERG_VERB "] ",
     NULL
@@ -493,31 +492,51 @@
 #endif
         used = set_time_str(buf, usable_size, l->log_fmt);
 
-        if (line) {
+        if (line) { /* line==0 only used for request log item */
             /* Log [pid:threadid] for all levels except REQUEST. */
             /* This information helps to correlate lines from different logs. */
             /* Performance is no issue, because with production log levels */
             /* we only call it often, if we have a lot of errors */
-            rc = snprintf(&buf[used], usable_size - used,
-                             "[%" JK_PID_T_FMT ":%" JK_UINT32_T_FMT "] ", getpid(), jk_gettid());
+            rc = snprintf(buf + used, usable_size - used,
+                          "[%" JK_PID_T_FMT ":%" JK_UINT32_T_FMT "] ", getpid(), jk_gettid());
             used += rc;
-            if (rc < 0 || usable_size - used < 8) {
+            if (rc < 0 ) {
                 return 0;
             }
-            strcat(buf, jk_level_verbs[level]);
-            used += 8;
+
+            rc = (int)strlen(jk_level_verbs[level]);
+            if (usable_size - used >= rc) {
+                strncpy(buf + used, jk_level_verbs[level], rc);
+                used += rc;
+            }
+            else {
+                return 0;           /* [V] not sure what to return... */
+            }
 
             if (funcname) {
-                rc = (int)strlen(funcname) + 2;
-                if (usable_size - used >= rc) {
-                    strcat(buf, funcname);
-                    strcat(buf, "::");
+                rc = (int)strlen(funcname);
+                if (usable_size - used >= rc + 2) {
+                    strncpy(buf + used, funcname, rc);
                     used += rc;
+                    strncpy(buf + used, "::", 2);
+                    used += 2;
+                }
+                else {
+                    return 0;           /* [V] not sure what to return... */
                 }
             }
 
-            rc = snprintf(&buf[used], usable_size - used,
-                             "%s (%d): ", f, line);
+            rc = (int)strlen(f);
+            if (usable_size - used >= rc) {
+                strncpy(buf + used, f, rc);
+                used += rc;
+            }
+            else {
+                return 0;           /* [V] not sure what to return... */
+            }
+
+            rc = snprintf(buf + used, usable_size - used,
+                          " (%d): ", line);
             used += rc;
             if (rc < 0 || usable_size - used < 0) {
                 return 0;           /* [V] not sure what to return... */



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


Mime
View raw message