From b3f42b0b5de4786752151641ef2af37f5ce3feaf Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 3 Aug 2015 19:44:18 +0000 Subject: Modify logfile to get logging info from the config and use common view --- chrony-controller.lua | 4 ++++ chrony-logfile-html.lsp | 7 +------ chrony-model.lua | 18 ++++++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) mode change 100644 => 120000 chrony-logfile-html.lsp diff --git a/chrony-controller.lua b/chrony-controller.lua index eedffb5..5fbd6d4 100644 --- a/chrony-controller.lua +++ b/chrony-controller.lua @@ -30,4 +30,8 @@ function mymodule.expert(self) return self.handle_form(self, self.model.get_filedetails, self.model.update_filedetails, self.clientdata, "Save", "Edit Config File", "Configuration Set") end +function mymodule.logfile(self) + return self.model.get_logfile(self, self.clientdata) +end + return mymodule diff --git a/chrony-logfile-html.lsp b/chrony-logfile-html.lsp deleted file mode 100644 index a1184f8..0000000 --- a/chrony-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="chronyd"}) -end %> diff --git a/chrony-logfile-html.lsp b/chrony-logfile-html.lsp new file mode 120000 index 0000000..ac8854f --- /dev/null +++ b/chrony-logfile-html.lsp @@ -0,0 +1 @@ +../logfile-html.lsp \ No newline at end of file diff --git a/chrony-model.lua b/chrony-model.lua index 8661e20..12f82f4 100644 --- a/chrony-model.lua +++ b/chrony-model.lua @@ -231,4 +231,22 @@ function mymodule.update_filedetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, {configfile}) end +function mymodule.get_logfile(self, clientdata) + local retval = cfe({ type="structure", value={{facility="daemon", grep="chronyd"}}, label="Log File Configuration" }) + local logdir = "/var/log/chrony" + local config = format.parse_linesandwords(fs.read_file(configfile) or "", "[!;#%%]") + if config then + for i,entry in ipairs(config) do + if entry[1] == "logdir" then + logdir = entry[2] + end + end + end + -- Add in files in the logdir + for f in fs.find(nil, logdir) do + retval.value[#retval.value+1] = {filename=f} + end + return retval +end + return mymodule -- cgit v1.2.3