added iOS source code
[wl-app.git] / iOS / Pods / GoogleUtilities / GoogleUtilities / Logger / Private / GULLogger.h
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
17 #import <Foundation/Foundation.h>
18
19 #import <GoogleUtilities/GULLoggerLevel.h>
20
21 NS_ASSUME_NONNULL_BEGIN
22
23 /**
24  * The services used in the logger.
25  */
26 typedef NSString *const GULLoggerService;
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif  // __cplusplus
31
32 /**
33  * Initialize GULLogger.
34  */
35 extern void GULLoggerInitializeASL(void);
36
37 /**
38  * Override log level to Debug.
39  */
40 void GULLoggerForceDebug(void);
41
42 /**
43  * Turn on logging to STDERR.
44  */
45 extern void GULLoggerEnableSTDERR(void);
46
47 /**
48  * Changes the default logging level of GULLoggerLevelNotice to a user-specified level.
49  * The default level cannot be set above GULLoggerLevelNotice if the app is running from App Store.
50  * (required) log level (one of the GULLoggerLevel enum values).
51  */
52 extern void GULSetLoggerLevel(GULLoggerLevel loggerLevel);
53
54 /**
55  * Checks if the specified logger level is loggable given the current settings.
56  * (required) log level (one of the GULLoggerLevel enum values).
57  */
58 extern BOOL GULIsLoggableLevel(GULLoggerLevel loggerLevel);
59
60 /**
61  * Register version to include in logs.
62  * (required) version
63  */
64 extern void GULLoggerRegisterVersion(const char *version);
65
66 /**
67  * Logs a message to the Xcode console and the device log. If running from AppStore, will
68  * not log any messages with a level higher than GULLoggerLevelNotice to avoid log spamming.
69  * (required) log level (one of the GULLoggerLevel enum values).
70  * (required) service name of type GULLoggerService.
71  * (required) message code starting with "I-" which means iOS, followed by a capitalized
72  *            three-character service identifier and a six digit integer message ID that is unique
73  *            within the service.
74  *            An example of the message code is @"I-COR000001".
75  * (required) message string which can be a format string.
76  * (optional) variable arguments list obtained from calling va_start, used when message is a format
77  *            string.
78  */
79 extern void GULLogBasic(GULLoggerLevel level,
80                         GULLoggerService service,
81                         BOOL forceLog,
82                         NSString *messageCode,
83                         NSString *message,
84 // On 64-bit simulators, va_list is not a pointer, so cannot be marked nullable
85 // See: http://stackoverflow.com/q/29095469
86 #if __LP64__ && TARGET_OS_SIMULATOR || TARGET_OS_OSX
87                         va_list args_ptr
88 #else
89                         va_list _Nullable args_ptr
90 #endif
91 );
92
93 /**
94  * The following functions accept the following parameters in order:
95  * (required) service name of type GULLoggerService.
96  * (required) message code starting from "I-" which means iOS, followed by a capitalized
97  *            three-character service identifier and a six digit integer message ID that is unique
98  *            within the service.
99  *            An example of the message code is @"I-COR000001".
100  *            See go/firebase-log-proposal for details.
101  * (required) message string which can be a format string.
102  * (optional) the list of arguments to substitute into the format string.
103  * Example usage:
104  * GULLogError(kGULLoggerCore, @"I-COR000001", @"Configuration of %@ failed.", app.name);
105  */
106 extern void GULLogError(GULLoggerService service,
107                         BOOL force,
108                         NSString *messageCode,
109                         NSString *message,
110                         ...) NS_FORMAT_FUNCTION(4, 5);
111 extern void GULLogWarning(GULLoggerService service,
112                           BOOL force,
113                           NSString *messageCode,
114                           NSString *message,
115                           ...) NS_FORMAT_FUNCTION(4, 5);
116 extern void GULLogNotice(GULLoggerService service,
117                          BOOL force,
118                          NSString *messageCode,
119                          NSString *message,
120                          ...) NS_FORMAT_FUNCTION(4, 5);
121 extern void GULLogInfo(GULLoggerService service,
122                        BOOL force,
123                        NSString *messageCode,
124                        NSString *message,
125                        ...) NS_FORMAT_FUNCTION(4, 5);
126 extern void GULLogDebug(GULLoggerService service,
127                         BOOL force,
128                         NSString *messageCode,
129                         NSString *message,
130                         ...) NS_FORMAT_FUNCTION(4, 5);
131
132 #ifdef __cplusplus
133 }  // extern "C"
134 #endif  // __cplusplus
135
136 @interface GULLoggerWrapper : NSObject
137
138 /**
139  * Objective-C wrapper for GULLogBasic to allow weak linking to GULLogger
140  * (required) log level (one of the GULLoggerLevel enum values).
141  * (required) service name of type GULLoggerService.
142  * (required) message code starting with "I-" which means iOS, followed by a capitalized
143  *            three-character service identifier and a six digit integer message ID that is unique
144  *            within the service.
145  *            An example of the message code is @"I-COR000001".
146  * (required) message string which can be a format string.
147  * (optional) variable arguments list obtained from calling va_start, used when message is a format
148  *            string.
149  */
150
151 + (void)logWithLevel:(GULLoggerLevel)level
152          withService:(GULLoggerService)service
153             withCode:(NSString *)messageCode
154          withMessage:(NSString *)message
155             withArgs:(va_list)args;
156
157 @end
158
159 NS_ASSUME_NONNULL_END