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