0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-17 16:48:43 +00:00

Allow logging to stderr as well.

This commit is contained in:
Martin Mares 1999-12-06 13:51:04 +00:00
parent 4ab5331c63
commit f78056fb2c
3 changed files with 19 additions and 12 deletions

View File

@ -12,29 +12,33 @@ CF_HDR
CF_DECLS CF_DECLS
CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG) CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR)
%type <i> log_mask log_mask_list log_cat %type <i> log_mask log_mask_list log_cat
%type <g> log_file
CF_GRAMMAR CF_GRAMMAR
CF_ADDTO(conf, log_config) CF_ADDTO(conf, log_config)
log_config: LOG TEXT log_mask ';' { log_config: LOG log_file log_mask ';' {
struct log_config *c = cfg_allocz(sizeof(struct log_config));
FILE *f = rfopen(new_config->pool, $2, "a");
if (!f) cf_error("Unable to open log file `%s': %m", $2);
c->mask = $3;
c->fh = f;
add_tail(&new_config->logfiles, &c->n);
}
| LOG SYSLOG log_mask ';' {
struct log_config *c = cfg_allocz(sizeof(struct log_config)); struct log_config *c = cfg_allocz(sizeof(struct log_config));
c->fh = $2;
c->mask = $3; c->mask = $3;
add_tail(&new_config->logfiles, &c->n); add_tail(&new_config->logfiles, &c->n);
} }
; ;
log_file:
TEXT {
FILE *f = tracked_fopen(new_config->pool, $1, "a");
if (!f) cf_error("Unable to open log file `%s': %m", $1);
$$ = f;
}
| SYSLOG { $$ = NULL; }
| STDERR { $$ = stderr; }
;
log_mask: log_mask:
ALL { $$ = ~0; } ALL { $$ = ~0; }
| '{' log_mask_list '}' { $$ = $2; } | '{' log_mask_list '}' { $$ = $2; }

View File

@ -83,7 +83,7 @@ static struct resclass rf_class = {
}; };
void * void *
rfopen(pool *p, char *name, char *mode) tracked_fopen(pool *p, char *name, char *mode)
{ {
FILE *f = fopen(name, mode); FILE *f = fopen(name, mode);

View File

@ -167,7 +167,10 @@ log_init(int debug)
void void
log_switch(list *l) log_switch(list *l)
{ {
current_log_list = l; if (EMPTY_LIST(*l))
current_log_list = &init_log_list;
else
current_log_list = l;
} }
void void