summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-02-05 14:02:56 +0100
committerspag <spag@golwen.net>2013-02-05 14:02:56 +0100
commit11c0c5bb51d58a6d33848806a29a9a4e0d241cbd (patch)
tree20ea04bf13f56b25837db9da12634d982a3b9abb /misc
parentbcce809c6e628fb7c067437e98a5195c5e228532 (diff)
dump_variables event module added
Diffstat (limited to 'misc')
-rw-r--r--misc/freeswitch/scripts/event/dump_variables.lua52
1 files changed, 52 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/event/dump_variables.lua b/misc/freeswitch/scripts/event/dump_variables.lua
new file mode 100644
index 0000000..96eb8f7
--- /dev/null
+++ b/misc/freeswitch/scripts/event/dump_variables.lua
@@ -0,0 +1,52 @@
+-- Gemeinschaft 5 module: dump_variables event handler class
+-- (c) AMOOMA GmbH 2012-2013
+--
+
+module(...,package.seeall)
+
+
+function handler_class()
+ return DumpVariables
+end
+
+
+DumpVariables = {}
+
+
+function DumpVariables.new(self, arg)
+ arg = arg or {}
+ object = arg.object or {}
+ setmetatable(object, self);
+ self.__index = self;
+ self.log = arg.log;
+ self.class = 'DumpVariables'
+ self.dump_file = arg.file or '/var/log/freeswitch/variables';
+
+ return object;
+end
+
+
+function DumpVariables.event_handlers(self)
+ return { CHANNEL_CREATE = { [true] = self.channel_data } }
+end
+
+
+function DumpVariables.channel_data(self, event)
+ local sequence = event:getHeader('Event-Sequence');
+ local direction = event:getHeader('Call-Direction');
+
+ if not direction or direction ~= 'inbound' then
+ return;
+ end
+
+ local file = io.open(self.dump_file, 'w');
+ if not file then
+ self.log:error('[', event.sequence, '] DUMP_VARIABLES - could not open file for writing: ', self.dump_file);
+ return;
+ end
+
+ self.log:debug('[', event.sequence, '] DUMP_VARIABLES - dumping channel data to: ', self.dump_file);
+
+ file:write(event:serialize(), '\n');
+ file:close();
+end