/ Zope / Apsis / Pound Mailing List / Archive / 2004 / 2004-08 / Flushing logmsg

[ << ] [ >> ]

[ BIO_read() returns EAGAIN? / Bill Anderson ... ] [ Problem with session cookies / Nick Delany ... ]

Flushing logmsg
Bart Teeuwisse <bart.teeuwisse(at)thecodemill.biz>
2004-08-13 01:08:21 [ FULL ]
Robert,

would you be so kind to flush log messages written to stdout and stderr? 
The simple change below would allow Pound users to pipe Pound's messages 
to logging applications like multilog 
(http://cr.yp.to/daemontools/multilog.html).

I personally prefer to run Pound under daemontools control with Pound's 
messages logged by multilog. Daemontools ensures that Pound is up and 
running and multilog ensures that Pound's log files never fill up the 
hard drive.

--- orig/svc.c
+++ mod/svc.c
(at)(at) -163,15 +163,17 (at)(at)
     vsnprintf(buf, MAXBUF, fmt, ap);
     va_end(ap);
 #ifdef  NO_SYSLOG
-    if(priority == LOG_INFO)
+    if(priority == LOG_INFO) {
         printf("%s\n", buf);
-    else {
+        fflush(stdout);
+    } else {
         char    t_stamp[32];
         time_t  now;
 
         now = time(NULL);
         strftime(t_stamp, sizeof(t_stamp), "%d/%b/%Y %H:%M:%S %z", 
localtime(&now));
         fprintf(stderr, "%s: %s\n", t_stamp, buf);
+        fflush(stderr);
     }
 #else
     syslog(priority, "%s", buf);


Thanks,
[...]

Re: Flushing logmsg
Robert Segall <roseg(at)apsis.ch>
2004-08-16 12:33:44 [ FULL ]
On Friday 13 August 2004 01.08, Bart Teeuwisse wrote:[...]

Take the new -current (just uploaded). It flushes stdout on each write. stderr 
is unbuffered by definition.
[...]

My preference as well...
[...]

You're welcome.[...]

MailBoxer