From 691e007e535e384e3dc27f98c81cf247be14ba15 Mon Sep 17 00:00:00 2001
From: Victor Seva <linuxmaniac@torreviejawireless.org>
Date: Tue, 25 Jun 2013 14:09:06 +0200
Subject: [PATCH] modules/debugger: trace msg out

---
 modules/debugger/debugger_api.c |   16 ++++++++++++++++
 modules/debugger/debugger_api.h |    2 ++
 modules/debugger/debugger_mod.c |    3 +++
 3 files changed, 21 insertions(+)

--- a/modules/debugger/debugger_api.c
+++ b/modules/debugger/debugger_api.c
@@ -174,6 +174,8 @@
  */
 char *_dbg_cfgtrace_prefix = "*** cfgtrace:";
 
+int _dbg_outtrace = 0;
+
 /**
  *
  */
@@ -487,6 +489,20 @@
 	return 0;
 }
 
+int dbg_cfg_dump(void *data)
+{
+	str *buf = (str *) data;
+	if(buf==NULL) return 0;
+	LM_DBG("msg out:{%.*s}\n", buf->len, buf->s);
+	return 0;
+}
+
+void dbg_enable_outtrace(void)
+{
+	if(_dbg_outtrace==1)
+		sr_event_register_cb(SREV_NET_DATA_OUT, dbg_cfg_dump);
+}
+
 /**
  *
  */
--- a/modules/debugger/debugger_api.h
+++ b/modules/debugger/debugger_api.h
@@ -57,5 +57,6 @@
 #define DBG_DP_OTHER		16
 #define DBG_DP_ALL			31
 int dbg_dump_json(struct sip_msg* msg, unsigned int mask, int level);
+void dbg_enable_outtrace(void);
 #endif
 
--- a/modules/debugger/debugger_mod.c
+++ b/modules/debugger/debugger_mod.c
@@ -60,6 +60,7 @@
 extern char *_dbg_cfgtrace_prefix;
 extern int _dbg_step_usleep;
 extern int _dbg_step_loops;
+extern int _dbg_outtrace;
 extern int _dbg_reset_msgid;
 
 static char * _dbg_cfgtrace_facility_str = 0;
@@ -86,6 +87,7 @@
 	{"log_assign",        INT_PARAM, &_dbg_log_assign},
 	{"step_usleep",       INT_PARAM, &_dbg_step_usleep},
 	{"step_loops",        INT_PARAM, &_dbg_step_loops},
+	{"trace_out_msg",     INT_PARAM, &_dbg_outtrace},
 	{"mod_hash_size",     INT_PARAM, &default_dbg_cfg.mod_hash_size},
 	{"mod_level_mode",    INT_PARAM, &default_dbg_cfg.mod_level_mode},
 	{"mod_level",         STR_PARAM|USE_FUNC_PARAM, (void*)dbg_mod_level_param},
@@ -178,6 +180,7 @@
 	if (rank==PROC_INIT) {
 		dbg_enable_mod_levels();
 		dbg_enable_log_assign();
+		dbg_enable_outtrace();
 		return dbg_init_pid_list();
 	}
 	return dbg_init_mypid();
