tkchin | 42f580e | 2015-11-26 23:18:23 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2015 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
tkchin | 9eeb624 | 2016-04-27 01:54:20 -0700 | [diff] [blame] | 11 | #import "WebRTC/RTCLogging.h" |
tkchin | 42f580e | 2015-11-26 23:18:23 -0800 | [diff] [blame] | 12 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame^] | 13 | #include "rtc_base/logging.h" |
tkchin | 42f580e | 2015-11-26 23:18:23 -0800 | [diff] [blame] | 14 | |
| 15 | rtc::LoggingSeverity RTCGetNativeLoggingSeverity(RTCLoggingSeverity severity) { |
| 16 | switch (severity) { |
tkchin | 8b9ca95 | 2016-03-31 12:08:03 -0700 | [diff] [blame] | 17 | case RTCLoggingSeverityVerbose: |
tkchin | 42f580e | 2015-11-26 23:18:23 -0800 | [diff] [blame] | 18 | return rtc::LS_VERBOSE; |
tkchin | 8b9ca95 | 2016-03-31 12:08:03 -0700 | [diff] [blame] | 19 | case RTCLoggingSeverityInfo: |
tkchin | 42f580e | 2015-11-26 23:18:23 -0800 | [diff] [blame] | 20 | return rtc::LS_INFO; |
tkchin | 8b9ca95 | 2016-03-31 12:08:03 -0700 | [diff] [blame] | 21 | case RTCLoggingSeverityWarning: |
tkchin | 42f580e | 2015-11-26 23:18:23 -0800 | [diff] [blame] | 22 | return rtc::LS_WARNING; |
tkchin | 8b9ca95 | 2016-03-31 12:08:03 -0700 | [diff] [blame] | 23 | case RTCLoggingSeverityError: |
tkchin | 42f580e | 2015-11-26 23:18:23 -0800 | [diff] [blame] | 24 | return rtc::LS_ERROR; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | void RTCLogEx(RTCLoggingSeverity severity, NSString* log_string) { |
| 29 | if (log_string.length) { |
| 30 | const char* utf8_string = log_string.UTF8String; |
| 31 | LOG_V(RTCGetNativeLoggingSeverity(severity)) << utf8_string; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity) { |
| 36 | rtc::LogMessage::LogToDebug(RTCGetNativeLoggingSeverity(severity)); |
| 37 | } |
| 38 | |
| 39 | NSString* RTCFileName(const char* file_path) { |
| 40 | NSString* ns_file_path = |
| 41 | [[NSString alloc] initWithBytesNoCopy:const_cast<char*>(file_path) |
| 42 | length:strlen(file_path) |
| 43 | encoding:NSUTF8StringEncoding |
| 44 | freeWhenDone:NO]; |
| 45 | return ns_file_path.lastPathComponent; |
| 46 | } |
| 47 | |