diff options
-rw-r--r-- | freeswitch-controller.lua | 4 | ||||
l---------[-rw-r--r--] | freeswitch-logfile-html.lsp | 7 | ||||
-rw-r--r-- | freeswitch-model.lua | 36 |
3 files changed, 41 insertions, 6 deletions
diff --git a/freeswitch-controller.lua b/freeswitch-controller.lua index baf1b35..a614cbf 100644 --- a/freeswitch-controller.lua +++ b/freeswitch-controller.lua @@ -30,4 +30,8 @@ function mymodule.reloadxml(self) return self.handle_form(self, self.model.getreloadxml, self.model.reload_xml, self.clientdata, "Reload", "Reload Freeswitch XML") end +function mymodule.logfile(self) + return self.model.get_logfile(self, self.clientdata) +end + return mymodule diff --git a/freeswitch-logfile-html.lsp b/freeswitch-logfile-html.lsp index 47e2b17..ac8854f 100644..120000 --- a/freeswitch-logfile-html.lsp +++ b/freeswitch-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/freeswitch/freeswitch.log"}) -end %> +../logfile-html.lsp
\ No newline at end of file diff --git a/freeswitch-model.lua b/freeswitch-model.lua index 4e2b140..d4bf837 100644 --- a/freeswitch-model.lua +++ b/freeswitch-model.lua @@ -6,11 +6,13 @@ posix = require("posix") fs = require("acf.fs") format = require("acf.format") validator = require("acf.validator") +xml = require("LuaXml") -- Set variables local processname = "freeswitch" local packagename = "freeswitch" local baseurl = "/etc/freeswitch" +local configfile = "/var/log/freeswitch/freeswitch.xml.fsxml" -- ################################################################################ -- LOCAL FUNCTIONS @@ -122,4 +124,38 @@ function mymodule.deletefile(self, delfile) return delfile end +function mymodule.get_logfile(self, clientdata) + local retval = cfe({ type="structure", value={}, label="Log File Configuration" }) + local config + local res, err = pcall(function() + config = xml.load(configfile) + end) + if not res and err then + retval.errtxt = err + config = xml.new() + end + + if (config:find("load", "module", "mod_logfile")) then + local logfileparam + local logfileconfig = config:find("configuration", "name", "logfile.conf") + -- There may be multiple profiles, but for now just use the first one found + if logfileconfig then + logfileparam = logfileconfig:find("param", "name", "logfile") + end + if logfileparam then + retval.value[#retval.value+1] = {filename=logfileparam.value} + else + retval.value[#retval.value+1] = {filename="/var/log/freeswitch/freeswitch.log"} + end + end + if (config:find("load", "module", "mod_syslog")) then + local syslog = config:find("configuration", "name", "syslog.conf") + local facility = syslog:find("param", "name", "facility") or {value="user"} + local ident = syslog:find("param", "name", "ident") or {value="freeswitch"} + retval.value[#retval.value+1] = {facility=facility.value, grep=ident.value} + end + + return retval +end + return mymodule |