GACAppCheckLogger.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright 2023 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 "FirebaseAppCheck/Sources/GAC/Core/GACAppCheckLogger.h"
  17. NS_ASSUME_NONNULL_BEGIN
  18. /**
  19. * Generates the logging functions using macros.
  20. *
  21. * Calling GACLogError(@"Firebase", @"I-GAC000001", @"Configure %@ failed.", @"blah") shows:
  22. * yyyy-mm-dd hh:mm:ss.SSS sender[PID] <Error> [Firebase/AppCheck][I-GAC000001] Configure blah
  23. * failed. Calling GACLogDebug(@"GoogleSignIn", @"I-GAC000002", @"Configure succeed.") shows:
  24. * yyyy-mm-dd hh:mm:ss.SSS sender[PID] <Debug> [GoogleSignIn/AppCheck][I-COR000002] Configure
  25. * succeed.
  26. */
  27. #define GAC_LOGGING_FUNCTION(level) \
  28. void GACLog##level(GACLoggerService service, NSString *messageCode, NSString *format, ...) { \
  29. va_list args_ptr; \
  30. va_start(args_ptr, format); \
  31. NSString *message = [[NSString alloc] initWithFormat:format arguments:args_ptr]; \
  32. va_end(args_ptr); \
  33. NSLog(@"<" #level "> [%@/AppCheck][%@] %@", service, messageCode, message); \
  34. }
  35. GAC_LOGGING_FUNCTION(Error)
  36. GAC_LOGGING_FUNCTION(Warning)
  37. GAC_LOGGING_FUNCTION(Notice)
  38. GAC_LOGGING_FUNCTION(Info)
  39. GAC_LOGGING_FUNCTION(Debug)
  40. #undef GAC_LOGGING_FUNCTION
  41. NS_ASSUME_NONNULL_END