postgres.git / summary / log / commit / refs
commit 91ba4cc76182ed0a501fd53a775eb87341c60141
Author: Bruce Momjian <bruce@momjian.us>
Date: Sat Nov 25 04:38:00 2000 +0000
> > 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:
Larry Rosenman
src/backend/utils/error/elog.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 52020544c36..9b8c2fd21c8 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -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
[parent: d5d23dde25e3]