From 574ed8e52bad94235e6531f9e3deefed0febafa1 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 6 Aug 2014 10:53:05 +0200 Subject: [PATCH] Add API to activate the serialization of logs. --- coreapi/linphonecore.c | 19 +++++++++++++++---- coreapi/linphonecore.h | 8 ++++++++ oRTP | 2 +- 3 files changed, 24 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index a3d618e96..e2c21e90a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -64,6 +64,7 @@ static const char *liblinphone_version= LIBLINPHONE_VERSION #endif ; +static bool_t liblinphone_serialize_logs = FALSE; static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime); static void linphone_core_run_hooks(LinphoneCore *lc); static void linphone_core_free_hooks(LinphoneCore *lc); @@ -480,11 +481,15 @@ void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){ * @ingroup misc * @deprecated Use #linphone_core_set_log_level instead. **/ -void linphone_core_disable_logs(){ +void linphone_core_disable_logs(void){ ortp_set_log_level_mask(ORTP_ERROR|ORTP_FATAL); sal_disable_logs(); } +void linphone_core_serialize_logs(void) { + liblinphone_serialize_logs = TRUE; +} + static void net_config_read (LinphoneCore *lc) { @@ -1331,7 +1336,9 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab linphone_core_set_state(lc,LinphoneGlobalStartup,"Starting up"); ortp_init(); - ortp_set_log_thread_id(ortp_thread_self()); + if (liblinphone_serialize_logs == TRUE) { + ortp_set_log_thread_id(ortp_thread_self()); + } lc->dyn_pt=96; lc->default_profile=rtp_profile_new("default profile"); linphone_core_assign_payload_type(lc,&payload_type_pcmu8000,0,NULL); @@ -2397,7 +2404,9 @@ void linphone_core_iterate(LinphoneCore *lc){ } } - ortp_logv_flush(); + if (liblinphone_serialize_logs == TRUE) { + ortp_logv_flush(); + } } /** @@ -6038,7 +6047,9 @@ static void linphone_core_uninit(LinphoneCore *lc) linphone_core_message_storage_close(lc); ms_exit(); linphone_core_set_state(lc,LinphoneGlobalOff,"Off"); - ortp_set_log_thread_id(0); + if (liblinphone_serialize_logs == TRUE) { + ortp_set_log_thread_id(0); + } } static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t curtime){ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 5e842ac59..9fdb864df 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1674,6 +1674,14 @@ LINPHONE_PUBLIC void linphone_core_set_log_level(OrtpLogLevel loglevel); LINPHONE_PUBLIC void linphone_core_enable_logs(FILE *file); LINPHONE_PUBLIC void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc); LINPHONE_PUBLIC void linphone_core_disable_logs(void); + +/** + * Enable logs serialization (output logs from either the thread that creates the linphone core or the thread that calls linphone_core_iterate()). + * Must be called before creating the linphone core. + * @ingroup misc + */ +LINPHONE_PUBLIC void linphone_core_serialize_logs(void); + LINPHONE_PUBLIC const char *linphone_core_get_version(void); LINPHONE_PUBLIC const char *linphone_core_get_user_agent(LinphoneCore *lc); /** diff --git a/oRTP b/oRTP index fc8d8457e..dfb505d71 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit fc8d8457eb630907eff50333ddf5243b448fe733 +Subproject commit dfb505d7198dc8be59919c8c6d68add302a98fd3