summaryrefslogtreecommitdiff
path: root/sysdep/unix/config.Y
diff options
context:
space:
mode:
Diffstat (limited to 'sysdep/unix/config.Y')
-rw-r--r--sysdep/unix/config.Y34
1 files changed, 22 insertions, 12 deletions
diff --git a/sysdep/unix/config.Y b/sysdep/unix/config.Y
index b8572c90..e7ecd735 100644
--- a/sysdep/unix/config.Y
+++ b/sysdep/unix/config.Y
@@ -11,13 +11,16 @@ CF_HDR
#include "sysdep/unix/unix.h"
#include <stdio.h>
+CF_DEFINES
+
+static struct log_config *this_log;
+
CF_DECLS
CF_KEYWORDS(LOG, SYSLOG, ALL, DEBUG, TRACE, INFO, REMOTE, WARNING, ERROR, AUTH, FATAL, BUG, STDERR, SOFT)
CF_KEYWORDS(NAME, CONFIRM, UNDO, CHECK, TIMEOUT, DEBUG, LATENCY, LIMIT, WATCHDOG, WARNING)
%type <i> log_mask log_mask_list log_cat cfg_timeout
-%type <g> log_file
%type <t> cfg_name
%type <tf> timeformat_which
%type <t> syslog_name
@@ -26,11 +29,11 @@ CF_GRAMMAR
conf: log_config ;
-log_config: LOG log_file log_mask ';' {
- struct log_config *c = cfg_allocz(sizeof(struct log_config));
- c->fh = $2;
- c->mask = $3;
- add_tail(&new_config->logfiles, &c->n);
+log_begin: { this_log = cfg_allocz(sizeof(struct log_config)); };
+
+log_config: LOG log_begin log_file log_mask ';' {
+ this_log->mask = $4;
+ add_tail(&new_config->logfiles, &this_log->n);
}
;
@@ -39,14 +42,21 @@ syslog_name:
| { $$ = bird_name; }
;
+log_limit:
+ /* empty */
+ | expr text { this_log->limit = $1; this_log->backup = $2; }
+ ;
+
log_file:
- text {
- struct rfile *f = rf_open(new_config->pool, $1, "a");
- if (!f) cf_error("Unable to open log file '%s': %m", $1);
- $$ = rf_file(f);
+ text log_limit {
+ this_log->rf = rf_open(new_config->pool, $1, "a");
+ if (!this_log->rf) cf_error("Unable to open log file '%s': %m", $1);
+ this_log->fh = rf_file(this_log->rf);
+ this_log->pos = -1;
+ this_log->filename = $1;
}
- | SYSLOG syslog_name { $$ = NULL; new_config->syslog_name = $2; }
- | STDERR { $$ = stderr; }
+ | SYSLOG syslog_name { this_log->fh = NULL; new_config->syslog_name = $2; }
+ | STDERR { this_log->fh = stderr; }
;
log_mask: