diff --git a/Classes/ChatRoomTableViewController.m b/Classes/ChatRoomTableViewController.m index 425b06662..3dfe02b57 100644 --- a/Classes/ChatRoomTableViewController.m +++ b/Classes/ChatRoomTableViewController.m @@ -114,16 +114,16 @@ - (void)debugMessages { if( !messageList ){ - NSLog(@"No data to debug"); - return; - } - MSList*item = self->messageList; - int count = 0; - while (item) { - LinphoneChatMessage* msg = (LinphoneChatMessage*)item->data; - NSLog(@"Message %d: %s", count++, linphone_chat_message_get_text(msg)); - item = item->next; - } + LOGE(@"No data to debug"); + return; + } + MSList *item = self->messageList; + int count = 0; + while (item) { + LinphoneChatMessage *msg = (LinphoneChatMessage *)item->data; + LOGI(@"Message %d: %s", count++, linphone_chat_message_get_text(msg)); + item = item->next; + } } - (void)scrollToLastUnread:(BOOL)animated { diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index 949bc6ec8..b79ac5886 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -524,23 +524,14 @@ static void dump_section(const char* section, void* data){ } } - -#pragma mark - Logs Functions - -void linphone_iphone_log_handler(int lev, const char *fmt, va_list args){ - NSString* format = [[NSString alloc] initWithUTF8String:fmt]; - NSString* formatedString = [[NSString alloc] initWithFormat:format arguments:args]; - //since \r are interpreted like \n, avoid double new lines when logging packets - NSLog([formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"], nil); +#pragma mark - Logs Functions handlers +static void linphone_iphone_log_user_info(struct _LinphoneCore *lc, const char *message) { + linphone_iphone_log_handler(ORTP_MESSAGE, message, NULL); } - -//Error/warning log handler -static void linphone_iphone_log(struct _LinphoneCore * lc, const char * message) { - NSString* log = [NSString stringWithCString:message encoding:[NSString defaultCStringEncoding]]; - NSLog(log, NULL); +static void linphone_iphone_log_user_warning(struct _LinphoneCore *lc, const char *message) { + linphone_iphone_log_handler(ORTP_WARNING, message, NULL); } - #pragma mark - Display Status Functions - (void)displayStatus:(NSString*) message { @@ -1188,26 +1179,25 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach #pragma mark - VTable -static LinphoneCoreVTable linphonec_vtable = { - .show =NULL, - .call_state_changed =(LinphoneCoreCallStateChangedCb)linphone_iphone_call_state, - .registration_state_changed = linphone_iphone_registration_state, - .notify_presence_received=NULL, - .new_subscription_requested = NULL, - .auth_info_requested = NULL, - .display_status = linphone_iphone_display_status, - .display_message=linphone_iphone_log, - .display_warning=linphone_iphone_log, - .display_url=NULL, - .text_received=NULL, - .message_received=linphone_iphone_message_received, - .dtmf_received=NULL, - .transfer_state_changed=linphone_iphone_transfer_state_changed, - .is_composing_received = linphone_iphone_is_composing_received, - .configuring_status = linphone_iphone_configuring_status_changed, - .global_state_changed = linphone_iphone_global_state_changed, - .notify_received = linphone_iphone_notify_received -}; +static LinphoneCoreVTable linphonec_vtable = {.show = NULL, + .call_state_changed = + (LinphoneCoreCallStateChangedCb)linphone_iphone_call_state, + .registration_state_changed = linphone_iphone_registration_state, + .notify_presence_received = NULL, + .new_subscription_requested = NULL, + .auth_info_requested = NULL, + .display_status = linphone_iphone_display_status, + .display_message = linphone_iphone_log_user_info, + .display_warning = linphone_iphone_log_user_warning, + .display_url = NULL, + .text_received = NULL, + .message_received = linphone_iphone_message_received, + .dtmf_received = NULL, + .transfer_state_changed = linphone_iphone_transfer_state_changed, + .is_composing_received = linphone_iphone_is_composing_received, + .configuring_status = linphone_iphone_configuring_status_changed, + .global_state_changed = linphone_iphone_global_state_changed, + .notify_received = linphone_iphone_notify_received}; #pragma mark - @@ -1374,7 +1364,7 @@ static BOOL libStarted = FALSE; NSError* err; if( ![audioSession setActive:NO error: &err] && err ){ - NSLog(@"audioSession setActive failed: %@", [err description]); + LOGE(@"audioSession setActive failed: %@", [err description]); } if(!bAudioInputAvailable){ UIAlertView* error = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"No microphone",nil) diff --git a/Classes/Utils/Utils.h b/Classes/Utils/Utils.h index 209499e75..e5dbcf3f4 100644 --- a/Classes/Utils/Utils.h +++ b/Classes/Utils/Utils.h @@ -39,7 +39,7 @@ typedef enum _LinphoneLoggerSeverity { } + (void)log:(LinphoneLoggerSeverity)severity file:(const char*)file line:(int)line format:(NSString *)format,...; - +void linphone_iphone_log_handler(int lev, const char *fmt, va_list args); @end @interface LinphoneUtils : NSObject { diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index 971a7da71..ec4f1ab59 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -52,6 +52,36 @@ va_end (args); } +#pragma mark - Logs Functions callbacks + +void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) { + NSString *format = [[NSString alloc] initWithUTF8String:fmt]; + NSString *formatedString = [[NSString alloc] initWithFormat:format arguments:args]; + char levelC = 'I'; + switch ((OrtpLogLevel)lev) { + case ORTP_FATAL: + levelC = 'F'; + break; + case ORTP_ERROR: + levelC = 'E'; + break; + case ORTP_WARNING: + levelC = 'W'; + break; + case ORTP_MESSAGE: + levelC = 'I'; + break; + case ORTP_TRACE: + case ORTP_DEBUG: + levelC = 'D'; + break; + case ORTP_LOGLEV_END: + return; + } + // since \r are interpreted like \n, avoid double new lines when logging packets + NSLog(@"%c %@", levelC, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]); +} + @end @implementation LinphoneUtils diff --git a/KifTests/LinphoneTestCase.m b/KifTests/LinphoneTestCase.m index 38b44a836..5060036c3 100644 --- a/KifTests/LinphoneTestCase.m +++ b/KifTests/LinphoneTestCase.m @@ -45,6 +45,7 @@ [tester acknowledgeSystemAlert]; #endif [super beforeAll]; + linphone_core_set_log_level(ORTP_WARNING); } diff --git a/submodules/linphone b/submodules/linphone index c3cd2a6d1..f01190554 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit c3cd2a6d114601ca32822ef5ed36d66b7fa9f776 +Subproject commit f011905543d9ce9c503fb099cd2a5615b5762b62