FUtilities.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. #import <FirebaseCore/FIRLogger.h>
  18. #import "FParsedUrl.h"
  19. @interface FUtilities : NSObject
  20. + (NSArray *) splitString:(NSString *)str intoMaxSize:(const unsigned int)size;
  21. + (NSNumber *) LUIDGenerator;
  22. + (FParsedUrl *) parseUrl:(NSString *)url;
  23. + (NSString *) getJavascriptType:(id)obj;
  24. + (NSError *) errorForStatus:(NSString *)status andReason:(NSString *)reason;
  25. + (NSNumber *) intForString:(NSString *)string;
  26. + (NSString *) ieee754StringForNumber:(NSNumber *)val;
  27. + (void) setLoggingEnabled:(BOOL)enabled;
  28. + (BOOL) getLoggingEnabled;
  29. + (NSString*) minName;
  30. + (NSString*) maxName;
  31. + (NSComparisonResult) compareKey:(NSString *)a toKey:(NSString *)b;
  32. + (NSComparator) stringComparator;
  33. + (NSComparator) keyComparator;
  34. + (double)randomDouble;
  35. @end
  36. typedef enum {
  37. FLogLevelDebug = 1,
  38. FLogLevelInfo = 2,
  39. FLogLevelWarn = 3,
  40. FLogLevelError = 4,
  41. FLogLevelNone = 5
  42. } FLogLevel;
  43. // Log tags
  44. FOUNDATION_EXPORT NSString *const kFPersistenceLogTag;
  45. #define FFLog(code, format, ...) FFDebug((code), (format), ##__VA_ARGS__)
  46. #define FFDebug(code, format, ...) do { \
  47. if (FFIsLoggingEnabled(FLogLevelDebug)) { \
  48. FIRLogDebug(kFIRLoggerDatabase, (code), (format), ##__VA_ARGS__); \
  49. } \
  50. } while(0)
  51. #define FFInfo(code, format, ...) do { \
  52. if (FFIsLoggingEnabled(FLogLevelInfo)) { \
  53. FIRLogError(kFIRLoggerDatabase, (code), (format), ##__VA_ARGS__); \
  54. } \
  55. } while(0)
  56. #define FFWarn(code, format, ...) do { \
  57. if (FFIsLoggingEnabled(FLogLevelWarn)) { \
  58. FIRLogWarning(kFIRLoggerDatabase, (code), (format), ##__VA_ARGS__); \
  59. } \
  60. } while(0)
  61. extern FIRLoggerService kFIRLoggerDatabase;
  62. BOOL FFIsLoggingEnabled(FLogLevel logLevel);
  63. void firebaseUncaughtExceptionHandler(NSException *exception);
  64. void firebaseJobsTroll(void);