FUtilities.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 <FirebaseCore/FIRLogger.h>
  17. #import <Foundation/Foundation.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, ...) \
  47. do { \
  48. if (FFIsLoggingEnabled(FLogLevelDebug)) { \
  49. FIRLogDebug(kFIRLoggerDatabase, (code), (format), ##__VA_ARGS__); \
  50. } \
  51. } while (0)
  52. #define FFInfo(code, format, ...) \
  53. do { \
  54. if (FFIsLoggingEnabled(FLogLevelInfo)) { \
  55. FIRLogError(kFIRLoggerDatabase, (code), (format), ##__VA_ARGS__); \
  56. } \
  57. } while (0)
  58. #define FFWarn(code, format, ...) \
  59. do { \
  60. if (FFIsLoggingEnabled(FLogLevelWarn)) { \
  61. FIRLogWarning(kFIRLoggerDatabase, (code), (format), \
  62. ##__VA_ARGS__); \
  63. } \
  64. } while (0)
  65. extern FIRLoggerService kFIRLoggerDatabase;
  66. BOOL FFIsLoggingEnabled(FLogLevel logLevel);
  67. void firebaseUncaughtExceptionHandler(NSException *exception);
  68. void firebaseJobsTroll(void);