GDTCORConsoleLogger.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * Copyright 2018 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. // Set this to 1 to have the library print out as much as possible about what GDT is doing.
  18. #define GDT_VERBOSE_LOGGING 0
  19. /** A list of message codes to print in the logger that help to correspond printed messages with
  20. * code locations.
  21. *
  22. * Prefixes:
  23. * - MCW => MessageCodeWarning
  24. * - MCE => MessageCodeError
  25. */
  26. typedef NS_ENUM(NSInteger, GDTCORMessageCode) {
  27. /** For warning messages concerning transportBytes: not being implemented by a data object. */
  28. GDTCORMCWDataObjectMissingBytesImpl = 1,
  29. /** For warning messages concerning a failed event upload. */
  30. GDTCORMCWUploadFailed = 2,
  31. /** For warning messages concerning a forced event upload. */
  32. GDTCORMCWForcedUpload = 3,
  33. /** For warning messages concerning a failed reachability call. */
  34. GDTCORMCWReachabilityFailed = 4,
  35. /** For error messages concerning transform: not being implemented by an event transformer. */
  36. GDTCORMCETransformerDoesntImplementTransform = 1000,
  37. /** For error messages concerning the creation of a directory failing. */
  38. GDTCORMCEDirectoryCreationError = 1001,
  39. /** For error messages concerning the writing of a event file. */
  40. GDTCORMCEFileWriteError = 1002,
  41. /** For error messages concerning the lack of a prioritizer for a given backend. */
  42. GDTCORMCEPrioritizerError = 1003,
  43. /** For error messages concerning a package delivery API violation. */
  44. GDTCORMCEDeliverTwice = 1004,
  45. /** For error messages concerning an error in an implementation of -transportBytes. */
  46. GDTCORMCETransportBytesError = 1005,
  47. /** For general purpose error messages in a dependency. */
  48. GDTCORMCEGeneralError = 1006,
  49. /** For fatal errors. Please go to https://github.com/firebase/firebase-ios-sdk/issues and open
  50. * an issue if you encounter an error with this code.
  51. */
  52. GDTCORMCEFatalAssertion = 1007
  53. };
  54. /** */
  55. FOUNDATION_EXPORT
  56. void GDTCORLog(GDTCORMessageCode code, NSString *_Nonnull format, ...);
  57. /** Returns the string that represents some message code.
  58. *
  59. * @param code The code to convert to a string.
  60. * @return The string representing the message code.
  61. */
  62. FOUNDATION_EXPORT NSString *_Nonnull GDTCORMessageCodeEnumToString(GDTCORMessageCode code);
  63. // A define to wrap GULLogWarning with slightly more convenient usage.
  64. #define GDTCORLogWarning(MESSAGE_CODE, MESSAGE_FORMAT, ...) \
  65. GDTCORLog(MESSAGE_CODE, MESSAGE_FORMAT, __VA_ARGS__);
  66. // A define to wrap GULLogError with slightly more convenient usage and a failing assert.
  67. #define GDTCORLogError(MESSAGE_CODE, MESSAGE_FORMAT, ...) \
  68. GDTCORLog(MESSAGE_CODE, MESSAGE_FORMAT, __VA_ARGS__);
  69. // A define to wrap NSLog for verbose console logs only useful for local debugging.
  70. #if GDT_VERBOSE_LOGGING == 1
  71. #define GDTCORLogDebug(FORMAT, ...) NSLog(@"GDT: " FORMAT, __VA_ARGS__);
  72. #else
  73. #define GDTCORLogDebug(...)
  74. #endif // GDT_VERBOSE_LOGGING == 1