diff --git a/Classes/Utils/Log.m b/Classes/Utils/Log.m index f89f2d095..0441d51b5 100644 --- a/Classes/Utils/Log.m +++ b/Classes/Utils/Log.m @@ -79,79 +79,46 @@ void linphone_iphone_log_handler(const char *domain, OrtpLogLevel lev, const char *fmt, va_list args) { NSString *format = [[NSString alloc] initWithUTF8String:fmt]; NSString *formatedString = [[NSString alloc] initWithFormat:format arguments:args]; + NSString *lvl; if (!domain) domain = "lib"; // since \r are interpreted like \n, avoid double new lines when logging network packets (belle-sip) // output format is like: I/ios/some logs. We truncate domain to **exactly** DOMAIN_SIZE characters to have // fixed-length aligned logs - - if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_9_x_Max) { - os_log_t log = os_log_create("subsystem", "Notice"); - os_log_type_t type = OS_LOG_TYPE_INFO; - switch (lev) { - case ORTP_FATAL: - type = OS_LOG_TYPE_FAULT; - log = os_log_create("subsystem", "Fatal"); - break; - case ORTP_ERROR: - type = OS_LOG_TYPE_ERROR; - log = os_log_create("subsystem", "Error"); - break; - case ORTP_WARNING: - type = OS_LOG_TYPE_DEFAULT; - log = os_log_create("subsystem", "Warning"); - break; - case ORTP_MESSAGE: - type = OS_LOG_TYPE_INFO; - log = os_log_create("subsystem", "Notice"); - break; - case ORTP_DEBUG: - case ORTP_TRACE: - type = OS_LOG_TYPE_INFO; - log = os_log_create("subsystem", "Debug"); - break; - case ORTP_LOGLEV_END: - return; - } - if ([formatedString containsString:@"\n"]) { - NSArray *myWords = [[formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"] - componentsSeparatedByString:@"\n"]; - for (int i = 0; i < myWords.count; i++) { - NSString *tab = i > 0 ? @"\t" : @""; - if (((NSString *)myWords[i]).length > 0) { - os_log_with_type(log, type, "%{public}s%{public}s", tab.UTF8String, - ((NSString *)myWords[i]).UTF8String); - } + switch (lev) { + case ORTP_FATAL: + lvl = @"Fatal"; + break; + case ORTP_ERROR: + lvl = @"Error"; + break; + case ORTP_WARNING: + lvl = @"Warning"; + break; + case ORTP_MESSAGE: + lvl = @"Message"; + break; + case ORTP_DEBUG: + lvl = @"Debug"; + break; + case ORTP_TRACE: + lvl = @"Trace"; + break; + case ORTP_LOGLEV_END: + return; + } + if ([formatedString containsString:@"\n"]) { + NSArray *myWords = [[formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"] + componentsSeparatedByString:@"\n"]; + for (int i = 0; i < myWords.count; i++) { + NSString *tab = i > 0 ? @"\t" : @""; + if (((NSString *)myWords[i]).length > 0) { + NSLog(@"[%@] %@%@", lvl, tab, (NSString *)myWords[i]); } - } else { - os_log_with_type(log, type, "%{public}s/%{public}s", domain, - [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"].UTF8String); } } else { - int lvl = ASL_LEVEL_NOTICE; - switch (lev) { - case ORTP_FATAL: - lvl = ASL_LEVEL_CRIT; - break; - case ORTP_ERROR: - lvl = ASL_LEVEL_ERR; - break; - case ORTP_WARNING: - lvl = ASL_LEVEL_WARNING; - break; - case ORTP_MESSAGE: - lvl = ASL_LEVEL_NOTICE; - break; - case ORTP_DEBUG: - case ORTP_TRACE: - lvl = ASL_LEVEL_INFO; - break; - case ORTP_LOGLEV_END: - return; - } - asl_log(NULL, NULL, lvl, "%*.*s/%s", DOMAIN_SIZE, DOMAIN_SIZE, domain, - [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"].UTF8String); + NSLog(@"[%@] %@", lvl, [formatedString stringByReplacingOccurrencesOfString:@"\r\n" withString:@"\n"]); } }