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
11#import "RTCLogging.h"
12
13#include "rtc_base/logging.h"
14
15rtc::LoggingSeverity RTCGetNativeLoggingSeverity(RTCLoggingSeverity severity) {
16  switch (severity) {
17    case RTCLoggingSeverityVerbose:
18      return rtc::LS_VERBOSE;
19    case RTCLoggingSeverityInfo:
20      return rtc::LS_INFO;
21    case RTCLoggingSeverityWarning:
22      return rtc::LS_WARNING;
23    case RTCLoggingSeverityError:
24      return rtc::LS_ERROR;
25    case RTCLoggingSeverityNone:
26      return rtc::LS_NONE;
27  }
28}
29
30void RTCLogEx(RTCLoggingSeverity severity, NSString* log_string) {
31  if (log_string.length) {
32    const char* utf8_string = log_string.UTF8String;
33    RTC_LOG_V(RTCGetNativeLoggingSeverity(severity)) << utf8_string;
34  }
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}
49