diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index 9829d22b3..940ba4d92 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -87,12 +87,37 @@ void _belle_sip_log(belle_sip_log_level lev, const char *fmt, va_list args) { } } -void sal_enable_logs(){ - belle_sip_set_log_level(BELLE_SIP_LOG_MESSAGE); +void sal_enable_log(){ + sal_set_log_level(ORTP_MESSAGE); } -void sal_disable_logs() { - belle_sip_set_log_level(BELLE_SIP_LOG_ERROR); +void sal_disable_log() { + sal_set_log_level(ORTP_ERROR); +} + +void sal_set_log_level(OrtpLogLevel level) { + belle_sip_log_level belle_sip_level; + switch (level) { + case ORTP_FATAL: + belle_sip_level = BELLE_SIP_LOG_FATAL; + break; + case ORTP_ERROR: + belle_sip_level = BELLE_SIP_LOG_ERROR; + break; + case ORTP_WARNING: + belle_sip_level = BELLE_SIP_LOG_WARNING; + break; + case ORTP_MESSAGE: + belle_sip_level = BELLE_SIP_LOG_MESSAGE; + break; + case ORTP_DEBUG: + case ORTP_TRACE: + belle_sip_level = BELLE_SIP_LOG_DEBUG; + break; + case ORTP_LOGLEV_END: + return; + } + belle_sip_set_log_level(belle_sip_level); } void sal_add_pending_auth(Sal *sal, SalOp *op){ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8950308a9..618609179 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -177,9 +177,9 @@ void linphone_core_set_log_level(OrtpLogLevel loglevel) { void linphone_core_set_log_level_mask(OrtpLogLevel loglevel) { ortp_set_log_level_mask(loglevel); if (loglevel == 0) { - sal_disable_logs(); + sal_disable_log(); } else { - sal_enable_logs(); + sal_enable_log(); } } @@ -662,8 +662,8 @@ void linphone_core_reset_log_collection() { void linphone_core_enable_logs(FILE *file){ if (file==NULL) file=stdout; ortp_set_log_file(file); - ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); - sal_enable_logs(); + ortp_set_log_level(ORTP_MESSAGE); + sal_set_log_level(ORTP_MESSAGE); } /** @@ -677,9 +677,9 @@ void linphone_core_enable_logs(FILE *file){ * **/ void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){ - ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); + ortp_set_log_level(ORTP_MESSAGE); linphone_core_set_log_handler(logfunc); - sal_enable_logs(); + sal_set_log_level(ORTP_MESSAGE); } /** @@ -689,8 +689,8 @@ void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){ * @deprecated Use #linphone_core_set_log_level instead. **/ void linphone_core_disable_logs(void){ - ortp_set_log_level_mask(ORTP_ERROR|ORTP_FATAL); - sal_disable_logs(); + ortp_set_log_level(ORTP_ERROR); + sal_set_log_level(ORTP_ERROR); } void linphone_core_serialize_logs(void) { diff --git a/include/sal/sal.h b/include/sal/sal.h index 07d2212c2..7d888b34f 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -777,8 +777,11 @@ const SalCustomHeader *sal_op_get_recv_custom_header(SalOp *op); void sal_op_set_sent_custom_header(SalOp *op, SalCustomHeader* ch); -void sal_enable_logs(); -void sal_disable_logs(); +/** deprecated. use sal_set_log_level instead **/ +void sal_enable_log(); +/** deprecated. use sal_set_log_level instead **/ +void sal_disable_log(); +void sal_set_log_level(OrtpLogLevel level); /*internal API */ void __sal_op_init(SalOp *b, Sal *sal);