From 294502ad752a57a50ec9826a090a6c19ab658bc2 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 3 Aug 2015 15:57:06 +0000 Subject: Modify logfile to get logging info from the config and use common view --- dnsmasq-controller.lua | 4 ++++ dnsmasq-logfile-html.lsp | 7 +------ dnsmasq-model.lua | 20 ++++++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) mode change 100644 => 120000 dnsmasq-logfile-html.lsp diff --git a/dnsmasq-controller.lua b/dnsmasq-controller.lua index 22fe912..c20cab0 100644 --- a/dnsmasq-controller.lua +++ b/dnsmasq-controller.lua @@ -22,4 +22,8 @@ function mymodule.viewleases(self) return self.model.getleases() end +function mymodule.logfile(self) + return self.model.get_logfile(self, self.clientdata) +end + return mymodule diff --git a/dnsmasq-logfile-html.lsp b/dnsmasq-logfile-html.lsp deleted file mode 100644 index 771b9cd..0000000 --- a/dnsmasq-logfile-html.lsp +++ /dev/null @@ -1,6 +0,0 @@ -<% local data, viewlibrary = ... -%> - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename="/var/log/messages", grep="dnsmasq"}) -end %> diff --git a/dnsmasq-logfile-html.lsp b/dnsmasq-logfile-html.lsp new file mode 120000 index 0000000..ac8854f --- /dev/null +++ b/dnsmasq-logfile-html.lsp @@ -0,0 +1 @@ +../logfile-html.lsp \ No newline at end of file diff --git a/dnsmasq-model.lua b/dnsmasq-model.lua index c6e4ddd..287947d 100644 --- a/dnsmasq-model.lua +++ b/dnsmasq-model.lua @@ -344,4 +344,24 @@ function mymodule.getleases() return modelfunctions.getfiledetails(leasefile) end +function mymodule.get_logfile(self, clientdata) + local retval = cfe({ type="group", value={}, label="Log File Configuration" }) + retval.value.facility = cfe({value="daemon", label="Syslog Facility"}) + retval.value.grep = cfe({ value="dnsmasq", label="Grep" }) + + local conf = parse_file(fs.read_file(configfile) or "") or {} + if conf["log-facility"] then + local facility = conf["log-facility"][1] + if string.find(facility, "/") then + retval.value.filename = cfe({value=facility, label="File name"}) + retval.value.facility = nil + retval.value.grep = nil + elseif not string.find(facility, "^%-$") then + retval.value.facility.value = string.lower(facility) + end + end + + return retval +end + return mymodule -- cgit v1.2.3