forked from mirrors/linphone-iphone
log: application logs are now separated of liblinphone logs
This commit is contained in:
parent
9671009541
commit
19fe1bd5d9
10 changed files with 60 additions and 88 deletions
|
|
@ -313,9 +313,8 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[alertView addButtonWithTitle:actionLog
|
||||
block:^{
|
||||
// enable / disable
|
||||
BOOL enableDebug = ![mgr lpConfigBoolForKey:@"debugenable_preference"];
|
||||
[mgr lpConfigSetBool:enableDebug forKey:@"debugenable_preference"];
|
||||
[mgr setLogsEnabled:enableDebug];
|
||||
BOOL enableDebug = !debugEnabled;
|
||||
[Log enableLogs:enableDebug];
|
||||
}];
|
||||
|
||||
[alertView show];
|
||||
|
|
|
|||
|
|
@ -792,10 +792,6 @@
|
|||
|
||||
// advanced section
|
||||
{
|
||||
BOOL debugmode = [self boolForKey:@"debugenable_preference"];
|
||||
[lm lpConfigSetInt:debugmode forKey:@"debugenable_preference"];
|
||||
[LinphoneManager.instance setLogsEnabled:debugmode];
|
||||
|
||||
BOOL animations = [self boolForKey:@"animations_preference"];
|
||||
[lm lpConfigSetInt:animations forKey:@"animations_preference"];
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,6 @@ typedef struct _LinphoneManagerSounds {
|
|||
- (bool)allowSpeaker;
|
||||
|
||||
- (void)configureVbrCodecs;
|
||||
- (void)setLogsEnabled:(BOOL)enabled;
|
||||
|
||||
+ (BOOL)copyFile:(NSString*)src destination:(NSString*)dst override:(BOOL)override;
|
||||
+ (NSString*)bundleFile:(NSString*)file;
|
||||
|
|
|
|||
|
|
@ -1441,7 +1441,7 @@ static BOOL libStarted = FALSE;
|
|||
return;
|
||||
}
|
||||
linphone_core_set_log_collection_path([[LinphoneManager cacheDirectory] UTF8String]);
|
||||
[self setLogsEnabled:[self lpConfigBoolForKey:@"debugenable_preference"]];
|
||||
[Log enableLogs:([self lpConfigBoolForKey:@"debugenable_preference"] || LinphoneManager.instance.isTesting)];
|
||||
connectivity = none;
|
||||
|
||||
ms_init(); // Need to initialize mediastreamer2 before loading the plugins
|
||||
|
|
@ -2133,25 +2133,6 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) {
|
|||
}
|
||||
}
|
||||
|
||||
- (void)setLogsEnabled:(BOOL)enabled {
|
||||
if ([LinphoneManager isRunningTests]) {
|
||||
NSLog(@"Running tests, forcing logs to MESSAGE level");
|
||||
linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler);
|
||||
linphone_core_set_log_level(ORTP_MESSAGE);
|
||||
} else {
|
||||
if (enabled) {
|
||||
NSLog(@"Enabling debug logs");
|
||||
linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler);
|
||||
linphone_core_set_log_level(ORTP_DEBUG);
|
||||
linphone_core_enable_log_collection(enabled);
|
||||
} else {
|
||||
NSLog(@"Disabling debug logs");
|
||||
linphone_core_enable_log_collection(enabled);
|
||||
linphone_core_disable_logs();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+ (id)getMessageAppDataForKey:(NSString *)key inMessage:(LinphoneChatMessage *)msg {
|
||||
|
||||
if (msg == nil)
|
||||
|
|
|
|||
|
|
@ -19,16 +19,19 @@
|
|||
|
||||
#import "LinphoneManager.h"
|
||||
|
||||
#define LOGV(level, ...) [LinphoneLogger log:level file:__FILE__ line:__LINE__ format:__VA_ARGS__]
|
||||
#define LOGD(...) LOGV(ORTP_DEBUG, __VA_ARGS__)
|
||||
#define LOGI(...) LOGV(ORTP_MESSAGE, __VA_ARGS__)
|
||||
#define LOGW(...) LOGV(ORTP_WARNING, __VA_ARGS__)
|
||||
#define LOGE(...) LOGV(ORTP_ERROR, __VA_ARGS__)
|
||||
#define LOGF(...) LOGV(ORTP_FATAL, __VA_ARGS__)
|
||||
#define APP_LVL 1 << 7
|
||||
#define LOGV(level, ...) [Log log:APP_LVL & level file:__FILE__ line:__LINE__ format:__VA_ARGS__]
|
||||
#define LOGD(...) LOGV(APP_LVL | ORTP_DEBUG, __VA_ARGS__)
|
||||
#define LOGI(...) LOGV(APP_LVL | ORTP_MESSAGE, __VA_ARGS__)
|
||||
#define LOGW(...) LOGV(APP_LVL | ORTP_WARNING, __VA_ARGS__)
|
||||
#define LOGE(...) LOGV(APP_LVL | ORTP_ERROR, __VA_ARGS__)
|
||||
#define LOGF(...) LOGV(APP_LVL | ORTP_FATAL, __VA_ARGS__)
|
||||
|
||||
@interface LinphoneLogger : NSObject {
|
||||
@interface Log : NSObject {
|
||||
}
|
||||
|
||||
+ (void)log:(OrtpLogLevel)severity file:(const char *)file line:(int)line format:(NSString *)format, ...;
|
||||
+ (void)enableLogs:(BOOL)enabled;
|
||||
|
||||
void linphone_iphone_log_handler(int lev, const char *fmt, va_list args);
|
||||
@end
|
||||
|
|
@ -414,7 +414,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
removeFromHiddenKeys = debugEnabled;
|
||||
[keys addObject:@"send_logs_button"];
|
||||
[keys addObject:@"reset_logs_button"];
|
||||
[LinphoneManager.instance setLogsEnabled:debugEnabled];
|
||||
[Log enableLogs:(debugEnabled || LinphoneManager.instance.isTesting)];
|
||||
} else if ([@"account_mandatory_advanced_preference" compare:notif.object] == NSOrderedSame) {
|
||||
removeFromHiddenKeys = [[notif.userInfo objectForKey:@"account_mandatory_advanced_preference"] boolValue];
|
||||
for (NSString *key in settingsStore->dict) {
|
||||
|
|
@ -535,9 +535,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
[hiddenKeys addObject:@"wifi_only_preference"];
|
||||
|
||||
[hiddenKeys addObject:@"quit_button"]; // Hide for the moment
|
||||
[hiddenKeys addObject:@"about_button"]; // Hide for the moment
|
||||
|
||||
if (!linphone_core_video_supported(LC)) {
|
||||
[hiddenKeys addObject:@"video_menu"];
|
||||
}
|
||||
|
|
@ -700,8 +697,6 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[_settingsController.navigationController popViewControllerAnimated:NO];
|
||||
}];
|
||||
[alert show];
|
||||
} else if ([key isEqual:@"about_button"]) {
|
||||
[PhoneMainView.instance changeCurrentView:AboutView.compositeViewDescription];
|
||||
} else if ([key isEqual:@"reset_logs_button"]) {
|
||||
linphone_core_reset_log_collection();
|
||||
} else if ([key isEqual:@"send_logs_button"]) {
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
#import "Log.h"
|
||||
|
||||
@implementation LinphoneLogger
|
||||
@implementation Log
|
||||
|
||||
+ (void)log:(OrtpLogLevel)severity file:(const char *)file line:(int)line format:(NSString *)format, ... {
|
||||
va_list args;
|
||||
|
|
@ -28,45 +28,59 @@
|
|||
const char *utf8str = [str cStringUsingEncoding:NSString.defaultCStringEncoding];
|
||||
int filesize = 20;
|
||||
const char *filename = strchr(file, '/') ? strrchr(file, '/') + 1 : file;
|
||||
if (severity <= ORTP_DEBUG) {
|
||||
// lol: ortp_debug(XXX) can be disabled at compile time, but ortp_log(ORTP_DEBUG, xxx) will always be valid even
|
||||
// not in debug build...
|
||||
ortp_debug("%*s:%3d - %s", filesize, filename + MAX((int)strlen(filename) - filesize, 0), line, utf8str);
|
||||
} else {
|
||||
ortp_log(severity, "%*s:%3d - %s", filesize, filename + MAX((int)strlen(filename) - filesize, 0), line,
|
||||
utf8str);
|
||||
|
||||
char levelC = 'U'; // undefined
|
||||
if ((severity & ORTP_FATAL) != 0) {
|
||||
levelC = 'F';
|
||||
} else if ((severity & ORTP_ERROR) != 0) {
|
||||
levelC = 'E';
|
||||
} else if ((severity & ORTP_WARNING) != 0) {
|
||||
levelC = 'W';
|
||||
} else if ((severity & ORTP_MESSAGE) != 0) {
|
||||
levelC = 'I';
|
||||
} else if (((severity & ORTP_TRACE) != 0) || ((severity & ORTP_DEBUG) != 0)) {
|
||||
levelC = 'D';
|
||||
}
|
||||
// we want application logs to be always enabled so use | ORTP_ERROR extra mask
|
||||
ortp_log(severity | ORTP_ERROR, "%c %*s:%3d - %s", levelC, filesize,
|
||||
filename + MAX((int)strlen(filename) - filesize, 0), line, utf8str);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
+ (void)enableLogs:(BOOL)enabled {
|
||||
[LinphoneManager.instance lpConfigSetBool:enabled forKey:@"debugenable_preference"];
|
||||
linphone_core_enable_logs_with_cb((OrtpLogFunc)linphone_iphone_log_handler);
|
||||
if (enabled) {
|
||||
NSLog(@"Enabling debug logs");
|
||||
linphone_core_set_log_level(ORTP_DEBUG);
|
||||
} else {
|
||||
NSLog(@"Disabling debug logs");
|
||||
linphone_core_set_log_level(ORTP_ERROR);
|
||||
}
|
||||
linphone_core_enable_log_collection(enabled);
|
||||
}
|
||||
|
||||
#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;
|
||||
NSString *lvl = @"";
|
||||
if ((lev & APP_LVL) == 0) {
|
||||
if ((lev & ORTP_FATAL) != 0) {
|
||||
lvl = @"F ";
|
||||
} else if ((lev & ORTP_ERROR) != 0) {
|
||||
lvl = @"E ";
|
||||
} else if ((lev & ORTP_WARNING) != 0) {
|
||||
lvl = @"W ";
|
||||
} else if ((lev & ORTP_MESSAGE) != 0) {
|
||||
lvl = @"I ";
|
||||
} else if (((lev & ORTP_TRACE) != 0) || ((lev & ORTP_DEBUG) != 0)) {
|
||||
lvl = @"D ";
|
||||
}
|
||||
}
|
||||
// since \r are interpreted like \n, avoid double new lines when logging packets
|
||||
NSLog(@"%c %@", levelC, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]);
|
||||
// since \r are interpreted like \n, avoid double new lines when logging network packets (belle-sip)
|
||||
NSLog(@"%@%@", lvl, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -150,22 +150,6 @@
|
|||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Key</key>
|
||||
<string>about_button</string>
|
||||
<key>Title</key>
|
||||
<string>About</string>
|
||||
<key>Type</key>
|
||||
<string>IASKButtonSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Key</key>
|
||||
<string>quit_button</string>
|
||||
<key>Title</key>
|
||||
<string>Quit</string>
|
||||
<key>Type</key>
|
||||
<string>IASKButtonSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Key</key>
|
||||
<string>release_button</string>
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
|
||||
- (void)beforeEach {
|
||||
[[LinphoneManager instance] lpConfigSetInt:NO forKey:@"animations_preference"];
|
||||
linphone_core_set_log_level(ORTP_MESSAGE);
|
||||
}
|
||||
|
||||
- (NSString *)me {
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 454e9834aed36270db6cdf2e4ca7240713dcf930
|
||||
Subproject commit 67f9bd2068ab6d040ddadd4209a538aef99a893a
|
||||
Loading…
Add table
Reference in a new issue