From 3a3c9636a502679bbdc041262458ecf88aaa1dc8 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Wed, 1 Jul 2015 12:18:30 +0200 Subject: [PATCH] Tester: always use the same logging system --- Classes/Utils/Utils.m | 3 +-- KifTests/LinphoneTestCase.m | 2 +- LinphoneTester Tests/LinphoneTester_Tests.m | 23 ++++------------- LinphoneTester/DetailViewController.m | 9 ++++--- LinphoneTester/MasterViewController.h | 2 -- LinphoneTester/MasterViewController.m | 28 +++++++-------------- linphone.xcodeproj/project.pbxproj | 4 +++ submodules/linphone | 2 +- 8 files changed, 26 insertions(+), 47 deletions(-) diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index b75f14e98..0cf88d007 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -20,6 +20,7 @@ #import "Utils.h" #include "linphone/linphonecore.h" +#import @implementation LinphoneLogger @@ -262,8 +263,6 @@ void linphone_iphone_log_handler(int lev, const char *fmt, va_list args) { @implementation NSString(md5) -#import - - (NSString *)md5 { const char *ptr = [self UTF8String]; unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH]; diff --git a/KifTests/LinphoneTestCase.m b/KifTests/LinphoneTestCase.m index d484327b2..ce5114103 100644 --- a/KifTests/LinphoneTestCase.m +++ b/KifTests/LinphoneTestCase.m @@ -102,7 +102,7 @@ static bool invalidAccount = true; [tester waitForTimeInterval:0.5]; } - NSLog(@"Switching to a valid account"); + LOGI(@"Switching to a valid account"); [tester tapViewWithAccessibilityLabel:@"Start"]; [tester tapViewWithAccessibilityLabel:@"Sign in linphone.org account"]; diff --git a/LinphoneTester Tests/LinphoneTester_Tests.m b/LinphoneTester Tests/LinphoneTester_Tests.m index 01dcb0e32..95e9d27a7 100644 --- a/LinphoneTester Tests/LinphoneTester_Tests.m +++ b/LinphoneTester Tests/LinphoneTester_Tests.m @@ -10,6 +10,7 @@ #include "linphone/linphonecore.h" #include "linphone/liblinphone_tester.h" #import "NSObject+DTRuntime.h" +#import "Utils.h" @interface LinphoneTester_Tests : XCTestCase @property (retain, nonatomic) NSString* bundlePath; @@ -17,19 +18,6 @@ @end @implementation LinphoneTester_Tests -static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list args) { - NSString* log = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:fmt] arguments:args]; - NSLog(@"%@",log); -} - - -void LSLog(NSString* fmt, ...){ - va_list args; - va_start(args, fmt); - linphone_log_function(ORTP_MESSAGE, [fmt UTF8String], args); - va_end(args); -} - + (NSArray*)skippedSuites { NSArray* skipped_suites = @[@"Flexisip"]; @@ -48,7 +36,7 @@ void LSLog(NSString* fmt, ...){ static char * bundle = NULL; static char * documents = NULL; - bc_tester_init((void (*)(int, const char *fm, va_list))linphone_log_function, ORTP_MESSAGE, ORTP_ERROR); + bc_tester_init((void (*)(int, const char *fm, va_list))linphone_iphone_log_handler, ORTP_MESSAGE, ORTP_ERROR); liblinphone_tester_add_suites(); NSString* bundlePath = [[NSBundle mainBundle] bundlePath]; @@ -57,14 +45,13 @@ void LSLog(NSString* fmt, ...){ bundle = ms_strdup([bundlePath UTF8String]); documents = ms_strdup([documentPath UTF8String]); - LSLog(@"Bundle path: %@", bundlePath); - LSLog(@"Document path: %@", documentPath); + LOGI(@"Bundle path: %@", bundlePath); + LOGI(@"Document path: %@", documentPath); bc_tester_read_dir_prefix = ms_strdup(bundle); bc_tester_writable_dir_prefix = ms_strdup(documents); liblinphone_tester_keep_accounts(TRUE); - int count = bc_tester_nb_suites(); for (int i=0; i -void LSLog(NSString* fmt, ...); - NSMutableArray* lastLogs; NSString* const kLogsUpdateNotification; diff --git a/LinphoneTester/MasterViewController.m b/LinphoneTester/MasterViewController.m index 0bae72436..e338cbcc3 100644 --- a/LinphoneTester/MasterViewController.m +++ b/LinphoneTester/MasterViewController.m @@ -12,6 +12,7 @@ #include "linphone/liblinphone_tester.h" #include "mediastreamer2/msutils.h" +#import "Utils.h" @interface MasterViewController () { NSMutableArray *_objects; @@ -37,23 +38,12 @@ static int const kLastLogsCapacity = 5000; static int const kLogsBufferCapacity = 10; NSString* const kLogsUpdateNotification = @"kLogsUpdateNotification"; -void LSLog(NSString* fmt, ...){ - va_list args; - va_start(args, fmt); - linphone_log_function(ORTP_MESSAGE, [fmt UTF8String], args); - va_end(args); -} - -static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list args) { - NSString* log = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:fmt] arguments:args]; - NSLog(@"%@",log); -} - - (void)setupLogging { lastLogs = [[NSMutableArray alloc] initWithCapacity:kLastLogsCapacity]; logsBuffer = [NSMutableArray arrayWithCapacity:kLogsBufferCapacity]; - linphone_core_set_log_handler(linphone_log_function); + // linphone_core_set_log_level(ORTP_MESSAGE); + linphone_core_set_log_handler((OrtpLogFunc)linphone_iphone_log_handler); } @@ -69,16 +59,16 @@ static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list arg NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); documentPath = [paths objectAtIndex:0]; - bc_tester_init((void (*)(int, const char *fm, va_list))linphone_log_function, ORTP_MESSAGE, ORTP_ERROR); + bc_tester_init((void (*)(int, const char *fm, va_list))linphone_iphone_log_handler, ORTP_MESSAGE, ORTP_ERROR); liblinphone_tester_add_suites(); bc_tester_read_dir_prefix = ms_strdup([bundlePath UTF8String]); bc_tester_writable_dir_prefix = ms_strdup([documentPath UTF8String]); - LSLog(@"Bundle path: %@", bundlePath); - LSLog(@"Document path: %@", documentPath); + LOGI(@"Bundle path: %@", bundlePath); + LOGI(@"Document path: %@", documentPath); - int count = bc_tester_nb_suites(); + int count = bc_tester_nb_suites(); _objects = [[NSMutableArray alloc] initWithCapacity:count + 1]; [_objects addObject:@"All"]; for (int i = 0; i < count; i++) { @@ -88,8 +78,8 @@ static void linphone_log_function(OrtpLogLevel lev, const char *fmt, va_list arg } - (void)displayLogs { - LSLog(@"Should display logs"); - [self.navigationController performSegueWithIdentifier:@"viewLogs" sender:self]; + LOGI(@"Should display logs"); + [self.navigationController performSegueWithIdentifier:@"viewLogs" sender:self]; } - (void)didReceiveMemoryWarning diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index b96c6ad3b..4d8f587b5 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -111,6 +111,8 @@ 630CF5571AF7CE1500539F7A /* UITextField+DoneButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 630CF5561AF7CE1500539F7A /* UITextField+DoneButton.m */; }; 631C4FB119D2A8F2004BFE77 /* UIDigitButtonLongPlus.m in Sources */ = {isa = PBXBuildFile; fileRef = 631C4FB019D2A8F2004BFE77 /* UIDigitButtonLongPlus.m */; }; 631C4FB719D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m in Sources */ = {isa = PBXBuildFile; fileRef = 631C4FB619D2C3A6004BFE77 /* UIDigitButtonLongVoiceMail.m */; }; + 632DA24D1B43EE9400EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; + 632DA24E1B43EEEF00EB356A /* Utils.m in Sources */ = {isa = PBXBuildFile; fileRef = D35860D515B549B500513429 /* Utils.m */; }; 636316D11A1DEBCB0009B839 /* AboutViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D31A1DEBCB0009B839 /* AboutViewController.xib */; }; 636316D41A1DEC650009B839 /* SettingsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D61A1DEC650009B839 /* SettingsViewController.xib */; }; 636316D91A1DECC90009B839 /* PhoneMainView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 636316D71A1DECC90009B839 /* PhoneMainView.xib */; }; @@ -4049,6 +4051,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 632DA24E1B43EEEF00EB356A /* Utils.m in Sources */, F08F119D19C0A65B007D70C2 /* NSObject+DTRuntime.m in Sources */, F08F118F19C09C6B007D70C2 /* LinphoneTester_Tests.m in Sources */, F08F11A019C0A6CB007D70C2 /* DTObjectBlockExecutor.m in Sources */, @@ -4059,6 +4062,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 632DA24D1B43EE9400EB356A /* Utils.m in Sources */, F0BB8BE41936208100974404 /* AppDelegate.m in Sources */, F84015C7193B4E34006ABAB5 /* LogsViewController.m in Sources */, F0BB8BED1936208200974404 /* MasterViewController.m in Sources */, diff --git a/submodules/linphone b/submodules/linphone index 58bf466a6..369d67517 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit 58bf466a676881ff5c4f086bb2ef77a472cc0a00 +Subproject commit 369d675171bc38601fe4d38834fc66df8e52ec9f