2 * Copyright 2017 Google
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #import "FIRMessagingLogger.h"
19 #import <FirebaseCore/FIRLogger.h>
21 @implementation FIRMessagingLogger
23 + (instancetype)standardLogger {
24 return [[FIRMessagingLogger alloc] init];
27 #pragma mark - Log Helpers
29 + (NSString *)formatMessageCode:(FIRMessagingMessageCode)messageCode {
30 return [NSString stringWithFormat:@"I-FCM%06ld", (long)messageCode];
33 - (void)logFuncDebug:(const char *)func
34 messageCode:(FIRMessagingMessageCode)messageCode
35 msg:(NSString *)fmt, ... {
38 FIRLogBasic(FIRLoggerLevelDebug, kFIRLoggerMessaging,
39 [FIRMessagingLogger formatMessageCode:messageCode], fmt, args);
43 - (void)logFuncInfo:(const char *)func
44 messageCode:(FIRMessagingMessageCode)messageCode
45 msg:(NSString *)fmt, ... {
48 FIRLogBasic(FIRLoggerLevelInfo, kFIRLoggerMessaging,
49 [FIRMessagingLogger formatMessageCode:messageCode], fmt, args);
53 - (void)logFuncNotice:(const char *)func
54 messageCode:(FIRMessagingMessageCode)messageCode
55 msg:(NSString *)fmt, ... {
58 FIRLogBasic(FIRLoggerLevelNotice, kFIRLoggerMessaging,
59 [FIRMessagingLogger formatMessageCode:messageCode], fmt, args);
63 - (void)logFuncWarning:(const char *)func
64 messageCode:(FIRMessagingMessageCode)messageCode
65 msg:(NSString *)fmt, ... {
68 FIRLogBasic(FIRLoggerLevelWarning, kFIRLoggerMessaging,
69 [FIRMessagingLogger formatMessageCode:messageCode], fmt, args);
73 - (void)logFuncError:(const char *)func
74 messageCode:(FIRMessagingMessageCode)messageCode
75 msg:(NSString *)fmt, ... {
78 FIRLogBasic(FIRLoggerLevelError, kFIRLoggerMessaging,
79 [FIRMessagingLogger formatMessageCode:messageCode], fmt, args);
85 FIRMessagingLogger *FIRMessagingSharedLogger(void) {
86 static dispatch_once_t onceToken;
87 static FIRMessagingLogger *logger;
88 dispatch_once(&onceToken, ^{
89 logger = [FIRMessagingLogger standardLogger];