Removes the default log handler of LinphoneCore when LinphoneLoggingService is instantiated.

This commit is contained in:
François Grisez 2018-01-23 10:43:04 +01:00
parent 9316b09835
commit 7d8bc3b7cc
4 changed files with 14 additions and 2 deletions

View file

@ -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);

View file

@ -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;
}

View file

@ -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
}

View file

@ -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);