Ticket #97: innfeed-ctime.patch
File innfeed-ctime.patch, 10.5 KB (added by , 14 years ago) |
---|
-
doc/man/innfeed.conf.5
190 190 a positive value for ``\fBdebug-value\fP'', is used). This corresponds to 191 191 the ``\fI\-l\fP'' command-line option. A relative pathname is relative to 192 192 the ``\fBbacklog-directory\fP'' value. 193 .TP 194 .B log-time-format 195 This key requires a format string suitable for strftime(3). It is used for 196 messages sent via syslog(3) and to the \fBstatus-file\fP. Default value 197 is "%a %b %d %H:%M:%S %Y". 193 198 .\" .TP 194 199 .\" .B initial-sleep 195 200 .\" This key requires a positive integer value. It specifies how many seconds -
innfeed/connection.c
4461 4461 free (PointersFreedOnExit) ; 4462 4462 freeTimeoutQueue () ; 4463 4463 4464 strlcpy (dateString,ctime (&now), sizeof(dateString)) ; 4464 timeToString (now, dateString, sizeof(dateString)) ; 4465 notice ("ME finishing at %s\n", dateString) ; 4465 4466 4466 notice ("ME finishing at %s", dateString) ;4467 4468 4467 exit (0) ; 4469 4468 } 4470 4469 } -
innfeed/misc.h
42 42 /* debugging information */ 43 43 extern unsigned int loggingLevel ; /* if 0 then d_printf is a no-op */ 44 44 45 /* used by timeToString with strftime(3) */ 46 extern char *timeToStringFormat ; 47 45 48 /* the current count of file desccriptors */ 46 49 extern unsigned int openfds ; 47 50 … … 114 117 /* converts val into a printable string */ 115 118 const char *boolToString (bool val) ; 116 119 120 /* strftime with "%a %b %d %H:%M:%S %Y" (like ctime without linefeed) */ 121 char* timeToString (time_t time, char* buffer, size_t size) ; 122 117 123 /* memory leak checker helper. */ 118 124 void addPointerFreedOnExit (char *pointerToFree) ; 119 125 -
innfeed/imap_connection.c
4170 4170 time_t now = theTime () ; 4171 4171 char dateString [30] ; 4172 4172 4173 strlcpy (dateString,ctime (&now),sizeof (dateString)) ; 4174 dateString [24] = '\0' ; 4175 4173 timeToString (now, dateString, sizeof (dateString)) ; 4176 4174 notice ("ME finishing at %s", dateString) ; 4177 4175 4178 4176 exit (0) ; -
innfeed/host.c
332 332 333 333 static unsigned int hostHighwater = HOST_HIGHWATER ; 334 334 static time_t start ; 335 static char startTime [30] ; /* for ctime(3)*/335 static char startTime [30] ; /* for timeToString */ 336 336 static pid_t myPid ; 337 337 338 338 static char *statusFile = NULL ; … … 396 396 else 397 397 iv = DNS_EXPIRE_PERIOD ; 398 398 dnsExpPeriod = (unsigned int) iv ; 399 399 400 400 if (getBool (topScope,"gen-html",&bval,NO_INHERIT)) 401 401 genHtml = (bval ? true : false) ; 402 402 else … … 410 410 else 411 411 hostSetStatusFile (INNFEED_STATUS) ; 412 412 413 414 413 if (getBool (topScope,"connection-stats",&bval,NO_INHERIT)) 415 414 logConnectionStats = (bval ? true : false) ; 416 415 else 417 416 logConnectionStats = (LOG_CONNECTION_STATS ? true : false) ; 418 417 419 420 418 if (getInteger (topScope,"host-queue-highwater", &iv,NO_INHERIT)) 421 419 { 422 420 if (iv < 0) … … 1111 1109 if (maxIpNameLen == 0) 1112 1110 { 1113 1111 start = theTime() ; 1114 strlcpy (startTime,ctime (&start),sizeof (startTime)) ;1112 timeToString (start, startTime, sizeof (startTime)) ; 1115 1113 myPid = getpid() ; 1116 1114 } 1117 1115 … … 1258 1256 1259 1257 void printHostInfo (Host host, FILE *fp, unsigned int indentAmt) 1260 1258 { 1259 char dateString [30] ; 1261 1260 char indent [INDENT_BUFFER_SIZE] ; 1262 1261 unsigned int i ; 1263 1262 ProcQElem qe ; … … 1404 1403 100.0 * host->blFull / cnt) ; 1405 1404 fprintf (fp,"%s number of samples : %u\n", indent, host->blCount) ; 1406 1405 1407 fprintf (fp,"%s firstConnectTime : %s",indent, 1408 ctime (&host->firstConnectTime)); 1409 fprintf (fp,"%s connectTime : %s",indent,ctime (&host->connectTime)); 1410 fprintf (fp,"%s spoolTime : %s",indent,ctime (&host->spoolTime)) ; 1411 fprintf (fp,"%s last-spool-time : %s",indent, 1412 ctime (&host->lastSpoolTime)) ; 1406 timeToString (host->firstConnectTime, dateString, sizeof (dateString)); 1407 fprintf (fp, "%s firstConnectTime : %s\n", indent, dateString); 1408 1409 timeToString (host->connectTime, dateString, sizeof (dateString)); 1410 fprintf (fp, "%s connectTime : %s\n", indent, dateString); 1411 1412 timeToString (host->spoolTime, dateString, sizeof (dateString)); 1413 fprintf (fp, "%s spoolTime : %s\n", indent, dateString); 1414 1415 timeToString (host->lastSpoolTime, dateString, sizeof (dateString)); 1416 fprintf (fp, "%s last-spool-time : %s\n", indent, dateString); 1413 1417 1414 1418 #if 0 1415 1419 fprintf (fp,"%s tape {\n",indent) ; … … 3160 3164 3161 3165 now = time (NULL) ; 3162 3166 sec = (long) (now - start) ; 3163 strlcpy (timeString,ctime (&now),sizeof (timeString)) ;3167 timeToString (now, timeString, sizeof (timeString)) ; 3164 3168 3165 3169 if (genHtml) 3166 3170 { … … 3173 3177 fprintf (fp, "<PRE>\n"); 3174 3178 } 3175 3179 3176 fprintf (fp,"innfeed from %s\npid %d started %s\n Updated: %s",3180 fprintf (fp,"innfeed from %s\npid %d started %s\n\nUpdated: %s\n", 3177 3181 INN_VERSION_STRING,(int) myPid,startTime,timeString) ; 3178 3182 fprintf (fp,"(peers: %d active-cxns: %d sleeping-cxns: %d idle-cxns: %d)\n\n", 3179 3183 peerNum, actConn, slpConn,(maxcon - (actConn + slpConn))) ; -
innfeed/endpoint.c
1495 1495 static void printDate (TimeoutId tid, void *data) ; 1496 1496 static void printDate (TimeoutId tid, void *data) 1497 1497 { 1498 time_t t ; 1498 char dateString[30]; 1499 const time_t t = theTime() ; 1499 1500 1500 t = theTime() ; 1501 1502 d_printf (1,"Timeout (%d) time now is %ld %s", 1503 (int) tid,(long) t,ctime(&t)) ; 1501 timeToString (t, dateString, sizeof (dateString)) ; 1502 d_printf (1,"Timeout (%d) time now is %ld %s\n", 1503 (int) tid, (long) t, dateString) ; 1504 1504 1505 1505 if (timeoutQueue == NULL) 1506 1506 { … … 1518 1518 static int seeded ; 1519 1519 static int howMany ; 1520 1520 static int i ; 1521 time_t t = theTime() ; 1521 char dateString[30]; 1522 const time_t t = theTime() ; 1522 1523 1523 1524 if ( !seeded ) 1524 1525 { … … 1526 1527 seeded = 1 ; 1527 1528 } 1528 1529 1529 d_printf (1,"Timeout (%d) time now is %ld %s", 1530 (int) tid, (long) t,ctime(&t)) ; 1530 timeToString (t, dateString, sizeof (dateString)) ; 1531 d_printf (1,"Timeout (%d) time now is %ld %s\n", 1532 (int) tid, (long) t, dateString) ; 1531 1533 1532 1534 if (timeoutQueue != NULL && timeoutQueue->next != NULL) 1533 1535 d_printf (1,"%s timeout id %d\n", -
innfeed/main.c
120 120 bool checkConfig = false ; 121 121 bool val; 122 122 123 strlcpy (dateString,ctime(&now),sizeof (dateString)) ;123 timeToString (now, dateString, sizeof (dateString)) ; 124 124 125 125 message_program_name = strrchr (argv [0],'/'); 126 126 if (message_program_name == NULL) … … 289 289 290 290 if ( !checkConfig ) 291 291 { 292 notice ("ME starting at %s (%s)", dateString, INN_VERSION_STRING);292 notice ("ME starting at %s\n (%s)", dateString, INN_VERSION_STRING); 293 293 } 294 294 295 295 val = true; … … 671 671 { 672 672 char *snapshotFile; 673 673 FILE *fp; 674 char nowString[30]; 674 675 time_t now = theTime() ; 675 676 676 677 snapshotFile = concatpath(innconf->pathlog, SNAPSHOT_FILE); … … 689 690 setbuf (fp, NULL) ; 690 691 #endif 691 692 692 fprintf (fp,"----------------------------System snaphot taken at: %s\n", 693 ctime (&now)) ; 693 timeToString (now, nowString, sizeof (nowString)) ; 694 fprintf (fp,"----------------------------System snaphot taken at: %s\n\n", 695 nowString) ; 694 696 gPrintListenerInfo (fp,0) ; 695 697 fprintf (fp,"\n\n\n\n") ; 696 698 gPrintHostInfo (fp,0) ; … … 770 772 free (p) ; 771 773 } 772 774 775 if (getString (topScope,"log-time-format",&p,NO_INHERIT)) 776 { 777 free(timeToStringFormat); 778 timeToStringFormat = p; 779 } 780 773 781 /* For imap/lmtp delivering */ 774 782 if (getString (topScope,"deliver-username",&p, NO_INHERIT)) 775 783 { -
innfeed/innlistener.c
230 230 char dateString [30] ; 231 231 232 232 gHostStats(); 233 strlcpy (dateString,ctime (&now),sizeof (dateString)) ; 234 dateString [24] = '\0' ; 233 timeToString (now, dateString, sizeof (dateString)) ; 235 234 236 235 if (fastExit) 237 236 notice ("ME finishing (quickly) at %s", dateString) ; -
innfeed/misc.c
40 40 unsigned int loggingLevel ; 41 41 char **PointersFreedOnExit ; 42 42 43 char *timeToStringFormat = 0; 43 44 bool debuggingDump = true ; 44 45 extern void (*gPrintInfo) (void) ; 45 46 void (*gCleanUp) (void) = 0 ; … … 115 116 static pid_t myPid ; 116 117 char timeString [30] ; 117 118 time_t now ; 119 struct tm *tm ; 118 120 va_list ap ; 119 121 120 122 if (myPid == 0) … … 124 126 return ; 125 127 126 128 now = theTime() ; 127 /* strip off leading day name */ 128 strlcpy (timeString, ctime (&now) + 4, sizeof (timeString)) ; 129 timeString [15] = '\0' ; /* strip off trailing year and newline */ 129 tm = localtime (&now); 130 strftime (timeString, sizeof(timeString), "%b %d %H:%M:%S", tm); 130 131 131 132 va_start (ap, fmt) ; 132 133 fprintf (stderr, "%s %s[%ld]: ",timeString, … … 591 592 return val ? "true" : "false" ; 592 593 } 593 594 595 char* timeToString(time_t t, char* buffer, size_t size) 596 { 597 static const char defaultFormat[] = "%a %b %d %H:%M:%S %Y" ; 598 const struct tm *const tm = localtime(&t); 599 strftime (buffer, size, 600 timeToStringFormat == 0 ? defaultFormat : timeToStringFormat, tm); 601 return buffer; 602 } 603 594 604 void addPointerFreedOnExit (char *pointerToFree) 595 605 { 596 606 static int totalPointers = 0 ;