GACAppCheckLogger.m 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright 2020 Google LLC
  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 "AppCheck/Sources/Core/GACAppCheckLogger.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. #pragma mark - Log Message Codes
  19. NSString *const kGACLoggerAppCheckMessageCodeUnknown = @"I-FAA001001";
  20. // GACAppCheck.m
  21. NSString *const kGACLoggerAppCheckMessageCodeProviderIsMissing = @"I-FAA002002";
  22. // GACAppCheckAPIService.m
  23. NSString *const kGACLoggerAppCheckMessageCodeUnexpectedHTTPCode = @"I-FAA003001";
  24. // GACAppCheckDebugProvider.m
  25. NSString *const kGACLoggerAppCheckMessageDebugProviderFailedExchange = @"I-FAA004002";
  26. // GACAppAttestProvider.m
  27. NSString *const kGACLoggerAppCheckMessageCodeAppAttestNotSupported = @"I-FAA007001";
  28. NSString *const kGACLoggerAppCheckMessageCodeAttestationRejected = @"I-FAA007002";
  29. #pragma mark - Logging Functions
  30. /**
  31. * Generates the logging functions using macros.
  32. *
  33. * Calling GACLogError(@"Firebase", @"I-GAC000001", @"Configure %@ failed.", @"blah") shows:
  34. * yyyy-mm-dd hh:mm:ss.SSS sender[PID] <Error> [Firebase/AppCheck][I-GAC000001] Configure blah
  35. * failed. Calling GACLogDebug(@"GoogleSignIn", @"I-GAC000002", @"Configure succeed.") shows:
  36. * yyyy-mm-dd hh:mm:ss.SSS sender[PID] <Debug> [GoogleSignIn/AppCheck][I-COR000002] Configure
  37. * succeed.
  38. */
  39. #define GAC_LOGGING_FUNCTION(level) \
  40. void GACLog##level(NSString *messageCode, NSString *format, ...) { \
  41. va_list args_ptr; \
  42. va_start(args_ptr, format); \
  43. NSString *message = [[NSString alloc] initWithFormat:format arguments:args_ptr]; \
  44. va_end(args_ptr); \
  45. NSLog(@"<" #level "> [AppCheck][%@] %@", messageCode, message); \
  46. }
  47. GAC_LOGGING_FUNCTION(Error)
  48. GAC_LOGGING_FUNCTION(Warning)
  49. GAC_LOGGING_FUNCTION(Notice)
  50. GAC_LOGGING_FUNCTION(Info)
  51. GAC_LOGGING_FUNCTION(Debug)
  52. #undef GAC_LOGGING_FUNCTION
  53. NS_ASSUME_NONNULL_END