diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-25 16:09:11 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2009-04-25 16:09:11 +0300 |
commit | ac1d885f562d4c45069ef3f9460917153cad1344 (patch) | |
tree | 5584de198ec33ea947617826f46d49dd74316960 /src/readconfig.c | |
parent | 55bb0a274095c4871e333e80d78873609bc39d3a (diff) | |
download | tagr-ac1d885f562d4c45069ef3f9460917153cad1344.tar.gz tagr-ac1d885f562d4c45069ef3f9460917153cad1344.tar.bz2 |
More bugfixes.
* Makefile.am (SUBDIRS): Add etc.
* etc/Makefile.am: New file.
* src/html.gram.y (create_html): Bugfixes.
(add_value): Replace existing entry, if found.
* src/log.c (log_facility, log_tag, log_print_severity): New variables.
* src/main.c (sig_child): Collect all terminated subprocesses.
(main): Redo syslog initialization.
Use daemon.
* src/output.c (add_stats): Exit immediately if the queue is empty.
(update_output): Redefine some symbols unconditionally.
* src/readconfig.c: Logging configuration.
* src/tagr.h (log_facility, log_tag, log_print_severity): New variables.
Diffstat (limited to 'src/readconfig.c')
-rw-r--r-- | src/readconfig.c | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/src/readconfig.c b/src/readconfig.c index 19daded..208731e 100644 --- a/src/readconfig.c +++ b/src/readconfig.c @@ -22,6 +22,7 @@ #include <string.h> #include <stdlib.h> #include <ctype.h> +#include <syslog.h> #define obstack_chunk_alloc malloc #define obstack_chunk_free free #include <obstack.h> @@ -239,6 +240,79 @@ cb_color (enum grecs_callback_command cmd, +static int +cb_facility (enum grecs_callback_command cmd, + grecs_locus_t *locus, + void *varptr, + grecs_value_t *value, + void *cb_data) +{ + int *iptr = varptr; + const char *str; + int i; + static struct log_xlat + { + const char *name; + int facility; + } xlat_tab[] = { + { "USER", LOG_USER }, + { "DAEMON", LOG_DAEMON }, + { "AUTH", LOG_AUTH }, + { "AUTHPRIV",LOG_AUTHPRIV }, + { "MAIL", LOG_MAIL }, + { "CRON", LOG_CRON }, + { "LOCAL0", LOG_LOCAL0 }, + { "LOCAL1", LOG_LOCAL1 }, + { "LOCAL2", LOG_LOCAL2 }, + { "LOCAL3", LOG_LOCAL3 }, + { "LOCAL4", LOG_LOCAL4 }, + { "LOCAL5", LOG_LOCAL5 }, + { "LOCAL6", LOG_LOCAL6 }, + { "LOCAL7", LOG_LOCAL7 }, + { NULL } + }; + + if (cmd != grecs_callback_set_value) + { + grecs_error (locus, 0, _("Unexpected block statement")); + return 1; + } + if (value->type != GCONF_TYPE_STRING) + { + grecs_error (locus, 0, _("expected scalar value but found list")); + return 1; + } + str = value->v.string; + if (strncasecmp (str, "LOG_", 4) == 0) + str += 4; + + for (i = 0; xlat_tab[i].name; i++) + if (strcasecmp (str, xlat_tab[i].name) == 0) + { + *iptr = xlat_tab[i].facility; + return 0; + } + + grecs_error (locus, 0, _("unknown syslog facility")); + return 0; +} + +static struct grecs_keyword log_kw[] = { + { "tag", N_("arg"), N_("Tag syslog diagnostics with this tag."), + grecs_type_string, &log_tag, 0 }, + { "log-facility", N_("arg"), + N_("Set syslog facility. Arg is one of the following: user, daemon, " + "auth, authpriv, mail, cron, local0 through local7 " + "(case-insensitive), or a facility number."), + grecs_type_string, NULL, 0, cb_facility }, + { "print-severity", N_("arg"), + N_("Prefix diagnostics messages with their severity."), + grecs_type_bool, &log_print_severity, 0 }, + { NULL } +}; + + + static struct grecs_keyword tagr_kw[] = { { "basedir", NULL, N_("Set base directory name"), grecs_type_string, &basedir }, @@ -257,6 +331,10 @@ static struct grecs_keyword tagr_kw[] = { grecs_type_section, NULL, 0, cb_monitor, NULL, monitor_kw }, + { "log", NULL, N_("Configure logging"), + grecs_type_section, NULL, 0, + NULL, NULL, log_kw }, + { "rate-units", NULL, N_("Name of rate units"), grecs_type_string, &rate_unit }, { "number-suffixes", N_("suffixes"), NULL /* FIXME */, |