<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/14801">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">scope_trace: Updated macro stubs to match other branches<br><br>Although scope tracing isn't actually implemented in this branch,<br>macro stubs had been added to allow code that used scope tracing<br>to be cherry-picked to this branch without modification.<br><br>To match the other branches, the following changes were made<br>to the stubs...<br><br>The SCOPE_ENTER and SCOPE_EXIT* macros now print debug messages<br>at the same level as the scope level. This allows the same<br>messages to be printed to the debug log when AST_DEVMODE<br>isn't enabled.<br><br>Also added a few variants of the SCOPE_EXIT macros that will<br>also call ast_log instead of ast_debug to make it easier to<br>use scope tracing and still print error messages.<br><br>Change-Id: Ifc281793a5b91c84a4f1633db9d07006d31585ed<br>---<br>M include/asterisk/logger.h<br>1 file changed, 70 insertions(+), 11 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/01/14801/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h</span><br><span>index f3cefd3..42348cb 100644</span><br><span>--- a/include/asterisk/logger.h</span><br><span>+++ b/include/asterisk/logger.h</span><br><span>@@ -599,24 +599,83 @@</span><br><span> };</span><br><span> </span><br><span> /*</span><br><span style="color: hsl(0, 100%, 40%);">- * The "#if 1" keeps the last few lines of scope tracing</span><br><span style="color: hsl(120, 100%, 40%);">+ * The "#if 0" keeps the last few lines of scope tracing</span><br><span> * common to all branches.</span><br><span> */</span><br><span style="color: hsl(0, 100%, 40%);">-#if 1</span><br><span style="color: hsl(0, 100%, 40%);">-#define ast_trace_raw(__level, __indent_type, ...)</span><br><span style="color: hsl(0, 100%, 40%);">-#define ast_trace(__level, ...)</span><br><span style="color: hsl(120, 100%, 40%);">+#if 0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#else /* AST_DEVMODE */</span><br><span style="color: hsl(120, 100%, 40%);">+#define ast_trace_raw(level, indent_type, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define ast_trace(level, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #define ast_trace_get_indent() (0)</span><br><span> #define ast_trace_set_indent(indent)</span><br><span> #define ast_trace_inc_indent()</span><br><span> #define ast_trace_dec_indent()</span><br><span> #define SCOPE_TRACE(__level, ...)</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPE_ENTER(level, ...)</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPE_ENTER_TASK(level, indent, ...)</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPE_EXIT(...)</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPE_EXIT_EXPR(__expr, ...) __expr</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPE_EXIT_RTN(...) return</span><br><span style="color: hsl(0, 100%, 40%);">-#define SCOPE_EXIT_RTN_VALUE(__return_value, ...) return __return_value</span><br><span style="color: hsl(0, 100%, 40%);">-#endif</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_ENTER(level, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ int __scope_level = level; \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(level, " " __VA_ARGS__)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_ENTER_TASK(level, indent, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ int __scope_level = level; \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(level, " " __VA_ARGS__)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT(...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(__scope_level, " " __VA_ARGS__)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT_EXPR(__expr, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(__scope_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ __expr</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT_RTN(...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(__scope_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ return</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT_RTN_VALUE(__return_value, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_debug(__scope_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ return __return_value</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif /* AST_DEVMODE */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * The following macros will print log messages before running</span><br><span style="color: hsl(120, 100%, 40%);">+ * the associated SCOPE_ macro.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT_LOG(__log_level, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+({ \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(__log_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ SCOPE_EXIT(" " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+})</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT_LOG_RTN(__log_level, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+({ \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(__log_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ SCOPE_EXIT_RTN(" " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+})</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+({ \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(__log_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ SCOPE_EXIT_RTN_VALUE(__value, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+})</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define SCOPE_EXIT_LOG_EXPR(__expr, __log_level, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+({ \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(__log_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ SCOPE_EXIT_EXPR(__expr, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+})</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define ast_trace_log(__level, __log_level, ...) \</span><br><span style="color: hsl(120, 100%, 40%);">+({ \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_log(__log_level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+ ast_trace(__level < 0 ? __scope_level : __level, " " __VA_ARGS__); \</span><br><span style="color: hsl(120, 100%, 40%);">+})</span><br><span> </span><br><span> #if defined(__cplusplus) || defined(c_plusplus)</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/14801">change 14801</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/14801"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-Change-Id: Ifc281793a5b91c84a4f1633db9d07006d31585ed </div>
<div style="display:none"> Gerrit-Change-Number: 14801 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>