diff options
author | Ted Trask <ttrask01@yahoo.com> | 2015-10-31 20:33:25 +0000 |
---|---|---|
committer | Ted Trask <ttrask01@yahoo.com> | 2015-10-31 20:33:25 +0000 |
commit | 8addabae08034da1f6e4ea6059148ecc1ea9d045 (patch) | |
tree | dadccbb6d52e563bd1797dcb5d9349fc9eff2ee6 | |
parent | 15f4736441fa4828f029e8052ef97d733422d7ae (diff) | |
download | acf-postgresql-8addabae08034da1f6e4ea6059148ecc1ea9d045.tar.bz2 acf-postgresql-8addabae08034da1f6e4ea6059148ecc1ea9d045.tar.xz |
Modify logfile to get logging info from the config and use common view
-rw-r--r-- | postgresql-controller.lua | 4 | ||||
l---------[-rw-r--r--] | postgresql-logfile-html.lsp | 7 | ||||
-rw-r--r-- | postgresql-model.lua | 30 |
3 files changed, 35 insertions, 6 deletions
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 index 0b81a65..ac8854f 100644..120000 --- a/postgresql-logfile-html.lsp +++ b/postgresql-logfile-html.lsp @@ -1,6 +1 @@ -<% local data, viewlibrary = ... -%> - -<% if viewlibrary and viewlibrary.dispatch_component then - viewlibrary.dispatch_component("alpine-baselayout/logfiles/view", {filename="/var/log/messages", grep="postgres"}) -end %> +../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, ...) |