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