@@ -65,6 +65,10 @@ - (void)logResponse:(AFHTTPRequestOperation *)operation
65
65
error : (NSError *)error {
66
66
SWGConfiguration *config = [SWGConfiguration sharedConfig ];
67
67
68
+ if (!config.debug ) {
69
+ return ;
70
+ }
71
+
68
72
NSString *message = [NSString stringWithFormat: @" \n [DEBUG] Request body \n ~BEGIN~\n %@ \n ~END~\n " \
69
73
" [DEBUG] HTTP Response body \n ~BEGIN~\n %@\n ~END~\n " ,
70
74
[[NSString alloc ] initWithData: request.HTTPBody encoding: NSUTF8StringEncoding],
@@ -74,8 +78,9 @@ - (void)logResponse:(AFHTTPRequestOperation *)operation
74
78
[config.loggingFileHanlder seekToEndOfFile ];
75
79
[config.loggingFileHanlder writeData: [message dataUsingEncoding: NSUTF8StringEncoding]];
76
80
}
77
-
78
- NSLog (@" %@ " , message);
81
+ else {
82
+ NSLog (@" %@ " , message);
83
+ }
79
84
}
80
85
81
86
#pragma mark - Cache Methods
@@ -177,8 +182,9 @@ +(NSNumber*) nextRequestId {
177
182
178
183
+(NSNumber *) queueRequest {
179
184
NSNumber * requestId = [SWGApiClient nextRequestId ];
180
- if ([[SWGConfiguration sharedConfig ] debug ])
185
+ if ([[SWGConfiguration sharedConfig ] debug ]) {
181
186
NSLog (@" added %@ to request queue" , requestId);
187
+ }
182
188
[queuedRequests addObject: requestId];
183
189
return requestId;
184
190
}
@@ -198,8 +204,9 @@ -(Boolean) executeRequestWithId:(NSNumber*) requestId {
198
204
}];
199
205
200
206
if (matchingItems.count == 1 ) {
201
- if ([[SWGConfiguration sharedConfig ] debug ])
207
+ if ([[SWGConfiguration sharedConfig ] debug ]){
202
208
NSLog (@" removing request id %@ " , requestId);
209
+ }
203
210
[queuedRequests removeObject: requestId];
204
211
return YES ;
205
212
}
@@ -577,15 +584,21 @@ -(NSNumber*) requestWithCompletionBlock: (NSString*) path
577
584
hasHeaderParams = true ;
578
585
}
579
586
if (offlineState) {
580
- NSLog (@" %@ cache forced" , resourcePath);
587
+ if ([[SWGConfiguration sharedConfig ] debug ]){
588
+ NSLog (@" %@ cache forced" , resourcePath);
589
+ }
581
590
[request setCachePolicy: NSURLRequestReturnCacheDataDontLoad];
582
591
}
583
592
else if (!hasHeaderParams && [method isEqualToString: @" GET" ] && cacheEnabled) {
584
- NSLog (@" %@ cache enabled" , resourcePath);
593
+ if ([[SWGConfiguration sharedConfig ] debug ]){
594
+ NSLog (@" %@ cache enabled" , resourcePath);
595
+ }
585
596
[request setCachePolicy: NSURLRequestUseProtocolCachePolicy];
586
597
}
587
598
else {
588
- NSLog (@" %@ cache disabled" , resourcePath);
599
+ if ([[SWGConfiguration sharedConfig ] debug ]){
600
+ NSLog (@" %@ cache disabled" , resourcePath);
601
+ }
589
602
[request setCachePolicy: NSURLRequestReloadIgnoringLocalCacheData];
590
603
}
591
604
0 commit comments