FPRDiagnostics.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2020 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #import <Foundation/Foundation.h>
  15. #import "FirebasePerformance/Sources/FPRConsoleLogger.h"
  16. /** Logs assert information. This shouldn't be called by anything except FPRAssert.
  17. *
  18. * @param object The object (or class) that is asserting.
  19. * @param condition The condition that is being asserted to be true.
  20. * @param func The value of the __func__ variable.
  21. */
  22. FOUNDATION_EXTERN void __FPRAssert(id object, BOOL condition, const char *func);
  23. /** This protocol defines the selectors that are invoked when a diagnostics event occurs. */
  24. @protocol FPRDiagnosticsProtocol
  25. @optional
  26. /** Emits class-level diagnostic information. */
  27. + (void)emitDiagnostics;
  28. /** Emits object-level diagnostic information. */
  29. - (void)emitDiagnostics;
  30. @end
  31. // Use this define in implementations of +/-emitDiagnostics.
  32. #define EMIT_DIAGNOSTIC(...) FPRLogNotice(kFPRDiagnosticLog, __VA_ARGS__)
  33. // This assert adds additional functionality to the normal NSAssert, including printing out
  34. // information when NSAsserts are stripped. A __builtin_expect is utilized to keep running speed
  35. // as fast as possible.
  36. #define FPRAssert(condition, ...) \
  37. do { \
  38. __FPRAssert(self, !!(condition), __func__); \
  39. NSAssert(condition, __VA_ARGS__); \
  40. } while (0);
  41. /** This class handles the control of diagnostics in the SDK. */
  42. @interface FPRDiagnostics : NSObject
  43. /** YES if diagnostics are enabled, NO otherwise. */
  44. @property(class, nonatomic, readonly, getter=isEnabled) BOOL enabled;
  45. @end