int sent_ring = 0;
int sent_progress = 0;
struct timeval start = ast_tvnow();
- SCOPE_TRACE(1, "%s\n", ast_channel_name(in));
+ SCOPE_ENTER(3, "%s\n", ast_channel_name(in));
if (single) {
/* Turn off hold music, etc */
*to = -1;
strcpy(pa->status, "CONGESTION");
ast_channel_publish_dial(in, outgoing->chan, NULL, pa->status);
- return NULL;
+ SCOPE_EXIT_RTN_VALUE(NULL, "%s: can't be made compat with %s\n",
+ ast_channel_name(in), ast_channel_name(outgoing->chan));
}
}
if (is_cc_recall) {
ast_cc_failed(cc_recall_core_id, "Everyone is busy/congested for the recall. How sad");
}
- return NULL;
+ SCOPE_EXIT_RTN_VALUE(NULL, "%s: No outging channels available\n", ast_channel_name(in));
}
winner = ast_waitfor_n(watchers, pos, to);
AST_LIST_TRAVERSE(out_chans, o, node) {
case AST_CONTROL_ANSWER:
/* This is our guy if someone answered. */
if (!peer) {
- ast_trace(1, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
+ ast_trace(-1, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
ast_verb(3, "%s answered %s\n", ast_channel_name(c), ast_channel_name(in));
if (o->orig_chan_name
&& strcmp(o->orig_chan_name, ast_channel_name(c))) {
* from being cleaned up when the frame is cleaned up.
*/
config->answer_topology = ao2_bump(f->subclass.topology);
- ast_trace(2, "%s Found topology in frame: %p %p %s\n",
+ ast_trace(-1, "%s Found topology in frame: %p %p %s\n",
ast_channel_name(peer), f, config->answer_topology,
ast_str_tmp(256, ast_stream_topology_to_str(config->answer_topology, &STR_TMP)));
}
if (is_cc_recall) {
ast_cc_completed(in, "CC completed, although the caller hung up (cancelled)");
}
- return NULL;
+ SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller hung up\n", ast_channel_name(in));
}
/* now f is guaranteed non-NULL */
if (is_cc_recall) {
ast_cc_completed(in, "CC completed, but the caller used DTMF to exit");
}
- return NULL;
+ SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller pressed %c to end call\n",
+ ast_channel_name(in), f->subclass.integer);
}
ast_channel_unlock(in);
}
if (is_cc_recall) {
ast_cc_completed(in, "CC completed, but the caller hung up with DTMF");
}
- return NULL;
+ SCOPE_EXIT_RTN_VALUE(NULL, "%s: Caller requested disconnect\n",
+ ast_channel_name(in));
}
}
if (is_cc_recall) {
ast_cc_completed(in, "Recall completed!");
}
- return peer;
+ SCOPE_EXIT_RTN_VALUE(peer, "%s: %s%s\n", ast_channel_name(in),
+ peer ? "Answered by " : "No answer", peer ? ast_channel_name(peer) : "");
}
static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode)
*/
struct ast_party_caller caller;
int max_forwards;
- SCOPE_TRACE(1, "%s Data: %s\n", ast_channel_name(chan), data);
+ SCOPE_ENTER(1, "%s: Data: %s\n", ast_channel_name(chan), data);
/* Reset all DIAL variables back to blank, to prevent confusion (in case we don't reset all of them). */
ast_channel_lock(chan);
ast_log(LOG_WARNING, "Cannot place outbound call from channel '%s'. Max forwards exceeded\n",
ast_channel_name(chan));
pbx_builtin_setvar_helper(chan, "DIALSTATUS", "BUSY");
- return -1;
+ SCOPE_EXIT_RTN_VALUE(-1, "%s: Max forwards exceeded\n", ast_channel_name(chan));
}
if (ast_check_hangup_locked(chan)) {
*/
ast_verb(3, "Caller hung up before dial.\n");
pbx_builtin_setvar_helper(chan, "DIALSTATUS", "CANCEL");
- return -1;
+ SCOPE_EXIT_RTN_VALUE(-1, "%s: Caller hung up before dial\n", ast_channel_name(chan));
}
parse = ast_strdupa(data ?: "");
ast_free((char *)config.start_sound);
}
ast_ignore_cc(chan);
- return res;
+ SCOPE_EXIT_RTN_VALUE(res, "%s: Done\n", ast_channel_name(chan));
}
static int dial_exec(struct ast_channel *chan, const char *data)
*
*/
#define ast_trace_raw(level, indent_type, ...) \
+ ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(level)) { \
__ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, indent_type, 0, " " __VA_ARGS__); \
}
* This will print the file, line and function at the current indent level
*/
#define ast_trace(level, ...) \
+ ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__); \
if (TRACE_ATLEAST(level)) { \
__ast_trace(__FILE__, __LINE__, __PRETTY_FUNCTION__, AST_TRACE_INDENT_SAME, 0, " " __VA_ARGS__); \
}
#define SCOPE_ENTER(level, ...) \
int __scope_level = level; \
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__); \
} \
#define SCOPE_ENTER_TASK(level, indent, ...) \
int __scope_level = level; \
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__); \
} \
* This macro can be used at the exit points of a statement block since it just prints the message.
*/
#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__); \
if (__scope_task) { \
* }
*/
#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__); \
if (__scope_task) { \
* needs to be returned.
*/
#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__); \
if (__scope_task) { \
* needs to be returned.
*/
#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__); \
if (__scope_task) { \
} \
return(__return_value)
-#else
-#define ast_trace_raw(__level, __indent_type, ...)
-#define ast_trace(__level, ...)
+#else /* AST_DEVMODE */
+#define ast_trace_raw(level, indent_type, ...) \
+ ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)
+
+#define ast_trace(level, ...) \
+ ast_debug(level < 0 ? __scope_level : level, " " __VA_ARGS__)
+
#define ast_trace_get_indent() (0)
#define ast_trace_set_indent(indent)
#define ast_trace_inc_indent()
#define ast_trace_dec_indent()
#define SCOPE_TRACE(__level, ...)
-#define SCOPE_ENTER(level, ...)
-#define SCOPE_ENTER_TASK(level, indent, ...)
-#define SCOPE_EXIT(...)
-#define SCOPE_EXIT_EXPR(__expr, ...) __expr
-#define SCOPE_EXIT_RTN(...) return
-#define SCOPE_EXIT_RTN_VALUE(__return_value, ...) return __return_value
-#endif
+
+#define SCOPE_ENTER(level, ...) \
+ int __scope_level = level; \
+ ast_debug(level, " " __VA_ARGS__)
+
+#define SCOPE_ENTER_TASK(level, indent, ...) \
+ int __scope_level = level; \
+ ast_debug(level, " " __VA_ARGS__)
+
+#define SCOPE_EXIT(...) \
+ ast_debug(__scope_level, " " __VA_ARGS__)
+
+#define SCOPE_EXIT_EXPR(__expr, ...) \
+ ast_debug(__scope_level, " " __VA_ARGS__); \
+ __expr
+
+#define SCOPE_EXIT_RTN(...) \
+ ast_debug(__scope_level, " " __VA_ARGS__); \
+ return
+
+#define SCOPE_EXIT_RTN_VALUE(__return_value, ...) \
+ ast_debug(__scope_level, " " __VA_ARGS__); \
+ return __return_value
+
+#endif /* AST_DEVMODE */
+
+/*!
+ * The following macros will print log messages before running
+ * the associated SCOPE_ macro.
+ */
+
+#define SCOPE_EXIT_LOG(__log_level, ...) \
+({ \
+ ast_log(__log_level, " " __VA_ARGS__); \
+ SCOPE_EXIT(" " __VA_ARGS__); \
+})
+
+#define SCOPE_EXIT_LOG_RTN(__log_level, ...) \
+({ \
+ ast_log(__log_level, " " __VA_ARGS__); \
+ SCOPE_EXIT_RTN(" " __VA_ARGS__); \
+})
+
+#define SCOPE_EXIT_LOG_RTN_VALUE(__value, __log_level, ...) \
+({ \
+ ast_log(__log_level, " " __VA_ARGS__); \
+ SCOPE_EXIT_RTN_VALUE(__value, " " __VA_ARGS__); \
+})
+
+#define SCOPE_EXIT_LOG_EXPR(__expr, __log_level, ...) \
+({ \
+ ast_log(__log_level, " " __VA_ARGS__); \
+ SCOPE_EXIT_EXPR(__expr, " " __VA_ARGS__); \
+})
+
+#define ast_trace_log(__level, __log_level, ...) \
+({ \
+ ast_log(__log_level, " " __VA_ARGS__); \
+ ast_trace(__level < 0 ? __scope_level : __level, " " __VA_ARGS__); \
+})
+
#if defined(__cplusplus) || defined(c_plusplus)
}