diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2017-02-14 11:59:14 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2017-02-14 13:38:26 +0100 |
commit | a898ee5458950203d4b2f8fec28c85313c855b91 (patch) | |
tree | f1b37449b5fd354e31a16c466957472cf4aa5fb1 /src/config.c | |
parent | 51c756cfc15c63322df9fdb70d5c701cfb6b9a9f (diff) |
config: make loglevel configurable via uci (FS#481)
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/config.c')
-rw-r--r-- | src/config.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/config.c b/src/config.c index 5174f2c..69a3ad1 100644 --- a/src/config.c +++ b/src/config.c @@ -6,6 +6,7 @@ #include <libgen.h> #include <string.h> #include <sys/stat.h> +#include <syslog.h> #include <uci.h> #include <uci_blob.h> @@ -16,7 +17,8 @@ static struct blob_buf b; static int reload_pipe[2]; struct list_head leases = LIST_HEAD_INIT(leases); struct list_head interfaces = LIST_HEAD_INIT(interfaces); -struct config config = {false, NULL, NULL}; +struct config config = {.legacy = false, .dhcp_cb = NULL, + .dhcp_statefile = NULL, .log_level = LOG_INFO}; enum { IFACE_ATTR_INTERFACE, @@ -123,6 +125,7 @@ enum { ODHCPD_ATTR_MAINDHCP, ODHCPD_ATTR_LEASEFILE, ODHCPD_ATTR_LEASETRIGGER, + ODHCPD_ATTR_LOGLEVEL, ODHCPD_ATTR_MAX }; @@ -130,6 +133,7 @@ static const struct blobmsg_policy odhcpd_attrs[LEASE_ATTR_MAX] = { [ODHCPD_ATTR_MAINDHCP] = { .name = "maindhcp", .type = BLOBMSG_TYPE_BOOL }, [ODHCPD_ATTR_LEASEFILE] = { .name = "leasefile", .type = BLOBMSG_TYPE_STRING }, [ODHCPD_ATTR_LEASETRIGGER] = { .name = "leasetrigger", .type = BLOBMSG_TYPE_STRING }, + [ODHCPD_ATTR_LOGLEVEL] = { .name = "loglevel", .type = BLOBMSG_TYPE_INT32 }, }; const struct uci_blob_param_list odhcpd_attr_list = { @@ -247,6 +251,15 @@ static void set_config(struct uci_section *s) free(config.dhcp_cb); config.dhcp_cb = strdup(blobmsg_get_string(c)); } + + if ((c = tb[ODHCPD_ATTR_LOGLEVEL])) { + int log_level = (blobmsg_get_u32(c) & LOG_PRIMASK); + + if (config.log_level != log_level) { + config.log_level = log_level; + setlogmask(LOG_UPTO(config.log_level)); + } + } } static double parse_leasetime(struct blob_attr *c) { |