[Asterisk-code-review] logger: use __FUNCTION__ instead of __PRETTY_FUNCTION__ (asterisk[19])
Jaco Kroon
asteriskteam at digium.com
Mon Nov 22 01:12:49 CST 2021
Jaco Kroon has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/17573 )
Change subject: logger: use __FUNCTION__ instead of __PRETTY_FUNCTION__
......................................................................
logger: use __FUNCTION__ instead of __PRETTY_FUNCTION__
This avoids a few long-name overflows, at the cost of less instructive
names in the case of C++ (specifically overloaded functions and class
methods). This in turn is offset against the fact that we're logging
the filename and line numbers in any case.
Change-Id: I54101a0bb5f8cb9ef63ec12c5e0d4c8edafff9ed
Signed-off-by: Jaco Kroon <jaco at uls.co.za>
---
M include/asterisk/logger.h
1 file changed, 15 insertions(+), 15 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/73/17573/1
diff --git a/include/asterisk/logger.h b/include/asterisk/logger.h
index 08e90bb..270b5d3 100644
--- a/include/asterisk/logger.h
+++ b/include/asterisk/logger.h
@@ -39,6 +39,8 @@
a; \
}
+#define _A_ __FILE__, __LINE__, __FUNCTION__
+
#define VERBOSE_PREFIX_1 " "
#define VERBOSE_PREFIX_2 " == "
#define VERBOSE_PREFIX_3 " -- "
@@ -175,8 +177,8 @@
*/
void __attribute__((format(printf, 6, 7))) __ast_verbose_callid(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, ...);
-#define ast_verbose(...) __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, __VA_ARGS__)
-#define ast_verbose_callid(callid, ...) __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, -1, callid, __VA_ARGS__)
+#define ast_verbose(...) __ast_verbose(_A_, -1, __VA_ARGS__)
+#define ast_verbose_callid(callid, ...) __ast_verbose_callid(_A_, -1, callid, __VA_ARGS__)
void __attribute__((format(printf, 6, 0))) __ast_verbose_ap(const char *file, int line, const char *func, int level, ast_callid callid, const char *fmt, va_list ap);
@@ -233,8 +235,6 @@
* needed for third-party modules
*/
-#define _A_ __FILE__, __LINE__, __PRETTY_FUNCTION__
-
#ifdef LOG_DEBUG
#undef LOG_DEBUG
#endif
@@ -437,7 +437,7 @@
* \since 1.8
*/
-#define ast_log_dynamic_level(level, ...) ast_log(level, __FILE__, __LINE__, __PRETTY_FUNCTION__, __VA_ARGS__)
+#define ast_log_dynamic_level(level, ...) ast_log(level, _A_, __VA_ARGS__)
#define DEBUG_ATLEAST(level) \
(option_debug >= (level) \
@@ -464,14 +464,14 @@
#define ast_verb(level, ...) \
do { \
if (VERBOSITY_ATLEAST(level) ) { \
- __ast_verbose(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, __VA_ARGS__); \
+ __ast_verbose(_A_, level, __VA_ARGS__); \
} \
} while (0)
#define ast_verb_callid(level, callid, ...) \
do { \
if (VERBOSITY_ATLEAST(level) ) { \
- __ast_verbose_callid(__FILE__, __LINE__, __PRETTY_FUNCTION__, level, callid, __VA_ARGS__); \
+ __ast_verbose_callid(_A_, level, callid, __VA_ARGS__); \
} \
} while (0)
@@ -678,7 +678,7 @@
#define ast_trace_raw(level, indent_type, ...) \
ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(level < 0 ? __scope_level : level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, indent_type, 0, " " __VA_ARGS__); \
+ __ast_trace(_A_, indent_type, 0, " " __VA_ARGS__); \
}
/*!
@@ -693,7 +693,7 @@
#define ast_trace(level, ...) \
ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(level < 0 ? __scope_level : level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_SAME, 0, " " __VA_ARGS__); \
+ __ast_trace(_A_, AST_TRACE_INDENT_SAME, 0, " " __VA_ARGS__); \
}
/*!
@@ -783,7 +783,7 @@
int __scope_task = 0; \
ast_debug(__scope_level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_INC_AFTER, 0, " " __VA_ARGS__); \
+ __ast_trace(_A_, AST_TRACE_INDENT_INC_AFTER, 0, " " __VA_ARGS__); \
} \
#define SCOPE_ENTER_TASK(level, indent, ...) \
@@ -791,7 +791,7 @@
int __scope_task = 1; \
ast_debug(__scope_level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_PROVIDED, indent, " " __VA_ARGS__); \
+ __ast_trace(_A_, AST_TRACE_INDENT_PROVIDED, indent, " " __VA_ARGS__); \
} \
/*!
@@ -806,7 +806,7 @@
#define SCOPE_EXIT(...) \
ast_debug(__scope_level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(__scope_level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
+ __ast_trace(_A_, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
if (__scope_task) { \
_ast_trace_set_indent(0); \
} \
@@ -836,7 +836,7 @@
#define SCOPE_EXIT_EXPR(__expr, ...) \
ast_debug(__scope_level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(__scope_level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
+ __ast_trace(_A_, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
if (__scope_task) { \
_ast_trace_set_indent(0); \
} \
@@ -856,7 +856,7 @@
#define SCOPE_EXIT_RTN(...) \
ast_debug(__scope_level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(__scope_level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
+ __ast_trace(_A_, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
if (__scope_task) { \
_ast_trace_set_indent(0); \
} \
@@ -877,7 +877,7 @@
#define SCOPE_EXIT_RTN_VALUE(__return_value, ...) \
ast_debug(__scope_level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(__scope_level)) { \
- __ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
+ __ast_trace(_A_, AST_TRACE_INDENT_DEC_BEFORE, 0, " " __VA_ARGS__); \
if (__scope_task) { \
_ast_trace_set_indent(0); \
} \
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/17573
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 19
Gerrit-Change-Id: I54101a0bb5f8cb9ef63ec12c5e0d4c8edafff9ed
Gerrit-Change-Number: 17573
Gerrit-PatchSet: 1
Gerrit-Owner: Jaco Kroon <jaco at uls.co.za>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20211122/981bd827/attachment-0001.html>
More information about the asterisk-code-review
mailing list