Няма описание

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2019 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 "FIRInstanceIDLogger.h"
  17. #import <FirebaseCore/FIRLogger.h>
  18. // Re-definition of FIRLogger service, as it is not included in :FIRAppHeaders target
  19. NSString *const kFIRInstanceIDLoggerService = @"[Firebase/InstanceID]";
  20. @implementation FIRInstanceIDLogger
  21. #pragma mark - Log Helpers
  22. + (NSString *)formatMessageCode:(FIRInstanceIDMessageCode)messageCode {
  23. return [NSString stringWithFormat:@"I-IID%06ld", (long)messageCode];
  24. }
  25. - (void)logFuncDebug:(const char *)func
  26. messageCode:(FIRInstanceIDMessageCode)messageCode
  27. msg:(NSString *)fmt, ... {
  28. va_list args;
  29. va_start(args, fmt);
  30. FIRLogBasic(FIRLoggerLevelDebug, kFIRInstanceIDLoggerService,
  31. [FIRInstanceIDLogger formatMessageCode:messageCode], fmt, args);
  32. va_end(args);
  33. }
  34. - (void)logFuncInfo:(const char *)func
  35. messageCode:(FIRInstanceIDMessageCode)messageCode
  36. msg:(NSString *)fmt, ... {
  37. va_list args;
  38. va_start(args, fmt);
  39. FIRLogBasic(FIRLoggerLevelInfo, kFIRInstanceIDLoggerService,
  40. [FIRInstanceIDLogger formatMessageCode:messageCode], fmt, args);
  41. va_end(args);
  42. }
  43. - (void)logFuncNotice:(const char *)func
  44. messageCode:(FIRInstanceIDMessageCode)messageCode
  45. msg:(NSString *)fmt, ... {
  46. va_list args;
  47. va_start(args, fmt);
  48. FIRLogBasic(FIRLoggerLevelNotice, kFIRInstanceIDLoggerService,
  49. [FIRInstanceIDLogger formatMessageCode:messageCode], fmt, args);
  50. va_end(args);
  51. }
  52. - (void)logFuncWarning:(const char *)func
  53. messageCode:(FIRInstanceIDMessageCode)messageCode
  54. msg:(NSString *)fmt, ... {
  55. va_list args;
  56. va_start(args, fmt);
  57. FIRLogBasic(FIRLoggerLevelWarning, kFIRInstanceIDLoggerService,
  58. [FIRInstanceIDLogger formatMessageCode:messageCode], fmt, args);
  59. va_end(args);
  60. }
  61. - (void)logFuncError:(const char *)func
  62. messageCode:(FIRInstanceIDMessageCode)messageCode
  63. msg:(NSString *)fmt, ... {
  64. va_list args;
  65. va_start(args, fmt);
  66. FIRLogBasic(FIRLoggerLevelError, kFIRInstanceIDLoggerService,
  67. [FIRInstanceIDLogger formatMessageCode:messageCode], fmt, args);
  68. va_end(args);
  69. }
  70. @end
  71. FIRInstanceIDLogger *FIRInstanceIDSharedLogger() {
  72. static dispatch_once_t onceToken;
  73. static FIRInstanceIDLogger *logger;
  74. dispatch_once(&onceToken, ^{
  75. logger = [[FIRInstanceIDLogger alloc] init];
  76. });
  77. return logger;
  78. }