Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd63a762

Browse files
committed
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 comingfrom the postgresql.conf file.I don't think it's a showstopper..Larry Rosenman
1 parentb557be5 commitd63a762

File tree

3 files changed

+73
-4
lines changed

3 files changed

+73
-4
lines changed

‎doc/src/sgml/runtime.sgml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.33 2000/11/10 16:32:09 tgl Exp $
2+
$Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.34 2000/11/13 21:35:02 momjian Exp $
33
-->
44

55
<Chapter Id="runtime">
@@ -821,6 +821,30 @@ env PGOPTIONS='-c geqo=off' psql
821821
</listitem>
822822
</varlistentry>
823823

824+
<varlistentry>
825+
<term>SYSLOG_FACILITY (<type>string</type>)</term>
826+
<listitem>
827+
<para>
828+
If the SYSLOG option is set to 1 or greater, this option determines
829+
the <application>syslog</application> facility used. You may choose
830+
from LOCAL0, LOCAL1, LOCAL2, LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
831+
the default is LOCAL0
832+
</para>
833+
</listitem>
834+
</varlistentry>
835+
836+
<varlistentry>
837+
<term>SYSLOG_PROGID (<type>string</type>)</term>
838+
<listitem>
839+
<para>
840+
If the SYSLOG option is set to 1 or greater, this option determines
841+
the program id used to identify <product>PostgreSQL</product> messages
842+
in <application>syslog</application> log messages. The default is
843+
postgres.
844+
</para>
845+
</listitem>
846+
</varlistentry>
847+
824848
<varlistentry>
825849
<term>TRACE_NOTIFY (<type>boolean</type>)</term>
826850
<listitem>

‎src/backend/utils/error/elog.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.65 2000/10/30 06:48:36 ishii Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.66 2000/11/13 21:35:02 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -58,6 +58,8 @@ extern CommandDest whereToSendOutput;
5858
* ... in theory anyway
5959
*/
6060
intUse_syslog=0;
61+
char*Syslog_facility="LOCAL0";
62+
char*Syslog_progid="postgres";
6163

6264
staticvoidwrite_syslog(intlevel,constchar*line);
6365

@@ -620,14 +622,31 @@ write_syslog(int level, const char *line)
620622

621623
staticboolopenlog_done= false;
622624
staticunsigned longseq=0;
625+
staticintsyslog_fac=LOG_LOCAL0;
623626
intlen=strlen(line);
624627

625628
if (Use_syslog==0)
626629
return;
627630

628631
if (!openlog_done)
629632
{
630-
openlog("postgres",LOG_PID |LOG_NDELAY,LOG_LOCAL0);
633+
if (strcasecmp(Syslog_facility,"LOCAL0")==0)
634+
syslog_fac=LOG_LOCAL0;
635+
if (strcasecmp(Syslog_facility,"LOCAL1")==0)
636+
syslog_fac=LOG_LOCAL1;
637+
if (strcasecmp(Syslog_facility,"LOCAL2")==0)
638+
syslog_fac=LOG_LOCAL2;
639+
if (strcasecmp(Syslog_facility,"LOCAL3")==0)
640+
syslog_fac=LOG_LOCAL3;
641+
if (strcasecmp(Syslog_facility,"LOCAL4")==0)
642+
syslog_fac=LOG_LOCAL4;
643+
if (strcasecmp(Syslog_facility,"LOCAL5")==0)
644+
syslog_fac=LOG_LOCAL5;
645+
if (strcasecmp(Syslog_facility,"LOCAL6")==0)
646+
syslog_fac=LOG_LOCAL6;
647+
if (strcasecmp(Syslog_facility,"LOCAL7")==0)
648+
syslog_fac=LOG_LOCAL7;
649+
openlog(Syslog_progid,LOG_PID |LOG_NDELAY,syslog_fac);
631650
openlog_done= true;
632651
}
633652

‎src/backend/utils/misc/guc.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* Support for grand unified configuration scheme, including SET
55
* command, configuration file, and command line options.
66
*
7-
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.17 2000/11/1315:18:12 momjian Exp $
7+
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.18 2000/11/1321:35:03 momjian Exp $
88
*
99
* Copyright 2000 by PostgreSQL Global Development Group
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -39,6 +39,11 @@ extern bool Log_connections;
3939
externintCheckPointTimeout;
4040
externintXLOGbuffers;
4141
externintXLOG_DEBUG;
42+
#ifdefENABLE_SYSLOG
43+
externchar*Syslog_facility;
44+
externchar*Syslog_progid;
45+
boolcheck_facility(constchar*facility);
46+
#endif
4247

4348
/*
4449
* Debugging options
@@ -303,6 +308,12 @@ ConfigureNamesString[] =
303308

304309
{"unix_socket_group",PGC_POSTMASTER,&Unix_socket_group,
305310
"",NULL},
311+
#ifdefENABLE_SYSLOG
312+
{"syslog_facility",PGC_SIGHUP,&Syslog_facility,
313+
"LOCAL0",check_facility},
314+
{"syslog_progid",PGC_SIGHUP,&Syslog_progid,
315+
"postgres",NULL},
316+
#endif
306317

307318
{"unixsocket",PGC_POSTMASTER,&UnixSocketName,
308319
"",NULL},
@@ -813,3 +824,18 @@ ParseLongOption(const char * string, char ** name, char ** value)
813824
if (*cp=='-')
814825
*cp='_';
815826
}
827+
#ifdefENABLE_SYSLOG
828+
bool
829+
check_facility(constchar*facility)
830+
{
831+
if (strcasecmp(facility,"LOCAL0")==0)return true;
832+
if (strcasecmp(facility,"LOCAL1")==0)return true;
833+
if (strcasecmp(facility,"LOCAL2")==0)return true;
834+
if (strcasecmp(facility,"LOCAL3")==0)return true;
835+
if (strcasecmp(facility,"LOCAL4")==0)return true;
836+
if (strcasecmp(facility,"LOCAL5")==0)return true;
837+
if (strcasecmp(facility,"LOCAL6")==0)return true;
838+
if (strcasecmp(facility,"LOCAL7")==0)return true;
839+
return false;
840+
}
841+
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp