OLD | NEW |
| (Empty) |
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 <Foundation/Foundation.h> | |
12 | |
13 #import "webrtc/base/objc/RTCMacros.h" | |
14 | |
15 // Subset of rtc::LoggingSeverity. | |
16 typedef NS_ENUM(NSInteger, RTCLoggingSeverity) { | |
17 RTCLoggingSeverityVerbose, | |
18 RTCLoggingSeverityInfo, | |
19 RTCLoggingSeverityWarning, | |
20 RTCLoggingSeverityError, | |
21 }; | |
22 | |
23 // Wrapper for C++ LOG(sev) macros. | |
24 // Logs the log string to the webrtc logstream for the given severity. | |
25 RTC_EXTERN void RTCLogEx(RTCLoggingSeverity severity, NSString* log_string); | |
26 | |
27 // Wrapper for rtc::LogMessage::LogToDebug. | |
28 // Sets the minimum severity to be logged to console. | |
29 RTC_EXTERN void RTCSetMinDebugLogLevel(RTCLoggingSeverity severity); | |
30 | |
31 // Returns the filename with the path prefix removed. | |
32 RTC_EXTERN NSString* RTCFileName(const char* filePath); | |
33 | |
34 // Some convenience macros. | |
35 | |
36 #define RTCLogString(format, ...) \ | |
37 [NSString stringWithFormat:@"(%@:%d %s): " format, \ | |
38 RTCFileName(__FILE__), \ | |
39 __LINE__, \ | |
40 __FUNCTION__, \ | |
41 ##__VA_ARGS__] | |
42 | |
43 #define RTCLogFormat(severity, format, ...) \ | |
44 do { \ | |
45 NSString* log_string = RTCLogString(format, ##__VA_ARGS__); \ | |
46 RTCLogEx(severity, log_string); \ | |
47 } while (false) | |
48 | |
49 #define RTCLogVerbose(format, ...) \ | |
50 RTCLogFormat(RTCLoggingSeverityVerbose, format, ##__VA_ARGS__) \ | |
51 | |
52 #define RTCLogInfo(format, ...) \ | |
53 RTCLogFormat(RTCLoggingSeverityInfo, format, ##__VA_ARGS__) \ | |
54 | |
55 #define RTCLogWarning(format, ...) \ | |
56 RTCLogFormat(RTCLoggingSeverityWarning, format, ##__VA_ARGS__) \ | |
57 | |
58 #define RTCLogError(format, ...) \ | |
59 RTCLogFormat(RTCLoggingSeverityError, format, ##__VA_ARGS__) \ | |
60 | |
61 #if !defined(NDEBUG) | |
62 #define RTCLogDebug(format, ...) RTCLogInfo(format, ##__VA_ARGS__) | |
63 #else | |
64 #define RTCLogDebug(format, ...) \ | |
65 do { \ | |
66 } while (false) | |
67 #endif | |
68 | |
69 #define RTCLog(format, ...) RTCLogInfo(format, ##__VA_ARGS__) | |
OLD | NEW |