diff options
author | Peter Kozak <spag@golwen.net> | 2013-03-13 13:42:09 -0400 |
---|---|---|
committer | Peter Kozak <spag@golwen.net> | 2013-03-13 13:42:09 -0400 |
commit | dc212986e401335fbd27216e029889f0cd941340 (patch) | |
tree | e849379c7c723d9f7c8ad8e56120d407273bfb2c /misc/freeswitch/scripts | |
parent | ea5289e7c3da5079414d088cb3844032a02ed369 (diff) |
log_details flag added
Diffstat (limited to 'misc/freeswitch/scripts')
-rw-r--r-- | misc/freeswitch/scripts/dialplan/router.lua | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/misc/freeswitch/scripts/dialplan/router.lua b/misc/freeswitch/scripts/dialplan/router.lua index 2d82f91..751d24f 100644 --- a/misc/freeswitch/scripts/dialplan/router.lua +++ b/misc/freeswitch/scripts/dialplan/router.lua @@ -20,6 +20,7 @@ function Router.new(self, arg) self.routes = arg.routes or {}; self.caller = arg.caller; self.variables = arg.variables or {}; + self.log_details = arg.log_details; self.routing_tables = {}; return object; end @@ -65,11 +66,19 @@ function Router.element_match(self, pattern, search_string, replacement, route_v local success, result = pcall(string.find, search_string, pattern); if not success then - self.log:error('ELEMENT_MATCH - table error - pattern: ', pattern, ', search_string: ', search_string); + self.log:error('ELEMENT_ERROR - table error - pattern: ', pattern, ', search_string: ', search_string); elseif result then - return true, search_string:gsub(pattern, common.array.expand_variables(replacement, route_variables, self.variables)); + local replace_by = common.array.expand_variables(replacement, route_variables, self.variables) + result = search_string:gsub(pattern, replace_by); + if self.log_details then + self.log:debug('ELEMENT_MATCH - ', search_string, ' ~= ', pattern, ' => ', replacement, ' => ', replace_by); + end + return true, result; end + if self.log_details then + self.log:debug('ELEMENT_NO_MATCH - ', search_string, ' != ', pattern); + end return false; end @@ -109,6 +118,10 @@ function Router.route_match(self, route) local element = route.elements[index]; + if self.log_details then + self.log:debug('ROUTE_ELEMENT ', element.id, ' - var_in: ', element.var_in, ', var_out: ', element.var_out, ', action: ', element.action, ', mandatory: ', element.mandatory); + end + if element.action ~= 'none' then if common.str.blank(element.var_in) or common.str.blank(element.pattern) and element.action == 'set' then result = true; |