diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 6f5530ebf..8be7a24c4 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -486,7 +486,7 @@ const LinphoneAddress *linphone_core_get_current_call_remote_address(struct _Lin static void linphone_core_log_collection_handler(const char *domain, OrtpLogLevel level, const char *fmt, va_list args); -void linphone_core_set_log_handler(OrtpLogFunc logfunc) { +void _linphone_core_set_log_handler(OrtpLogFunc logfunc) { liblinphone_user_log_func = logfunc; if (liblinphone_current_log_func == linphone_core_log_collection_handler) { ms_message("There is already a log collection handler, keep it"); @@ -495,9 +495,13 @@ void linphone_core_set_log_handler(OrtpLogFunc logfunc) { } } +void linphone_core_set_log_handler(OrtpLogFunc logfunc){ + _linphone_core_set_log_handler(logfunc); +} + void linphone_core_set_log_file(FILE *file) { if (file == NULL) file = stdout; - linphone_core_set_log_handler(NULL); + _linphone_core_set_log_handler(NULL); bctbx_set_log_file(file); /*gather everythings*/ } @@ -1046,7 +1050,7 @@ void linphone_core_enable_logs(FILE *file){ } void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){ - linphone_core_set_log_handler(logfunc); + _linphone_core_set_log_handler(logfunc); linphone_core_set_log_level(ORTP_MESSAGE); } diff --git a/coreapi/logging.c b/coreapi/logging.c index 7c7960650..fd3f12f36 100644 --- a/coreapi/logging.c +++ b/coreapi/logging.c @@ -183,7 +183,7 @@ static const char *_linphone_logging_service_log_domains[] = { "ortp", "mediastreamer", "bzrtp", - "linphone", + BCTBX_LOG_DOMAIN, /* which is "liblinphone", set from CMakeList.txt*/ NULL }; @@ -238,6 +238,11 @@ void linphone_logging_service_cbs_unref(LinphoneLoggingServiceCbs *cbs) { } void linphone_logging_service_cbs_set_log_message_written(LinphoneLoggingServiceCbs *cbs, LinphoneLoggingServiceCbsLogMessageWrittenCb cb) { + /* We need to set the legacy log handler to NULL here + because LinphoneCore have a default log handler that dump + all messages into the standard output. */ + /*this function is moved here to make sure default log handler is only removed when user defined logging cbs is set*/ + _linphone_core_set_log_handler(NULL); cbs->message_event_cb = cb; } diff --git a/coreapi/private_functions.h b/coreapi/private_functions.h index 772e89294..8f78e107d 100644 --- a/coreapi/private_functions.h +++ b/coreapi/private_functions.h @@ -558,6 +558,8 @@ LinphoneNatPolicy * linphone_config_create_nat_policy_from_section(const Linphon SalCustomHeader *linphone_info_message_get_headers (const LinphoneInfoMessage *im); void linphone_info_message_set_headers (LinphoneInfoMessage *im, const SalCustomHeader *headers); +void _linphone_core_set_log_handler(OrtpLogFunc logfunc); + #ifdef __cplusplus } #endif diff --git a/include/linphone/core.h b/include/linphone/core.h index 4d77351a3..c8e876c6a 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -807,7 +807,7 @@ LINPHONE_PUBLIC void linphone_core_reset_log_collection(void); /** * @bref Define a log handler. * @param logfunc The function pointer of the log handler. - * @deprecated Use #linphone_log_service_set_log_handler() instead. Deprecated since 2017-10-10. + * @deprecated Use #linphone_logging_service_cbs_set_log_message_written() instead. Deprecated since 2017-10-10. * @donotwrap */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_log_handler(OrtpLogFunc logfunc);