Re: Syslog Facility Patch

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Larry Rosenman <ler(at)lerctr(dot)org>, PostgreSQL Hackers List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Syslog Facility Patch
Date: 2000-11-13 23:45:10
Message-ID: 200011132345.SAA17466@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

There were problems? I saw someone asking why it hadn't been applied
yet. What do people want? I can back it out.

> Bruce Momjian writes:
>
> > Applied.
>
> Uh, shouldn't the problems Larry pointed out be fixed first?
>
> >
> >
> > > Ok, You guys are probably tired of me, BUT, here is another one, that
> > > adds the facility to set the program name used in syslog.
> > > (this includes the other ones).
> > >
> > > One gotcha, the parser doesn't like special characters in strings.
> > > For example, i tried to use pg-test, and if failed the parse coming
> > > from the postgresql.conf file.
> > >
> > > I don't think it's a showstopper..
> > >
> > > Comments?
> > >
> > >
> > >
> > > Index: doc/src/sgml/runtime.sgml
> > > ===================================================================
> > > RCS file: /home/projects/pgsql/cvsroot/pgsql/doc/src/sgml/runtime.sgml,v
> > > retrieving revision 1.33
> > > diff -c -r1.33 runtime.sgml
> > > *** doc/src/sgml/runtime.sgml 2000/11/10 16:32:09 1.33
> > > --- doc/src/sgml/runtime.sgml 2000/11/13 01:15:34
> > > ***************
> > > *** 822,827 ****
> > > --- 822,851 ----
> > > </varlistentry>
> > >
> > > <varlistentry>
> > > + <term>SYSLOG_FACILITY (<type>string</type>)</term>
> > > + <listitem>
> > > + <para>
> > > + If the SYSLOG option is set to 1 or greater, this option determines
> > > + the <application>syslog</application> facility used. You may choose
> > > + from LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
> > > + the default is LOCAL0
> > > + </para>
> > > + </listitem>
> > > + </varlistentry>
> > > +
> > > + <varlistentry>
> > > + <term>SYSLOG_PROGID (<type>string</type>)</term>
> > > + <listitem>
> > > + <para>
> > > + If the SYSLOG option is set to 1 or greater, this option determines
> > > + the program id used to identify <product>PostgreSQL</product> messages
> > > + in <application>syslog</application> log messages. The default is
> > > + postgres.
> > > + </para>
> > > + </listitem>
> > > + </varlistentry>
> > > +
> > > + <varlistentry>
> > > <term>TRACE_NOTIFY (<type>boolean</type>)</term>
> > > <listitem>
> > > <para>
> > > Index: src/backend/utils/error/elog.c
> > > ===================================================================
> > > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/error/elog.c,v
> > > retrieving revision 1.65
> > > diff -c -r1.65 elog.c
> > > *** src/backend/utils/error/elog.c 2000/10/30 06:48:36 1.65
> > > --- src/backend/utils/error/elog.c 2000/11/13 01:15:37
> > > ***************
> > > *** 58,63 ****
> > > --- 58,65 ----
> > > * ... in theory anyway
> > > */
> > > int Use_syslog = 0;
> > > + char *Syslog_facility = "LOCAL0";
> > > + char *Syslog_progid = "postgres";
> > >
> > > static void write_syslog(int level, const char *line);
> > >
> > > ***************
> > > *** 620,625 ****
> > > --- 622,628 ----
> > >
> > > static bool openlog_done = false;
> > > static unsigned long seq = 0;
> > > + static int syslog_fac = LOG_LOCAL0;
> > > int len = strlen(line);
> > >
> > > if (Use_syslog == 0)
> > > ***************
> > > *** 627,633 ****
> > >
> > > if (!openlog_done)
> > > {
> > > ! openlog("postgres", LOG_PID | LOG_NDELAY, LOG_LOCAL0);
> > > openlog_done = true;
> > > }
> > >
> > > --- 630,652 ----
> > >
> > > if (!openlog_done)
> > > {
> > > ! if (strcasecmp(Syslog_facility,"LOCAL0") == 0)
> > > ! syslog_fac = LOG_LOCAL0;
> > > ! if (strcasecmp(Syslog_facility,"LOCAL1") == 0)
> > > ! syslog_fac = LOG_LOCAL1;
> > > ! if (strcasecmp(Syslog_facility,"LOCAL2") == 0)
> > > ! syslog_fac = LOG_LOCAL2;
> > > ! if (strcasecmp(Syslog_facility,"LOCAL3") == 0)
> > > ! syslog_fac = LOG_LOCAL3;
> > > ! if (strcasecmp(Syslog_facility,"LOCAL4") == 0)
> > > ! syslog_fac = LOG_LOCAL4;
> > > ! if (strcasecmp(Syslog_facility,"LOCAL5") == 0)
> > > ! syslog_fac = LOG_LOCAL5;
> > > ! if (strcasecmp(Syslog_facility,"LOCAL6") == 0)
> > > ! syslog_fac = LOG_LOCAL6;
> > > ! if (strcasecmp(Syslog_facility,"LOCAL7") == 0)
> > > ! syslog_fac = LOG_LOCAL7;
> > > ! openlog(Syslog_progid, LOG_PID | LOG_NDELAY, syslog_fac);
> > > openlog_done = true;
> > > }
> > >
> > > Index: src/backend/utils/misc/guc.c
> > > ===================================================================
> > > RCS file: /home/projects/pgsql/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
> > > retrieving revision 1.16
> > > diff -c -r1.16 guc.c
> > > *** src/backend/utils/misc/guc.c 2000/11/09 11:25:59 1.16
> > > --- src/backend/utils/misc/guc.c 2000/11/13 01:15:38
> > > ***************
> > > *** 39,44 ****
> > > --- 39,49 ----
> > > extern int CheckPointTimeout;
> > > extern int XLOGbuffers;
> > > extern int XLOG_DEBUG;
> > > + #ifdef ENABLE_SYSLOG
> > > + extern char *Syslog_facility;
> > > + extern char *Syslog_progid;
> > > + bool check_facility(const char *facility);
> > > + #endif
> > >
> > > /*
> > > * Debugging options
> > > ***************
> > > *** 303,308 ****
> > > --- 308,319 ----
> > >
> > > {"unix_socket_group", PGC_POSTMASTER, &Unix_socket_group,
> > > "", NULL},
> > > + #ifdef ENABLE_SYSLOG
> > > + {"syslog_facility", PGC_SIGHUP, &Syslog_facility,
> > > + "LOCAL0", check_facility},
> > > + {"syslog_progid", PGC_SIGHUP, &Syslog_progid,
> > > + "postgres", NULL},
> > > + #endif
> > >
> > > {NULL, 0, NULL, NULL, NULL}
> > > };
> > > ***************
> > > *** 807,809 ****
> > > --- 818,835 ----
> > > if (*cp == '-')
> > > *cp = '_';
> > > }
> > > + #ifdef ENABLE_SYSLOG
> > > + bool
> > > + check_facility(const char *facility)
> > > + {
> > > + if (strcasecmp(facility,"LOCAL0") == 0) return true;
> > > + if (strcasecmp(facility,"LOCAL1") == 0) return true;
> > > + if (strcasecmp(facility,"LOCAL2") == 0) return true;
> > > + if (strcasecmp(facility,"LOCAL3") == 0) return true;
> > > + if (strcasecmp(facility,"LOCAL4") == 0) return true;
> > > + if (strcasecmp(facility,"LOCAL5") == 0) return true;
> > > + if (strcasecmp(facility,"LOCAL6") == 0) return true;
> > > + if (strcasecmp(facility,"LOCAL7") == 0) return true;
> > > + return false;
> > > + }
> > > + #endif
> > > --
> > > Larry Rosenman http://www.lerctr.org/~ler
> > > Phone: +1 972-414-9812 (voice) Internet: ler(at)lerctr(dot)org
> > > US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
> > >
> >
> >
> >
>
> --
> Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/
>
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2000-11-13 23:45:50 Re: Syslog Facility Patch
Previous Message Larry Rosenman 2000-11-13 23:45:02 Re: Syslog Facility Patch