Skip to content

Commit

Permalink
ADD: debugLogEnabled option
Browse files Browse the repository at this point in the history
Change-Id: I61390a39d7285db4ce884ae501256aaba9150c88
  • Loading branch information
liujl committed Sep 13, 2016
1 parent f210739 commit f0ee0b4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
12 changes: 7 additions & 5 deletions YTKNetwork/YTKNetworkConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ NS_ASSUME_NONNULL_BEGIN
+ (YTKNetworkConfig *)sharedConfig;

/// Request base URL, such as "http://www.yuantiku.com". Default is empty string.
@property (strong, nonatomic) NSString *baseUrl;
@property (nonatomic, strong) NSString *baseUrl;
/// Request CDN URL. Default is empty string.
@property (strong, nonatomic) NSString *cdnUrl;
@property (nonatomic, strong) NSString *cdnUrl;
/// URL filters. See also `YTKUrlFilterProtocol`.
@property (strong, nonatomic, readonly) NSArray<id<YTKUrlFilterProtocol>> *urlFilters;
@property (nonatomic, strong, readonly) NSArray<id<YTKUrlFilterProtocol>> *urlFilters;
/// Cache path filters. See also `YTKCacheDirPathFilterProtocol`.
@property (strong, nonatomic, readonly) NSArray<id<YTKCacheDirPathFilterProtocol>> *cacheDirPathFilters;
@property (nonatomic, strong, readonly) NSArray<id<YTKCacheDirPathFilterProtocol>> *cacheDirPathFilters;
/// Security policy will be used by AFNetworking. See also `AFSecurityPolicy`.
@property (strong, nonatomic) AFSecurityPolicy *securityPolicy;
@property (nonatomic, strong) AFSecurityPolicy *securityPolicy;
/// Whether to log debug info. Default is NO;
@property (nonatomic) BOOL debugLogEnabled;

/// Add a new URL filter.
- (void)addUrlFilter:(id<YTKUrlFilterProtocol>)filter;
Expand Down
1 change: 1 addition & 0 deletions YTKNetwork/YTKNetworkConfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ - (instancetype)init {
_urlFilters = [NSMutableArray array];
_cacheDirPathFilters = [NSMutableArray array];
_securityPolicy = [AFSecurityPolicy defaultPolicy];
_debugLogEnabled = NO;
}
return self;
}
Expand Down
1 change: 1 addition & 0 deletions YTKNetwork/YTKNetworkPrivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#import "YTKBatchRequest.h"
#import "YTKChainRequest.h"
#import "YTKNetworkAgent.h"
#import "YTKNetworkConfig.h"

@class AFHTTPSessionManager;

Expand Down
3 changes: 3 additions & 0 deletions YTKNetwork/YTKNetworkPrivate.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

void YTKLog(NSString *format, ...) {
#ifdef DEBUG
if (![YTKNetworkConfig sharedConfig].debugLogEnabled) {
return;
}
va_list argptr;
va_start(argptr, format);
NSLogv(format, argptr);
Expand Down

0 comments on commit f0ee0b4

Please sign in to comment.