Skip to content

Commit 409e386

Browse files
committed
Convert syslog_facility guc to enum type.
1 parent b011c5f commit 409e386

File tree

1 file changed

+31
-41
lines changed
  • src/backend/utils/misc

1 file changed

+31
-41
lines changed

src/backend/utils/misc/guc.c

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.441 2008/04/02 14:42:56 mha Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.442 2008/04/03 09:21:15 mha Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -135,8 +135,8 @@ static const char *assign_log_destination(const char *value,
135135
#ifdef HAVE_SYSLOG
136136
static int syslog_facility = LOG_LOCAL0;
137137

138-
static const char *assign_syslog_facility(const char *facility,
139-
bool doit, GucSource source);
138+
static bool assign_syslog_facility(int newval,
139+
bool doit, GucSource source);
140140
static const char *assign_syslog_ident(const char *ident,
141141
bool doit, GucSource source);
142142
#endif
@@ -229,6 +229,18 @@ static const struct config_enum_entry session_replication_role_options[] = {
229229
{NULL, 0}
230230
};
231231

232+
static const struct config_enum_entry syslog_facility_options[] = {
233+
{"local0", LOG_LOCAL0},
234+
{"local1", LOG_LOCAL1},
235+
{"local2", LOG_LOCAL2},
236+
{"local3", LOG_LOCAL3},
237+
{"local4", LOG_LOCAL4},
238+
{"local5", LOG_LOCAL5},
239+
{"local6", LOG_LOCAL6},
240+
{"local7", LOG_LOCAL7},
241+
{NULL, 0}
242+
};
243+
232244

233245
/*
234246
* GUC option variables that are exported from this module
@@ -283,7 +295,6 @@ int tcp_keepalives_count;
283295
static char *log_destination_string;
284296

285297
#ifdef HAVE_SYSLOG
286-
static char *syslog_facility_str;
287298
static char *syslog_ident_str;
288299
#endif
289300
static bool phony_autocommit;
@@ -2231,15 +2242,6 @@ static struct config_string ConfigureNamesString[] =
22312242
},
22322243

22332244
#ifdef HAVE_SYSLOG
2234-
{
2235-
{"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
2236-
gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
2237-
gettext_noop("Valid values are LOCAL0, LOCAL1, LOCAL2, LOCAL3, "
2238-
"LOCAL4, LOCAL5, LOCAL6, LOCAL7.")
2239-
},
2240-
&syslog_facility_str,
2241-
"LOCAL0", assign_syslog_facility, NULL
2242-
},
22432245
{
22442246
{"syslog_ident", PGC_SIGHUP, LOGGING_WHERE,
22452247
gettext_noop("Sets the program name used to identify PostgreSQL "
@@ -2488,6 +2490,18 @@ static struct config_enum ConfigureNamesEnum[] =
24882490
LOGSTMT_NONE, log_statement_options, NULL, NULL
24892491
},
24902492

2493+
#ifdef HAVE_SYSLOG
2494+
{
2495+
{"syslog_facility", PGC_SIGHUP, LOGGING_WHERE,
2496+
gettext_noop("Sets the syslog \"facility\" to be used when syslog enabled."),
2497+
gettext_noop("Valid values are LOCAL0, LOCAL1, LOCAL2, LOCAL3, "
2498+
"LOCAL4, LOCAL5, LOCAL6, LOCAL7.")
2499+
},
2500+
&syslog_facility,
2501+
LOG_LOCAL0, syslog_facility_options, assign_syslog_facility, NULL
2502+
},
2503+
#endif
2504+
24912505
{
24922506
{"regex_flavor", PGC_USERSET, COMPAT_OPTIONS_PREVIOUS,
24932507
gettext_noop("Sets the regular expression \"flavor\"."),
@@ -6860,38 +6874,14 @@ assign_log_destination(const char *value, bool doit, GucSource source)
68606874

68616875
#ifdef HAVE_SYSLOG
68626876

6863-
static const char *
6864-
assign_syslog_facility(const char *facility, bool doit, GucSource source)
6877+
static bool
6878+
assign_syslog_facility(int newval, bool doit, GucSource source)
68656879
{
6866-
int syslog_fac;
6867-
6868-
if (pg_strcasecmp(facility, "LOCAL0") == 0)
6869-
syslog_fac = LOG_LOCAL0;
6870-
else if (pg_strcasecmp(facility, "LOCAL1") == 0)
6871-
syslog_fac = LOG_LOCAL1;
6872-
else if (pg_strcasecmp(facility, "LOCAL2") == 0)
6873-
syslog_fac = LOG_LOCAL2;
6874-
else if (pg_strcasecmp(facility, "LOCAL3") == 0)
6875-
syslog_fac = LOG_LOCAL3;
6876-
else if (pg_strcasecmp(facility, "LOCAL4") == 0)
6877-
syslog_fac = LOG_LOCAL4;
6878-
else if (pg_strcasecmp(facility, "LOCAL5") == 0)
6879-
syslog_fac = LOG_LOCAL5;
6880-
else if (pg_strcasecmp(facility, "LOCAL6") == 0)
6881-
syslog_fac = LOG_LOCAL6;
6882-
else if (pg_strcasecmp(facility, "LOCAL7") == 0)
6883-
syslog_fac = LOG_LOCAL7;
6884-
else
6885-
return NULL; /* reject */
6886-
68876880
if (doit)
6888-
{
6889-
syslog_facility = syslog_fac;
68906881
set_syslog_parameters(syslog_ident_str ? syslog_ident_str : "postgres",
6891-
syslog_facility);
6892-
}
6882+
newval);
68936883

6894-
return facility;
6884+
return true;
68956885
}
68966886

68976887
static const char *

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy