Skip to content

Commit 629dafa

Browse files
committed
Revert "GULLogger - count errors and warnigns (#2601)"
This reverts commit 1e08a55.
1 parent 98cad74 commit 629dafa

File tree

3 files changed

+0
-179
lines changed

3 files changed

+0
-179
lines changed

GoogleUtilities/Example/Tests/Logger/GULLoggerTest.m

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232

3333
extern BOOL getGULLoggerDebugMode(void);
3434

35-
extern NSUserDefaults *getGULLoggerUsetDefaults(void);
36-
3735
static NSString *const kMessageCode = @"I-COR000001";
3836

3937
@interface GULLoggerTest : XCTestCase
@@ -155,85 +153,6 @@ - (void)testGULLoggerLevelValues {
155153
XCTAssertEqual(GULLoggerLevelDebug, ASL_LEVEL_DEBUG);
156154
}
157155

158-
- (void)testGetErrorWarningNumberBeforeLogDontCrash {
159-
GULResetLogger();
160-
161-
XCTestExpectation *getErrorCountExpectation =
162-
[self expectationWithDescription:@"getErrorCountExpectation"];
163-
XCTestExpectation *getWarningsCountExpectation =
164-
[self expectationWithDescription:@"getWarningsCountExpectation"];
165-
166-
GULNumberOfErrorsLogged(^(NSInteger count) {
167-
[getErrorCountExpectation fulfill];
168-
});
169-
170-
GULNumberOfWarningsLogged(^(NSInteger count) {
171-
[getWarningsCountExpectation fulfill];
172-
});
173-
174-
[self waitForExpectations:@[ getErrorCountExpectation, getWarningsCountExpectation ]
175-
timeout:0.5
176-
enforceOrder:YES];
177-
}
178-
179-
- (void)testErrorNumberIncrement {
180-
[getGULLoggerUsetDefaults() setInteger:10 forKey:kGULLoggerErrorCountKey];
181-
182-
GULLogError(@"my service", NO, kMessageCode, @"Message.");
183-
184-
XCTestExpectation *getErrorCountExpectation =
185-
[self expectationWithDescription:@"getErrorCountExpectation"];
186-
187-
GULNumberOfErrorsLogged(^(NSInteger count) {
188-
[getErrorCountExpectation fulfill];
189-
XCTAssertEqual(count, 11);
190-
});
191-
192-
[self waitForExpectationsWithTimeout:0.5 handler:NULL];
193-
}
194-
195-
- (void)testWarningNumberIncrement {
196-
[getGULLoggerUsetDefaults() setInteger:5 forKey:kGULLoggerWarningCountKey];
197-
198-
GULLogWarning(@"my service", NO, kMessageCode, @"Message.");
199-
200-
XCTestExpectation *getWarningsCountExpectation =
201-
[self expectationWithDescription:@"getWarningsCountExpectation"];
202-
203-
GULNumberOfWarningsLogged(^(NSInteger count) {
204-
[getWarningsCountExpectation fulfill];
205-
XCTAssertEqual(count, 6);
206-
});
207-
208-
[self waitForExpectationsWithTimeout:0.5 handler:NULL];
209-
}
210-
211-
- (void)testResetIssuesCount {
212-
[getGULLoggerUsetDefaults() setInteger:3 forKey:kGULLoggerErrorCountKey];
213-
[getGULLoggerUsetDefaults() setInteger:4 forKey:kGULLoggerWarningCountKey];
214-
215-
GULResetNumberOfIssuesLogged();
216-
217-
XCTestExpectation *getErrorCountExpectation =
218-
[self expectationWithDescription:@"getErrorCountExpectation"];
219-
XCTestExpectation *getWarningsCountExpectation =
220-
[self expectationWithDescription:@"getWarningsCountExpectation"];
221-
222-
GULNumberOfErrorsLogged(^(NSInteger count) {
223-
[getErrorCountExpectation fulfill];
224-
XCTAssertEqual(count, 0);
225-
});
226-
227-
GULNumberOfWarningsLogged(^(NSInteger count) {
228-
[getWarningsCountExpectation fulfill];
229-
XCTAssertEqual(count, 0);
230-
});
231-
232-
[self waitForExpectations:@[ getErrorCountExpectation, getWarningsCountExpectation ]
233-
timeout:0.5
234-
enforceOrder:YES];
235-
}
236-
237156
// Helper functions.
238157
- (BOOL)logExists {
239158
[self drainGULClientQueue];

GoogleUtilities/Logger/GULLogger.m

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
#import <GoogleUtilities/GULAppEnvironmentUtil.h>
2020
#import "Public/GULLoggerLevel.h"
2121

22-
NSString *const kGULLoggerErrorCountKey = @"kGULLoggerErrorCountKey";
23-
NSString *const kGULLoggerWarningCountKey = @"kGULLoggerWarningCountKey";
24-
2522
/// ASL client facility name used by GULLogger.
2623
const char *kGULLoggerASLClientFacilityName = "com.google.utilities.logger";
2724

@@ -46,8 +43,6 @@
4643
static NSRegularExpression *sMessageCodeRegex;
4744
#endif
4845

49-
void GULIncrementLogCountForLevel(GULLoggerLevel level);
50-
5146
void GULLoggerInitializeASL(void) {
5247
dispatch_once(&sGULLoggerOnceToken, ^{
5348
NSInteger majorOSVersion = [[GULAppEnvironmentUtil systemVersion] integerValue];
@@ -154,10 +149,6 @@ void GULLogBasic(GULLoggerLevel level,
154149
NSString *message,
155150
va_list args_ptr) {
156151
GULLoggerInitializeASL();
157-
158-
// Keep count of how many errors and warnings are triggered.
159-
GULIncrementLogCountForLevel(level);
160-
161152
if (!(level <= sGULLoggerMaximumLevel || sGULLoggerDebugMode || forceLog)) {
162153
return;
163154
}
@@ -203,70 +194,6 @@ void GULLogBasic(GULLoggerLevel level,
203194

204195
#undef GUL_MAKE_LOGGER
205196

206-
#pragma mark - Number of errors and warnings
207-
208-
NSUserDefaults *getGULLoggerUsetDefaults(void) {
209-
static NSUserDefaults *_userDefaults = nil;
210-
static dispatch_once_t onceToken;
211-
dispatch_once(&onceToken, ^{
212-
_userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"GoogleUtilities.Logger.GULLogger"];
213-
});
214-
215-
return _userDefaults;
216-
}
217-
218-
dispatch_queue_t getGULLoggerCounterQueue(void) {
219-
static dispatch_queue_t queue;
220-
static dispatch_once_t onceToken;
221-
dispatch_once(&onceToken, ^{
222-
queue = dispatch_queue_create("GoogleUtilities.GULLogger.counterQueue", DISPATCH_QUEUE_SERIAL);
223-
dispatch_set_target_queue(queue,
224-
dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0));
225-
});
226-
227-
return queue;
228-
}
229-
230-
void GULAsyncGetUserDefaultsIntegerForKey(NSString *key, void (^completion)(NSInteger)) {
231-
dispatch_async(getGULLoggerCounterQueue(), ^{
232-
NSInteger count = [getGULLoggerUsetDefaults() integerForKey:key];
233-
dispatch_async(dispatch_get_main_queue(), ^{
234-
completion(count);
235-
});
236-
});
237-
}
238-
239-
void GULNumberOfErrorsLogged(void (^completion)(NSInteger)) {
240-
GULAsyncGetUserDefaultsIntegerForKey(kGULLoggerErrorCountKey, completion);
241-
}
242-
243-
void GULNumberOfWarningsLogged(void (^completion)(NSInteger)) {
244-
GULAsyncGetUserDefaultsIntegerForKey(kGULLoggerWarningCountKey, completion);
245-
}
246-
247-
void GULResetNumberOfIssuesLogged(void) {
248-
dispatch_async(getGULLoggerCounterQueue(), ^{
249-
[getGULLoggerUsetDefaults() setInteger:0 forKey:kGULLoggerErrorCountKey];
250-
[getGULLoggerUsetDefaults() setInteger:0 forKey:kGULLoggerWarningCountKey];
251-
});
252-
}
253-
254-
void GULIncrementUserDefaultsIntegerForKey(NSString *key) {
255-
NSUserDefaults *defaults = getGULLoggerUsetDefaults();
256-
NSInteger errorCount = [defaults integerForKey:key];
257-
[defaults setInteger:errorCount + 1 forKey:key];
258-
}
259-
260-
void GULIncrementLogCountForLevel(GULLoggerLevel level) {
261-
dispatch_async(getGULLoggerCounterQueue(), ^{
262-
if (level == GULLoggerLevelError) {
263-
GULIncrementUserDefaultsIntegerForKey(kGULLoggerErrorCountKey);
264-
} else if (level == GULLoggerLevelWarning) {
265-
GULIncrementUserDefaultsIntegerForKey(kGULLoggerWarningCountKey);
266-
}
267-
});
268-
}
269-
270197
#pragma mark - GULLoggerWrapper
271198

272199
@implementation GULLoggerWrapper

GoogleUtilities/Logger/Private/GULLogger.h

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ NS_ASSUME_NONNULL_BEGIN
2525
*/
2626
typedef NSString *const GULLoggerService;
2727

28-
/**
29-
* The key used to store the logger's error count.
30-
*/
31-
extern NSString *const kGULLoggerErrorCountKey;
32-
33-
/**
34-
* The key used to store the logger's warning count.
35-
*/
36-
extern NSString *const kGULLoggerWarningCountKey;
37-
3828
#ifdef __cplusplus
3929
extern "C" {
4030
#endif // __cplusplus
@@ -139,21 +129,6 @@ extern void GULLogDebug(GULLoggerService service,
139129
NSString *message,
140130
...) NS_FORMAT_FUNCTION(4, 5);
141131

142-
/**
143-
* Retrieve the number of errors that have been logged since the stat was last reset.
144-
*/
145-
extern void GULNumberOfErrorsLogged(void (^completion)(NSInteger));
146-
147-
/**
148-
* Retrieve the number of warnings that have been logged since the stat was last reset.
149-
*/
150-
extern void GULNumberOfWarningsLogged(void (^completion)(NSInteger));
151-
152-
/**
153-
* Reset number of errors and warnings that have been logged to 0.
154-
*/
155-
extern void GULResetNumberOfIssuesLogged(void);
156-
157132
#ifdef __cplusplus
158133
} // extern "C"
159134
#endif // __cplusplus

0 commit comments

Comments
 (0)