From 8addabae08034da1f6e4ea6059148ecc1ea9d045 Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Sat, 31 Oct 2015 20:33:25 +0000 Subject: Modify logfile to get logging info from the config and use common view --- postgresql-controller.lua | 4 ++++ postgresql-logfile-html.lsp | 7 +------ postgresql-model.lua | 30 ++++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 6 deletions(-) mode change 100644 => 120000 postgresql-logfile-html.lsp diff --git a/postgresql-controller.lua b/postgresql-controller.lua index 2b375e8..b2d80c2 100644 --- a/postgresql-controller.lua +++ b/postgresql-controller.lua @@ -28,6 +28,10 @@ function mymodule.expert(self) return self.handle_form(self, function() return self.model.getfiledetails(self.clientdata.filename) end, self.model.updatefiledetails, self.clientdata, "Save", "Edit Postgresql File", "File Saved") end +function mymodule.logfile(self) + return self.model.get_logfile(self, self.clientdata) +end + -- Use acf-db to allow editing of the database dbcontrollerfunctions = require("dbcontrollerfunctions") for n,f in pairs(dbcontrollerfunctions) do diff --git a/postgresql-logfile-html.lsp b/postgresql-logfile-html.lsp deleted file mode 100644 index 0b81a65..0000000 --- a/postgresql-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="postgres"}) -end %> diff --git a/postgresql-logfile-html.lsp b/postgresql-logfile-html.lsp new file mode 120000 index 0000000..ac8854f --- /dev/null +++ b/postgresql-logfile-html.lsp @@ -0,0 +1 @@ +../logfile-html.lsp \ No newline at end of file diff --git a/postgresql-model.lua b/postgresql-model.lua index 8e6e4cd..8bfe047 100644 --- a/postgresql-model.lua +++ b/postgresql-model.lua @@ -105,6 +105,36 @@ function mymodule.updatefiledetails(self, filedetails) return modelfunctions.setfiledetails(self, filedetails, determinefilelist()) end +function mymodule.get_logfile(self, clientdata) + local retval = cfe({ type="structure", value={}, label="Log File Configuration" }) + + if string.find(getconfvalue("log_destination") or "", "syslog") then + retval.value[#retval.value+1] = {facility=getconfvalue("syslog_facility") or "local0", grep=getconfvalue("syslog_ident") or "postgres"} + end + + if getconfvalue("logging_collector") == "on" then + local logdir = getconfvalue("log_directory") or "pg_log" + if not string.find(logdir, "^/") then + logdir = datadirectory.."/"..logdir + end + local logfile = getconfvalue("log_filename") or "postgresql-" + -- drop the escapes + logfile = string.match(logfile, "^[^%%]*") + local files = fs.find_files_as_array(format.escapemagiccharacters(logfile)..".*", logdir) + for i,f in ipairs(files) do + retval.value[#retval.value+1] = {filename=f} + end + end + + if #retval.value == 0 then + retval.value[#retval.value+1] = {facility="daemon", grep="postgres"} + end + + retval.value[#retval.value+1] = {filename=datadirectory.."/postmaster.log"} + + return retval +end + for n,f in pairs(dbmodelfunctions) do mymodule[n] = function(...) return f(determineconnection, ...) -- cgit v1.2.3