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 |
/** The current logging level. This value and higher will be printed. Declared as volatile to make |
|
20 |
* getting and setting atomic. |
|
21 |
*/ |
|
22 |
FOUNDATION_EXPORT volatile NSInteger GDTCORConsoleLoggerLoggingLevel; |
|
23 |
|
|
24 |
/** A list of logging levels that GDT supports. */ |
|
25 |
typedef NS_ENUM(NSInteger, GDTCORLoggingLevel) { |
|
26 |
|
|
27 |
/** Causes all logs to be printed. */ |
|
28 |
GDTCORLoggingLevelDebug = 1, |
|
29 |
|
|
30 |
/** Causes all non-debug logs to be printed. */ |
|
31 |
GDTCORLoggingLevelVerbose = 2, |
|
32 |
|
|
33 |
/** Causes warnings and errors to be printed. */ |
|
34 |
GDTCORLoggingLevelWarnings = 3, |
|
35 |
|
|
36 |
/** Causes errors to be printed. This is the default value. */ |
|
37 |
GDTCORLoggingLevelErrors = 4 |
|
38 |
}; |
|
39 |
|
|
40 |
/** A list of message codes to print in the logger that help to correspond printed messages with |
|
41 |
* code locations. |
|
42 |
* |
|
43 |
* Prefixes: |
|
44 |
* - MCD => MessageCodeDebug |
|
45 |
* - MCW => MessageCodeWarning |
|
46 |
* - MCE => MessageCodeError |
|
47 |
*/ |
|
48 |
typedef NS_ENUM(NSInteger, GDTCORMessageCode) { |
|
49 |
|
|
50 |
/** For debug logs. */ |
|
51 |
GDTCORMCDDebugLog = 0, |
|
52 |
|
|
53 |
/** For warning messages concerning transportBytes: not being implemented by a data object. */ |
|
54 |
GDTCORMCWDataObjectMissingBytesImpl = 1, |
|
55 |
|
|
56 |
/** For warning messages concerning a failed event upload. */ |
|
57 |
GDTCORMCWUploadFailed = 2, |
|
58 |
|
|
59 |
/** For warning messages concerning a forced event upload. */ |
|
60 |
GDTCORMCWForcedUpload = 3, |
|
61 |
|
|
62 |
/** For warning messages concerning a failed reachability call. */ |
|
63 |
GDTCORMCWReachabilityFailed = 4, |
|
64 |
|
|
65 |
/** For warning messages concerning a database warning. */ |
|
66 |
GDTCORMCWDatabaseWarning = 5, |
|
67 |
|
|
68 |
/** For warning messages concerning the reading of a event file. */ |
|
69 |
GDTCORMCWFileReadError = 6, |
|
70 |
|
df1e8e
|
71 |
/** For error messages concerning transformGDTEvent: not being implemented by an event |
L |
72 |
transformer. */ |
a6c014
|
73 |
GDTCORMCETransformerDoesntImplementTransform = 1000, |
L |
74 |
|
|
75 |
/** For error messages concerning the creation of a directory failing. */ |
|
76 |
GDTCORMCEDirectoryCreationError = 1001, |
|
77 |
|
|
78 |
/** For error messages concerning the writing of a event file. */ |
|
79 |
GDTCORMCEFileWriteError = 1002, |
|
80 |
|
|
81 |
/** For error messages concerning the lack of a prioritizer for a given backend. */ |
|
82 |
GDTCORMCEPrioritizerError = 1003, |
|
83 |
|
|
84 |
/** For error messages concerning a package delivery API violation. */ |
|
85 |
GDTCORMCEDeliverTwice = 1004, |
|
86 |
|
|
87 |
/** For error messages concerning an error in an implementation of -transportBytes. */ |
|
88 |
GDTCORMCETransportBytesError = 1005, |
|
89 |
|
|
90 |
/** For general purpose error messages in a dependency. */ |
|
91 |
GDTCORMCEGeneralError = 1006, |
|
92 |
|
|
93 |
/** For fatal errors. Please go to https://github.com/firebase/firebase-ios-sdk/issues and open |
|
94 |
* an issue if you encounter an error with this code. |
|
95 |
*/ |
|
96 |
GDTCORMCEFatalAssertion = 1007, |
|
97 |
|
|
98 |
/** For error messages concerning the reading of a event file. */ |
|
99 |
GDTCORMCEFileReadError = 1008, |
|
100 |
|
|
101 |
/** For errors related to running sqlite. */ |
|
102 |
GDTCORMCEDatabaseError = 1009, |
|
103 |
}; |
|
104 |
|
|
105 |
/** Prints the given code and format string to the console. |
|
106 |
* |
|
107 |
* @param code The message code describing the nature of the log. |
|
108 |
* @param logLevel The log level of this log. |
|
109 |
* @param format The format string. |
|
110 |
*/ |
|
111 |
FOUNDATION_EXPORT |
|
112 |
void GDTCORLog(GDTCORMessageCode code, GDTCORLoggingLevel logLevel, NSString *_Nonnull format, ...) |
|
113 |
NS_FORMAT_FUNCTION(3, 4); |
|
114 |
|
|
115 |
/** Prints an assert log to the console. |
|
116 |
* |
|
117 |
* @param wasFatal Send YES if the assertion should be fatal, NO otherwise. |
|
118 |
* @param file The file in which the failure occurred. |
|
119 |
* @param line The line number of the failure. |
|
120 |
* @param format The format string. |
|
121 |
*/ |
|
122 |
FOUNDATION_EXPORT void GDTCORLogAssert(BOOL wasFatal, |
|
123 |
NSString *_Nonnull file, |
|
124 |
NSInteger line, |
|
125 |
NSString *_Nullable format, |
|
126 |
...) NS_FORMAT_FUNCTION(4, 5); |
|
127 |
|
|
128 |
/** Returns the string that represents some message code. |
|
129 |
* |
|
130 |
* @param code The code to convert to a string. |
|
131 |
* @return The string representing the message code. |
|
132 |
*/ |
|
133 |
FOUNDATION_EXPORT NSString *_Nonnull GDTCORMessageCodeEnumToString(GDTCORMessageCode code); |
|
134 |
|
|
135 |
#define GDTCORLogDebug(MESSAGE_FORMAT, ...) \ |
|
136 |
GDTCORLog(GDTCORMCDDebugLog, GDTCORLoggingLevelDebug, MESSAGE_FORMAT, __VA_ARGS__); |
|
137 |
|
|
138 |
// A define to wrap GULLogWarning with slightly more convenient usage. |
|
139 |
#define GDTCORLogWarning(MESSAGE_CODE, MESSAGE_FORMAT, ...) \ |
|
140 |
GDTCORLog(MESSAGE_CODE, GDTCORLoggingLevelWarnings, MESSAGE_FORMAT, __VA_ARGS__); |
|
141 |
|
|
142 |
// A define to wrap GULLogError with slightly more convenient usage and a failing assert. |
|
143 |
#define GDTCORLogError(MESSAGE_CODE, MESSAGE_FORMAT, ...) \ |
|
144 |
GDTCORLog(MESSAGE_CODE, GDTCORLoggingLevelErrors, MESSAGE_FORMAT, __VA_ARGS__); |