| 1 | 
           efrain | 
           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 | 
              | 
        
        
            | 
            | 
           15 | 
           #import <Foundation/Foundation.h>
  | 
        
        
            | 
            | 
           16 | 
              | 
        
        
            | 
            | 
           17 | 
           #import "FirebasePerformance/Sources/FPRConsoleLogger.h"
  | 
        
        
            | 
            | 
           18 | 
              | 
        
        
            | 
            | 
           19 | 
           /** Logs assert information. This shouldn't be called by anything except FPRAssert.
  | 
        
        
            | 
            | 
           20 | 
            *
  | 
        
        
            | 
            | 
           21 | 
            *  @param object The object (or class) that is asserting.
  | 
        
        
            | 
            | 
           22 | 
            *  @param condition The condition that is being asserted to be true.
  | 
        
        
            | 
            | 
           23 | 
            *  @param func The value of the __func__ variable.
  | 
        
        
            | 
            | 
           24 | 
            */
  | 
        
        
            | 
            | 
           25 | 
           FOUNDATION_EXTERN void __FPRAssert(id object, BOOL condition, const char *func);
  | 
        
        
            | 
            | 
           26 | 
              | 
        
        
            | 
            | 
           27 | 
           /** This protocol defines the selectors that are invoked when a diagnostics event occurs. */
  | 
        
        
            | 
            | 
           28 | 
           @protocol FPRDiagnosticsProtocol
  | 
        
        
            | 
            | 
           29 | 
              | 
        
        
            | 
            | 
           30 | 
           @optional
  | 
        
        
            | 
            | 
           31 | 
              | 
        
        
            | 
            | 
           32 | 
           /** Emits class-level diagnostic information. */
  | 
        
        
            | 
            | 
           33 | 
           + (void)emitDiagnostics;
  | 
        
        
            | 
            | 
           34 | 
              | 
        
        
            | 
            | 
           35 | 
           /** Emits object-level diagnostic information. */
  | 
        
        
            | 
            | 
           36 | 
           - (void)emitDiagnostics;
  | 
        
        
            | 
            | 
           37 | 
              | 
        
        
            | 
            | 
           38 | 
           @end
  | 
        
        
            | 
            | 
           39 | 
              | 
        
        
            | 
            | 
           40 | 
           // Use this define in implementations of +/-emitDiagnostics.
  | 
        
        
            | 
            | 
           41 | 
           #define EMIT_DIAGNOSTIC(...) FPRLogNotice(kFPRDiagnosticLog, __VA_ARGS__)
  | 
        
        
            | 
            | 
           42 | 
              | 
        
        
            | 
            | 
           43 | 
           // This assert adds additional functionality to the normal NSAssert, including printing out
  | 
        
        
            | 
            | 
           44 | 
           // information when NSAsserts are stripped. A __builtin_expect is utilized to keep running speed
  | 
        
        
            | 
            | 
           45 | 
           // as fast as possible.
  | 
        
        
            | 
            | 
           46 | 
           #define FPRAssert(condition, ...)                 \
  | 
        
        
            | 
            | 
           47 | 
             {                                               \
  | 
        
        
            | 
            | 
           48 | 
               do {                                          \
  | 
        
        
            | 
            | 
           49 | 
                 __FPRAssert(self, !!(condition), __func__); \
  | 
        
        
            | 
            | 
           50 | 
                 NSAssert(condition, __VA_ARGS__);           \
  | 
        
        
            | 
            | 
           51 | 
               } while (0);                                  \
  | 
        
        
            | 
            | 
           52 | 
             }
  | 
        
        
            | 
            | 
           53 | 
              | 
        
        
            | 
            | 
           54 | 
           /** This class handles the control of diagnostics in the SDK. */
  | 
        
        
            | 
            | 
           55 | 
           @interface FPRDiagnostics : NSObject
  | 
        
        
            | 
            | 
           56 | 
              | 
        
        
            | 
            | 
           57 | 
           /** YES if diagnostics are enabled, NO otherwise. */
  | 
        
        
            | 
            | 
           58 | 
           @property(class, nonatomic, readonly, getter=isEnabled) BOOL enabled;
  | 
        
        
            | 
            | 
           59 | 
              | 
        
        
            | 
            | 
           60 | 
           @end
  |