]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Scope Tracing: Add stubs to allow easier cherry-picking
authorGeorge Joseph <gjoseph@digium.com>
Thu, 21 May 2020 13:20:28 +0000 (07:20 -0600)
committerJoshua Colp <jcolp@sangoma.com>
Wed, 3 Jun 2020 09:00:39 +0000 (04:00 -0500)
Scope tracing isn't supported in Asterisk 13 due to changes made
to logging between 13 and 16 but since the scope tracing macros
may be present in the 16, 17 and master branches, those macros
are defined here as NOOPs so cherry-picking changes downward
to 13 can still be seamless.

Change-Id: I0390ce5651374d8f3e06d7620050acb22c5440a2

include/asterisk/logger.h

index e19ba942ff44f9c174c8a6c10dc61f17e1be8467..ada04ab1a878f28c2c62c2cabe338c1ac062a5ce 100644 (file)
@@ -26,6 +26,7 @@
 #define _ASTERISK_LOGGER_H
 
 #include "asterisk/options.h"  /* need option_debug */
+#include "asterisk/inline_api.h"
 
 #if defined(__cplusplus) || defined(c_plusplus)
 extern "C" {
@@ -231,6 +232,17 @@ void ast_console_toggle_loglevel(int fd, int level, int state);
 #endif
 #define AST_LOG_DEBUG      __LOG_DEBUG, _A_
 
+#ifdef LOG_TRACE
+#undef LOG_TRACE
+#endif
+#define __LOG_TRACE   1
+#define LOG_TRACE     __LOG_TRACE, _A_
+
+#ifdef AST_LOG_TRACE
+#undef AST_LOG_TRACE
+#endif
+#define AST_LOG_TRACE     __LOG_TRACE, _A_
+
 #ifdef LOG_NOTICE
 #undef LOG_NOTICE
 #endif
@@ -543,6 +555,59 @@ void ast_logger_set_queue_limit(int queue_limit);
  */
 int ast_logger_get_queue_limit(void);
 
+/*!
+ \page Scope_Trace Scope Trace
+
+Scope tracing is not available in this version of Asterisk.
+The declatrations and stubs below are there to facilitate
+cherry-picking from branches where it is available.
+
+ */
+
+/*!
+ * \brief Get the trace level for a module
+ * \param module the name of module
+ * \return the trace level
+ */
+AST_INLINE_API(
+unsigned int ast_trace_get_by_module(const char *module),
+{
+       return 0;
+}
+)
+
+#define TRACE_ATLEAST(level) (0)
+
+/*!
+ * \brief Controls if and when indenting is applied.
+ */
+enum ast_trace_indent_type {
+       /*! Use the existing indent level */
+       AST_TRACE_INDENT_SAME = 0,
+       /*! Increment the indent before printing the message */
+       AST_TRACE_INDENT_INC_BEFORE,
+       /*! Increment the indent after printing the message */
+       AST_TRACE_INDENT_INC_AFTER,
+       /*! Decrement the indent before printing the message */
+       AST_TRACE_INDENT_DEC_BEFORE,
+       /*! Decrement the indent after printing the message */
+       AST_TRACE_INDENT_DEC_AFTER,
+       /*! Don't use or alter the level */
+       AST_TRACE_INDENT_NONE,
+};
+
+/*
+ * The "#if 1" keeps the last few lines of scope tracing
+ * common to all branches.
+ */
+#if 1
+#define ast_trace(__level)
+#define ast_trace_raw(__level, __indent_type, __fmt, ...)
+#define ast_trace_msg(__level, __indent_type, __fmt, ...)
+#define SCOPE_TRACE_MSG(__debug_level, __fmt, ...)
+#define SCOPE_TRACE(__level)
+#endif
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif