From 7d8bc3b7cc9b2eea0371665e3a43e4904bcf7f0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Tue, 23 Jan 2018 10:43:04 +0100 Subject: [PATCH] Removes the default log handler of LinphoneCore when LinphoneLoggingService is instantiated. --- coreapi/linphonecore.c | 6 +++++- coreapi/logging.c | 6 ++++++ coreapi/private.h | 2 ++ include/linphone/core.h | 2 +- 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 575b11790..c4f07e691 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -462,7 +462,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"); @@ -471,6 +471,10 @@ 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); diff --git a/coreapi/logging.c b/coreapi/logging.c index 78c68596e..8512595b9 100644 --- a/coreapi/logging.c +++ b/coreapi/logging.c @@ -132,6 +132,12 @@ static LinphoneLoggingService *_linphone_logging_service_new(void) { service->log_handler = bctbx_create_log_handler(_log_handler_on_message_written_cb, _log_handler_destroy_cb, service); service->cbs = _linphone_logging_service_cbs_new(); bctbx_add_log_handler(service->log_handler); + + /* 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. */ + _linphone_core_set_log_handler(NULL); + return service; } diff --git a/coreapi/private.h b/coreapi/private.h index 1c2af376c..54c18b7e5 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -2036,6 +2036,8 @@ LinphoneVideoDefinition * linphone_factory_find_supported_video_definition_by_na const char* _linphone_config_load_from_xml_string(LpConfig *lpc, const char *buffer); LinphoneNatPolicy * linphone_config_create_nat_policy_from_section(const LinphoneConfig *config, const char* section); +void _linphone_core_set_log_handler(OrtpLogFunc logfunc); + #ifdef __cplusplus } diff --git a/include/linphone/core.h b/include/linphone/core.h index 06bd97b1f..d06335409 100644 --- a/include/linphone/core.h +++ b/include/linphone/core.h @@ -797,7 +797,7 @@ LINPHONE_PUBLIC void linphone_core_reset_log_collection(void); * 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. */ LINPHONE_PUBLIC LINPHONE_DEPRECATED void linphone_core_set_log_handler(OrtpLogFunc logfunc);