Skip to content

Commit 995b9dc

Browse files
authored
Remove the GULLogger dependency (#2703)
* Remove the GULLogger dependency Wrote a quick console logging function that will log to the console in debug mode. * Style
1 parent ff85a57 commit 995b9dc

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

GoogleDataTransport.podspec

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ Shared library for iOS SDK data transport needs.
2727
s.public_header_files = 'GoogleDataTransport/GoogleDataTransport/Classes/Public/*.h'
2828
s.private_header_files = 'GoogleDataTransport/GoogleDataTransport/Classes/Private/*.h'
2929

30-
s.dependency 'GoogleUtilities/Logger'
31-
3230
s.pod_target_xcconfig = {
3331
'GCC_C_LANGUAGE_STANDARD' => 'c99',
3432
'GCC_TREAT_WARNINGS_AS_ERRORS' => 'YES',

GoogleDataTransport/GoogleDataTransport/DependencyWrappers/GDTConsoleLogger.m renamed to GoogleDataTransport/GoogleDataTransport/Classes/GDTConsoleLogger.m

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616

1717
#import "GDTConsoleLogger.h"
1818

19-
NSString* GDTMessageCodeEnumToString(GDTMessageCode code) {
19+
/** The console logger prefix. */
20+
static NSString *kGDTConsoleLogger = @"[GoogleDataTransport]";
21+
22+
NSString *GDTMessageCodeEnumToString(GDTMessageCode code) {
2023
return [[NSString alloc] initWithFormat:@"I-GDT%06ld", (long)code];
2124
}
25+
26+
void GDTLog(GDTMessageCode code, NSString *format, ...) {
27+
// Don't log anything in not debug builds.
28+
#ifndef NDEBUG
29+
NSString *logFormat = [NSString
30+
stringWithFormat:@"%@[%@] %@", kGDTConsoleLogger, GDTMessageCodeEnumToString(code), format];
31+
va_list args;
32+
va_start(args, format);
33+
NSLogv(logFormat, args);
34+
va_end(args);
35+
#endif // NDEBUG
36+
}

GoogleDataTransport/GoogleDataTransport/DependencyWrappers/GDTConsoleLogger.h renamed to GoogleDataTransport/GoogleDataTransport/Classes/Private/GDTConsoleLogger.h

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
#import "GULLogger.h"
18-
1917
#import "GDTAssert.h"
2018

21-
/** The console logger prefix. */
22-
static GULLoggerService kGDTConsoleLogger = @"[GoogleDataTransport]";
23-
2419
/** A list of message codes to print in the logger that help to correspond printed messages with
2520
* code locations.
2621
*
@@ -50,23 +45,21 @@ typedef NS_ENUM(NSInteger, GDTMessageCode) {
5045
};
5146

5247
/** */
53-
FOUNDATION_EXPORT NSString *_Nonnull GDTMessageCodeEnumToString(GDTMessageCode code);
48+
FOUNDATION_EXPORT
49+
void GDTLog(GDTMessageCode code, NSString *format, ...);
5450

55-
/** Logs the warningMessage string to the console at the warning level.
51+
/** Returns the string that represents some message code.
5652
*
57-
* @param warningMessageFormat The format string to log to the console.
53+
* @param code The code to convert to a string.
54+
* @return The string representing the message code.
5855
*/
59-
FOUNDATION_EXPORT void GDTLogWarning(GDTMessageCode messageCode,
60-
NSString *_Nonnull warningMessageFormat,
61-
...) NS_FORMAT_FUNCTION(2, 3);
56+
FOUNDATION_EXPORT NSString *_Nonnull GDTMessageCodeEnumToString(GDTMessageCode code);
6257

6358
// A define to wrap GULLogWarning with slightly more convenient usage.
64-
#define GDTLogWarning(MESSAGE_CODE, MESSAGE_FORMAT, ...) \
65-
GULLogWarning(kGDTConsoleLogger, YES, GDTMessageCodeEnumToString(MESSAGE_CODE), MESSAGE_FORMAT, \
66-
__VA_ARGS__);
59+
#define GDTLogWarning(MESSAGE_CODE, MESSAGE_FORMAT, ...) \
60+
GDTLog(MESSAGE_CODE, MESSAGE_FORMAT, __VA_ARGS__);
6761

6862
// A define to wrap GULLogError with slightly more convenient usage and a failing assert.
69-
#define GDTLogError(MESSAGE_CODE, MESSAGE_FORMAT, ...) \
70-
GULLogError(kGDTConsoleLogger, YES, GDTMessageCodeEnumToString(MESSAGE_CODE), MESSAGE_FORMAT, \
71-
__VA_ARGS__); \
63+
#define GDTLogError(MESSAGE_CODE, MESSAGE_FORMAT, ...) \
64+
GDTLog(MESSAGE_CODE, MESSAGE_FORMAT, __VA_ARGS__); \
7265
GDTAssert(NO, MESSAGE_FORMAT, __VA_ARGS__);

0 commit comments

Comments
 (0)