Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2018 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 "RTCLogging.h" |
| 14 | #import "RTCMacros.h" |
| 15 | |
| 16 | NS_ASSUME_NONNULL_BEGIN |
| 17 | |
Jiawei Ou | 3ea1878 | 2018-10-31 23:14:24 -0700 | [diff] [blame] | 18 | typedef void (^RTCCallbackLoggerMessageHandler)(NSString *message); |
| 19 | typedef void (^RTCCallbackLoggerMessageAndSeverityHandler)(NSString *message, |
| 20 | RTCLoggingSeverity severity); |
| 21 | |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 22 | // This class intercepts WebRTC logs and forwards them to a registered block. |
| 23 | // This class is not threadsafe. |
Mirko Bonadei | e8d5724 | 2018-09-17 10:22:56 +0200 | [diff] [blame] | 24 | RTC_OBJC_EXPORT |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 25 | @interface RTCCallbackLogger : NSObject |
| 26 | |
| 27 | // The severity level to capture. The default is kRTCLoggingSeverityInfo. |
| 28 | @property(nonatomic, assign) RTCLoggingSeverity severity; |
| 29 | |
Jiawei Ou | 3ea1878 | 2018-10-31 23:14:24 -0700 | [diff] [blame] | 30 | // The callback handler will be called on the same thread that does the |
| 31 | // logging, so if the logging callback can be slow it may be a good idea |
| 32 | // to implement dispatching to some other queue. |
| 33 | - (void)start:(nullable RTCCallbackLoggerMessageHandler)handler; |
| 34 | - (void)startWithMessageAndSeverityHandler: |
| 35 | (nullable RTCCallbackLoggerMessageAndSeverityHandler)handler; |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 36 | |
| 37 | - (void)stop; |
| 38 | |
| 39 | @end |
| 40 | |
| 41 | NS_ASSUME_NONNULL_END |