Skip to content
Snippets Groups Projects
Commit 36e1698e authored by Daniel Salzman's avatar Daniel Salzman
Browse files

Merge branch 'log_defaults_fix' of /git/repositories/knot

parents fdb4376e 1fafff6b
No related branches found
No related tags found
No related merge requests found
......@@ -985,7 +985,8 @@ log_start:
| log_start log_file '{' log_src '}'
;
log: LOG '{' log_start log_end;
log: LOG { new_config->logs_count = 0; } '{' log_start log_end
;
ctl_listen_start:
LISTEN_ON { conf_init_iface(scanner, NULL, -1); }
......
......@@ -393,7 +393,7 @@ void __attribute__ ((constructor)) conf_init()
map->prios = LOG_MASK(LOG_WARNING)|LOG_MASK(LOG_ERR);
add_tail(&log->map, &map->n);
add_tail(&s_config->logs, &log->n);
++s_config->logs_count;
s_config->logs_count = 1;
/* Stderr */
log = malloc(sizeof(conf_log_t));
......@@ -529,6 +529,7 @@ conf_t *conf_new(const char* path)
c->xfers = -1;
c->rrl_slip = -1;
c->build_diffs = 0; /* Disable by default. */
c->logs_count = -1;
/* ACLs. */
c->ctl.acl = acl_new(ACL_DENY, "remote_ctl");
......@@ -633,7 +634,7 @@ void conf_truncate(conf_t *conf, int unload_hooks)
WALK_LIST_DELSAFE(n, nxt, conf->logs) {
conf_free_log((conf_log_t*)n);
}
conf->logs_count = 0;
conf->logs_count = -1;
init_list(&conf->logs);
// Free remote interfaces
......
......@@ -34,13 +34,15 @@ int log_conf_hook(const struct conf_t *conf, void *data)
int ret = 0;
UNUSED(data);
// Check if log declaration exists, otherwise ignore
if (conf->logs_count < 1) {
return KNOT_EINVAL;
// Use defaults if no 'log' section is configured.
if (conf->logs_count < 0) {
log_close();
log_init();
return KNOT_EOK;
}
// Find maximum log facility id
node *n = 0; size_t files = 0;
node *n = NULL; size_t files = 0;
WALK_LIST(n, conf->logs) {
conf_log_t* log = (conf_log_t*)n;
if (log->type == LOGT_FILE) {
......@@ -55,8 +57,7 @@ int log_conf_hook(const struct conf_t *conf, void *data)
}
// Setup logs
int loaded_sections = 0;
n = 0;
n = NULL;
WALK_LIST(n, conf->logs) {
// Calculate offset
......@@ -71,13 +72,6 @@ int log_conf_hook(const struct conf_t *conf, void *data)
}
}
// Auto-assign fatal errors to syslog or stderr
if (facility <= LOGT_STDERR) {
int mask = LOG_MASK(LOG_FATAL);
log_levels_add(facility, LOG_ANY, mask);
loaded_sections |= 1 << facility;
}
// Setup sources mapping
node *m = 0;
WALK_LIST(m, log->map) {
......@@ -88,14 +82,5 @@ int log_conf_hook(const struct conf_t *conf, void *data)
}
}
// Load defaults for syslog or stderr
int bmask = LOG_MASK(LOG_ERR)|LOG_MASK(LOG_FATAL);
if (!(loaded_sections & (1 << LOGT_SYSLOG))) {
log_levels_set(LOGT_SYSLOG, LOG_ANY, bmask);
}
if (!(loaded_sections & (1 << LOGT_STDERR))) {
log_levels_set(LOGT_STDERR, LOG_ANY, bmask);
}
return KNOT_EOK;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment