> > Looking some more, I found some other places that need a space (I
authorBruce Momjian
Sat, 25 Nov 2000 04:38:00 +0000 (04:38 +0000)
committerBruce Momjian
Sat, 25 Nov 2000 04:38:00 +0000 (04:38 +0000)
> > 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:

Larry Rosenman

src/backend/utils/error/elog.c

index 52020544c36be97e52aba33b037abd86c8885eec..9b8c2fd21c83467c5e01bfc2b067c8f87cc23f76 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.67 2000/11/14 19:13:27 petere Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.68 2000/11/25 04:38:00 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -657,7 +657,8 @@ write_syslog(int level, const char *line)
    seq++;
 
    /* divide into multiple syslog() calls if message is too long */
-   if (len > PG_SYSLOG_LIMIT)
+   /* 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,9 +668,17 @@ write_syslog(int level, const char *line)
        {
            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