[Asterisk-code-review] logger: Bring back ability to turn debug on by source file (asterisk[15])

George Joseph asteriskteam at digium.com
Wed Sep 27 13:51:14 CDT 2017


George Joseph has uploaded this change for review. ( https://gerrit.asterisk.org/6620


Change subject: logger:  Bring back ability to  turn debug on by source file
......................................................................

logger:  Bring back ability to  turn debug on by source file

Somewhere along the way we lost the ability to debug individual
source files.  For modules, this wasn't a big deal but all the
source files in ./main are in the one "core" module so debugging
individual core capabilities was almost impossible.

* Added a new function "ast_debug_get_by_file" to logger.h/cli.c
which gets the debug level for a specific sourfe file.  You can now
do a "core set debug 3 bridge_channel.c" for instance, and only turn
debugging on for that since source file.  This isn't limited to
source files in ./main.  Any source file works so you could also do
"core set debug 3 pjsip_message_filter.c".

Change-Id: Icc0af41837f3b1679dec7af21fa32cd1f7469f6e
---
M include/asterisk/logger.h
M main/cli.c
2 files changed, 29 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/20/6620/1

diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 849f986..88b934f 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -310,6 +310,16 @@
 unsigned int ast_debug_get_by_module(const char *module);
 
 /*!
+ * \brief Get the debug level for a source file
+ * \since 13.18.0
+ * \since 14.7.0
+ * \since 15.1.0
+ * \param file the name of source file
+ * \return the debug level
+ */
+unsigned int ast_debug_get_by_file(const char *file);
+
+/*!
  * \brief Get the verbose level for a module
  * \param module the name of module
  * \return the verbose level
@@ -429,7 +439,8 @@
 
 #define DEBUG_ATLEAST(level) \
 	(option_debug >= (level) \
-		|| (ast_opt_dbg_module && (int)ast_debug_get_by_module(AST_MODULE) >= (level)))
+		|| (ast_opt_dbg_module && ((int)ast_debug_get_by_module(AST_MODULE) >= (level) \
+		|| (int)ast_debug_get_by_file(__FILE__) >= (level))))
 
 /*!
  * \brief Log a DEBUG message
diff --git a/main/cli.c b/main/cli.c
index ef86e25..f11ef7d 100644
--- a/main/cli.c
+++ b/main/cli.c
@@ -149,6 +149,23 @@
 	return res;
 }
 
+unsigned int ast_debug_get_by_file(const char *file)
+{
+	struct module_level *ml;
+	unsigned int res = 0;
+
+	AST_RWLIST_RDLOCK(&debug_modules);
+	AST_LIST_TRAVERSE(&debug_modules, ml, entry) {
+		if (!strcasecmp(ml->module, file)) {
+			res = ml->level;
+			break;
+		}
+	}
+	AST_RWLIST_UNLOCK(&debug_modules);
+
+	return res;
+}
+
 unsigned int ast_verbose_get_by_module(const char *module)
 {
 	return 0;

-- 
To view, visit https://gerrit.asterisk.org/6620
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc0af41837f3b1679dec7af21fa32cd1f7469f6e
Gerrit-Change-Number: 6620
Gerrit-PatchSet: 1
Gerrit-Owner: George Joseph <gjoseph at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20170927/d477718a/attachment-0001.html>


More information about the asterisk-code-review mailing list