diff options
Diffstat (limited to 'freeswitch-model.lua')
-rw-r--r-- | freeswitch-model.lua | 36 |
1 files changed, 36 insertions, 0 deletions
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 |