blob: e8dae02efb78b7dfb90fb89779fdaf0a664804b0 [file] [log] [blame]
tkchin42f580e2015-11-26 23:18:23 -08001/*
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
Anders Carlsson7bca8ca2018-08-30 09:30:29 +020011#import "RTCLogging.h"
tkchin42f580e2015-11-26 23:18:23 -080012
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "rtc_base/logging.h"
tkchin42f580e2015-11-26 23:18:23 -080014
15rtc::LoggingSeverity RTCGetNativeLoggingSeverity(RTCLoggingSeverity severity) {
16 switch (severity) {
tkchin8b9ca952016-03-31 12:08:03 -070017 case RTCLoggingSeverityVerbose:
tkchin42f580e2015-11-26 23:18:23 -080018 return rtc::LS_VERBOSE;
tkchin8b9ca952016-03-31 12:08:03 -070019 case RTCLoggingSeverityInfo:
tkchin42f580e2015-11-26 23:18:23 -080020 return rtc::LS_INFO;
tkchin8b9ca952016-03-31 12:08:03 -070021 case RTCLoggingSeverityWarning:
tkchin42f580e2015-11-26 23:18:23 -080022 return rtc::LS_WARNING;
tkchin8b9ca952016-03-31 12:08:03 -070023 case RTCLoggingSeverityError:
tkchin42f580e2015-11-26 23:18:23 -080024 return rtc::LS_ERROR;
Peter Hanspersd419db92018-10-15 22:47:38 +020025 case RTCLoggingSeverityNone:
26 return rtc::LS_NONE;
tkchin42f580e2015-11-26 23:18:23 -080027 }
28}
29
30void RTCLogEx(RTCLoggingSeverity severity, NSString* log_string) {
31 if (log_string.length) {
32 const char* utf8_string = log_string.UTF8String;
Mirko Bonadei675513b2017-11-09 11:09:25 +010033 RTC_LOG_V(RTCGetNativeLoggingSeverity(severity)) << utf8_string;
tkchin42f580e2015-11-26 23:18:23 -080034 }
35}
36
37void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity) {
38 rtc::LogMessage::LogToDebug(RTCGetNativeLoggingSeverity(severity));
39}
40
41NSString* RTCFileName(const char* file_path) {
42 NSString* ns_file_path =
43 [[NSString alloc] initWithBytesNoCopy:const_cast<char*>(file_path)
44 length:strlen(file_path)
45 encoding:NSUTF8StringEncoding
46 freeWhenDone:NO];
47 return ns_file_path.lastPathComponent;
48}