* Tom Lane <[EMAIL PROTECTED]> [001122 22:44]:
> Larry Rosenman <[EMAIL PROTECTED]> writes:
> > Looking some more, I found some other places that need a space (I
> > suspect...), so here is an updated patch.
> 
> This seems like the wrong way to go about it, because anytime anyone
> changes any elog output anywhere, we'll risk another failure.  If
> syslog can't cope with empty lines, I think the right fix is for the
> output-to-syslog routine to change the data just before sending ---
> then there is only one place to fix.  See the syslog output routine in
> src/backend/utils/error/elog.c.
Makes sense.  Here's a new patch, now the output even looks better:
Nov 23 00:58:04 lerami pg-test[9914]: [2-1] NOTICE:  QUERY PLAN:
Nov 23 00:58:04 lerami pg-test[9914]: [2-2] 
Nov 23 00:58:04 lerami pg-test[9914]: [2-3] Seq Scan on upsdata
(cost=0.00..2766.62 rows=2308 width=48)
Nov 23 00:58:04 lerami pg-test[9914]: [2-4] 


Index: src/backend/utils/error/elog.c
===================================================================
RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/error/elog.c,v
retrieving revision 1.67
diff -c -r1.67 elog.c
*** src/backend/utils/error/elog.c      2000/11/14 19:13:27     1.67
--- src/backend/utils/error/elog.c      2000/11/23 06:58:23
***************
*** 657,663 ****
        seq++;
  
        /* divide into multiple syslog() calls if message is too long */
!       if (len > PG_SYSLOG_LIMIT)
        {
                static char     buf[PG_SYSLOG_LIMIT+1];
                int chunk_nr = 0;
--- 657,664 ----
        seq++;
  
        /* divide into multiple syslog() calls if message is too long */
!       /* or if the message contains embedded NewLine(s) '\n' */
!       if (len > PG_SYSLOG_LIMIT || strchr(line,'\n') != NULL )
        {
                static char     buf[PG_SYSLOG_LIMIT+1];
                int chunk_nr = 0;
***************
*** 667,675 ****
--- 668,684 ----
                {
                        int l;
                        int i;
+                       /* if we start at a newline, move ahead one char */
+                       if (line[0] == '\n')
+                       {
+                               line++;
+                               len--;
+                       }
  
                        strncpy(buf, line, PG_SYSLOG_LIMIT);
                        buf[PG_SYSLOG_LIMIT] = '\0';
+                       if (strchr(buf,'\n') != NULL) 
+                               *strchr(buf,'\n') = '\0';
  
                        l = strlen(buf);
  #ifdef MULTIBYTE
-- 
Larry Rosenman                      http://www.lerctr.org/~ler
Phone: +1 972-414-9812 (voice) Internet: [EMAIL PROTECTED]
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749

Reply via email to