Logging: show verbosity level when logging

This commit is contained in:
Gautier Pelloux-Prayer 2015-06-19 18:10:32 +02:00
parent 0208f1d808
commit 5f8ed678a0
6 changed files with 68 additions and 47 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -45,6 +45,7 @@
[tester acknowledgeSystemAlert];
#endif
[super beforeAll];
linphone_core_set_log_level(ORTP_WARNING);
}

@ -1 +1 @@
Subproject commit c3cd2a6d114601ca32822ef5ed36d66b7fa9f776
Subproject commit f011905543d9ce9c503fb099cd2a5615b5762b62