[mod_spandsp] Add verbose-log-level configuration.

This commit is contained in:
Chris Rienzo 2020-07-30 21:54:56 +00:00 committed by Andrey Volk
parent 31fdf1b746
commit cd041b768c
5 changed files with 55 additions and 10 deletions

View File

@ -28,6 +28,7 @@
<fax-settings> <fax-settings>
<param name="use-ecm" value="true"/> <param name="use-ecm" value="true"/>
<param name="verbose" value="false"/> <param name="verbose" value="false"/>
<!--param name="verbose-log-level" value="INFO"/-->
<param name="disable-v17" value="false"/> <param name="disable-v17" value="false"/>
<param name="ident" value="SpanDSP Fax Ident"/> <param name="ident" value="SpanDSP Fax Ident"/>
<param name="header" value="SpanDSP Fax Header"/> <param name="header" value="SpanDSP Fax Header"/>

View File

@ -516,6 +516,7 @@ switch_status_t load_configuration(switch_bool_t reload)
spandsp_globals.enable_tep = 0; spandsp_globals.enable_tep = 0;
spandsp_globals.total_sessions = 0; spandsp_globals.total_sessions = 0;
spandsp_globals.verbose = 0; spandsp_globals.verbose = 0;
spandsp_globals.verbose_log_level = SWITCH_LOG_DEBUG;
spandsp_globals.use_ecm = 1; spandsp_globals.use_ecm = 1;
spandsp_globals.disable_v17 = 0; spandsp_globals.disable_v17 = 0;
spandsp_globals.prepend_string = switch_core_strdup(spandsp_globals.config_pool, "fax"); spandsp_globals.prepend_string = switch_core_strdup(spandsp_globals.config_pool, "fax");
@ -591,6 +592,11 @@ switch_status_t load_configuration(switch_bool_t reload)
spandsp_globals.verbose = 1; spandsp_globals.verbose = 1;
else else
spandsp_globals.verbose = 0; spandsp_globals.verbose = 0;
} else if (!strcmp(name, "verbose-log-level")) {
switch_log_level_t verbose_log_level = switch_log_str2level(value);
if (verbose_log_level != SWITCH_LOG_INVALID) {
spandsp_globals.verbose_log_level = verbose_log_level;
}
} else if (!strcmp(name, "disable-v17")) { } else if (!strcmp(name, "disable-v17")) {
if (switch_true(value)) if (switch_true(value))
spandsp_globals.disable_v17 = 1; spandsp_globals.disable_v17 = 1;

View File

@ -70,6 +70,7 @@ struct spandsp_globals {
short int use_ecm; short int use_ecm;
short int verbose; short int verbose;
switch_log_level_t verbose_log_level;
short int disable_v17; short int disable_v17;
short int enable_tep; short int enable_tep;
short int enable_colour_fax; short int enable_colour_fax;
@ -106,6 +107,12 @@ typedef enum {
FUNCTION_GW FUNCTION_GW
} mod_spandsp_fax_application_mode_t; } mod_spandsp_fax_application_mode_t;
struct mod_spandsp_log_data {
switch_log_level_t verbose_log_level;
switch_core_session_t *session;
};
typedef struct mod_spandsp_log_data mod_spandsp_log_data_t;
/****************************************************************************** /******************************************************************************
* TONE DETECTION WITH CADENCE * TONE DETECTION WITH CADENCE
*/ */

View File

@ -406,7 +406,12 @@ static switch_bool_t inband_dtmf_callback(switch_media_bug_t *bug, void *user_da
switch (type) { switch (type) {
case SWITCH_ABC_TYPE_INIT: { case SWITCH_ABC_TYPE_INIT: {
pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL); pvt->dtmf_detect = dtmf_rx_init(NULL, NULL, NULL);
span_log_set_message_handler(dtmf_rx_get_logging_state(pvt->dtmf_detect), mod_spandsp_log_message, pvt->session); {
mod_spandsp_log_data_t *log_data = switch_core_session_alloc(pvt->session, sizeof(*log_data));
log_data->session = pvt->session;
log_data->verbose_log_level = spandsp_globals.verbose_log_level;
span_log_set_message_handler(dtmf_rx_get_logging_state(pvt->dtmf_detect), mod_spandsp_log_message, log_data);
}
if (pvt->verbose) { if (pvt->verbose) {
span_log_set_level(dtmf_rx_get_logging_state(pvt->dtmf_detect), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(dtmf_rx_get_logging_state(pvt->dtmf_detect), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
} }

View File

@ -106,6 +106,7 @@ struct pvt_s {
int enable_colour_to_bilevel; int enable_colour_to_bilevel;
int enable_grayscale_to_bilevel; int enable_grayscale_to_bilevel;
int verbose; int verbose;
switch_log_level_t verbose_log_level;
int caller; int caller;
int tx_page_start; int tx_page_start;
@ -273,7 +274,9 @@ static void counter_increment(void)
void mod_spandsp_log_message(void *user_data, int level, const char *msg) void mod_spandsp_log_message(void *user_data, int level, const char *msg)
{ {
int fs_log_level; int fs_log_level;
switch_core_session_t *session = (switch_core_session_t *)user_data; mod_spandsp_log_data_t *log_data = (mod_spandsp_log_data_t *)user_data;
switch_core_session_t *session = log_data ? log_data->session : NULL;
switch_log_level_t verbose_log_level = log_data ? log_data->verbose_log_level : spandsp_globals.verbose_log_level;
switch (level) { switch (level) {
case SPAN_LOG_NONE: case SPAN_LOG_NONE:
@ -290,7 +293,7 @@ void mod_spandsp_log_message(void *user_data, int level, const char *msg)
case SPAN_LOG_FLOW_2: case SPAN_LOG_FLOW_2:
case SPAN_LOG_FLOW_3: case SPAN_LOG_FLOW_3:
default: /* SPAN_LOG_DEBUG, SPAN_LOG_DEBUG_2, SPAN_LOG_DEBUG_3 */ default: /* SPAN_LOG_DEBUG, SPAN_LOG_DEBUG_2, SPAN_LOG_DEBUG_3 */
fs_log_level = SWITCH_LOG_DEBUG; fs_log_level = verbose_log_level;
break; break;
} }
@ -811,8 +814,13 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
fax_set_transmit_on_idle(fax, TRUE); fax_set_transmit_on_idle(fax, TRUE);
span_log_set_message_handler(fax_get_logging_state(fax), mod_spandsp_log_message, pvt->session); {
span_log_set_message_handler(t30_get_logging_state(t30), mod_spandsp_log_message, pvt->session); mod_spandsp_log_data_t *log_data = switch_core_session_alloc(pvt->session, sizeof(*log_data));
log_data->session = pvt->session;
log_data->verbose_log_level = pvt->verbose_log_level;
span_log_set_message_handler(fax_get_logging_state(fax), mod_spandsp_log_message, log_data);
span_log_set_message_handler(t30_get_logging_state(t30), mod_spandsp_log_message, log_data);
}
if (pvt->verbose) { if (pvt->verbose) {
span_log_set_level(fax_get_logging_state(fax), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(fax_get_logging_state(fax), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
@ -865,8 +873,13 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE; msg.message_id = SWITCH_MESSAGE_INDICATE_UDPTL_MODE;
switch_core_session_receive_message(pvt->session, &msg); switch_core_session_receive_message(pvt->session, &msg);
span_log_set_message_handler(t38_terminal_get_logging_state(t38), mod_spandsp_log_message, pvt->session); {
span_log_set_message_handler(t30_get_logging_state(t30), mod_spandsp_log_message, pvt->session); mod_spandsp_log_data_t *log_data = switch_core_session_alloc(pvt->session, sizeof(*log_data));
log_data->session = pvt->session;
log_data->verbose_log_level = pvt->verbose_log_level;
span_log_set_message_handler(t38_terminal_get_logging_state(t38), mod_spandsp_log_message, log_data);
span_log_set_message_handler(t30_get_logging_state(t30), mod_spandsp_log_message, log_data);
}
if (pvt->verbose) { if (pvt->verbose) {
span_log_set_level(t38_terminal_get_logging_state(t38), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(t38_terminal_get_logging_state(t38), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
@ -922,8 +935,13 @@ static switch_status_t spanfax_init(pvt_t *pvt, transport_mode_t trans_mode)
t38_gateway_set_ecm_capability(pvt->t38_gateway_state, pvt->use_ecm); t38_gateway_set_ecm_capability(pvt->t38_gateway_state, pvt->use_ecm);
switch_channel_set_variable(channel, "fax_ecm_requested", pvt->use_ecm ? "true" : "false"); switch_channel_set_variable(channel, "fax_ecm_requested", pvt->use_ecm ? "true" : "false");
span_log_set_message_handler(t38_gateway_get_logging_state(pvt->t38_gateway_state), mod_spandsp_log_message, pvt->session); {
span_log_set_message_handler(t38_core_get_logging_state(pvt->t38_core), mod_spandsp_log_message, pvt->session); mod_spandsp_log_data_t *log_data = switch_core_session_alloc(pvt->session, sizeof(*log_data));
log_data->session = pvt->session;
log_data->verbose_log_level = pvt->verbose_log_level;
span_log_set_message_handler(t38_gateway_get_logging_state(pvt->t38_gateway_state), mod_spandsp_log_message, log_data);
span_log_set_message_handler(t38_core_get_logging_state(pvt->t38_core), mod_spandsp_log_message, log_data);
}
if (pvt->verbose) { if (pvt->verbose) {
span_log_set_level(t38_gateway_get_logging_state(pvt->t38_gateway_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW); span_log_set_level(t38_gateway_get_logging_state(pvt->t38_gateway_state), SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW);
@ -1377,6 +1395,14 @@ static pvt_t *pvt_init(switch_core_session_t *session, mod_spandsp_fax_applicati
pvt->verbose = spandsp_globals.verbose; pvt->verbose = spandsp_globals.verbose;
} }
pvt->verbose_log_level = spandsp_globals.verbose_log_level;
if ((tmp = switch_channel_get_variable(channel, "fax_verbose_log_level"))) {
switch_log_level_t verbose_log_level = switch_log_str2level(tmp);
if (verbose_log_level != SWITCH_LOG_INVALID) {
pvt->verbose_log_level = verbose_log_level;
}
}
if ((tmp = switch_channel_get_variable(channel, "fax_force_caller"))) { if ((tmp = switch_channel_get_variable(channel, "fax_force_caller"))) {
if (switch_true(tmp)) { if (switch_true(tmp)) {
pvt->caller = 1; pvt->caller = 1;