Explorar o código

End truncated log entries with [truncated]

svn:r2235
Nick Mathewson %!s(int64=21) %!d(string=hai) anos
pai
achega
ebf2d275bf
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      src/common/log.c

+ 6 - 1
src/common/log.c

@@ -22,6 +22,9 @@
 #define snprintf _snprintf
 #define snprintf _snprintf
 #endif
 #endif
 
 
+#define TRUNCATED_STR "\n[truncated]"
+#define TRUNCATED_STR_LEN 12
+
 /** Information for a single logfile; only used in log.c */
 /** Information for a single logfile; only used in log.c */
 typedef struct logfile_t {
 typedef struct logfile_t {
   struct logfile_t *next; /**< Next logfile_t in the linked list. */
   struct logfile_t *next; /**< Next logfile_t in the linked list. */
@@ -116,8 +119,10 @@ static INLINE void format_msg(char *buf, size_t buf_len,
   }
   }
 
 
   n += vsnprintf(buf+n,buf_len-n,format,ap);
   n += vsnprintf(buf+n,buf_len-n,format,ap);
-  if(n > buf_len)
+  if(n > buf_len) {
     n = buf_len-1;
     n = buf_len-1;
+    strcpy(buf+n-TRUNCATED_STR_LEN, TRUNCATED_STR);
+  }
   buf[n]='\n';
   buf[n]='\n';
   buf[n+1]='\0';
   buf[n+1]='\0';
 }
 }