1*d9f75844SAndroid Build Coastguard Worker/* 2*d9f75844SAndroid Build Coastguard Worker * Copyright 2015 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker#import "RTCLogging.h" 12*d9f75844SAndroid Build Coastguard Worker 13*d9f75844SAndroid Build Coastguard Worker#include "rtc_base/logging.h" 14*d9f75844SAndroid Build Coastguard Worker 15*d9f75844SAndroid Build Coastguard Workerrtc::LoggingSeverity RTCGetNativeLoggingSeverity(RTCLoggingSeverity severity) { 16*d9f75844SAndroid Build Coastguard Worker switch (severity) { 17*d9f75844SAndroid Build Coastguard Worker case RTCLoggingSeverityVerbose: 18*d9f75844SAndroid Build Coastguard Worker return rtc::LS_VERBOSE; 19*d9f75844SAndroid Build Coastguard Worker case RTCLoggingSeverityInfo: 20*d9f75844SAndroid Build Coastguard Worker return rtc::LS_INFO; 21*d9f75844SAndroid Build Coastguard Worker case RTCLoggingSeverityWarning: 22*d9f75844SAndroid Build Coastguard Worker return rtc::LS_WARNING; 23*d9f75844SAndroid Build Coastguard Worker case RTCLoggingSeverityError: 24*d9f75844SAndroid Build Coastguard Worker return rtc::LS_ERROR; 25*d9f75844SAndroid Build Coastguard Worker case RTCLoggingSeverityNone: 26*d9f75844SAndroid Build Coastguard Worker return rtc::LS_NONE; 27*d9f75844SAndroid Build Coastguard Worker } 28*d9f75844SAndroid Build Coastguard Worker} 29*d9f75844SAndroid Build Coastguard Worker 30*d9f75844SAndroid Build Coastguard Workervoid RTCLogEx(RTCLoggingSeverity severity, NSString* log_string) { 31*d9f75844SAndroid Build Coastguard Worker if (log_string.length) { 32*d9f75844SAndroid Build Coastguard Worker const char* utf8_string = log_string.UTF8String; 33*d9f75844SAndroid Build Coastguard Worker RTC_LOG_V(RTCGetNativeLoggingSeverity(severity)) << utf8_string; 34*d9f75844SAndroid Build Coastguard Worker } 35*d9f75844SAndroid Build Coastguard Worker} 36*d9f75844SAndroid Build Coastguard Worker 37*d9f75844SAndroid Build Coastguard Workervoid RTCSetMinDebugLogLevel(RTCLoggingSeverity severity) { 38*d9f75844SAndroid Build Coastguard Worker rtc::LogMessage::LogToDebug(RTCGetNativeLoggingSeverity(severity)); 39*d9f75844SAndroid Build Coastguard Worker} 40*d9f75844SAndroid Build Coastguard Worker 41*d9f75844SAndroid Build Coastguard WorkerNSString* RTCFileName(const char* file_path) { 42*d9f75844SAndroid Build Coastguard Worker NSString* ns_file_path = 43*d9f75844SAndroid Build Coastguard Worker [[NSString alloc] initWithBytesNoCopy:const_cast<char*>(file_path) 44*d9f75844SAndroid Build Coastguard Worker length:strlen(file_path) 45*d9f75844SAndroid Build Coastguard Worker encoding:NSUTF8StringEncoding 46*d9f75844SAndroid Build Coastguard Worker freeWhenDone:NO]; 47*d9f75844SAndroid Build Coastguard Worker return ns_file_path.lastPathComponent; 48*d9f75844SAndroid Build Coastguard Worker} 49