RTCCallbackLogger.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #import <Foundation/Foundation.h>
  11. #import "RTCLogging.h"
  12. #import "RTCMacros.h"
  13. NS_ASSUME_NONNULL_BEGIN
  14. typedef void (^RTCCallbackLoggerMessageHandler)(NSString *message);
  15. typedef void (^RTCCallbackLoggerMessageAndSeverityHandler)(NSString *message,
  16. RTCLoggingSeverity severity);
  17. // This class intercepts WebRTC logs and forwards them to a registered block.
  18. // This class is not threadsafe.
  19. RTC_OBJC_EXPORT
  20. @interface RTC_OBJC_TYPE (RTCCallbackLogger) : NSObject
  21. // The severity level to capture. The default is kRTCLoggingSeverityInfo.
  22. @property(nonatomic, assign) RTCLoggingSeverity severity;
  23. // The callback handler will be called on the same thread that does the
  24. // logging, so if the logging callback can be slow it may be a good idea
  25. // to implement dispatching to some other queue.
  26. - (void)start:(nullable RTCCallbackLoggerMessageHandler)handler;
  27. - (void)startWithMessageAndSeverityHandler:
  28. (nullable RTCCallbackLoggerMessageAndSeverityHandler)handler;
  29. - (void)stop;
  30. @end
  31. NS_ASSUME_NONNULL_END