This commit is contained in:
2026-03-04 18:29:32 +08:00
parent e7567909bc
commit f2184cf9c6
4 changed files with 12 additions and 17 deletions

View File

@@ -100,7 +100,7 @@ NSErrorDomain const KBNetworkErrorDomain = @"com.company.keyboard.network";
#if DEBUG
// GET
NSString *paramStr = [self kb_prettyJSONStringFromObject:parameters] ?: @"(null)";
KBLOG(@"HTTP GET\nURL: %@\nHeaders: %@\n参数: %@",
KBLOG(@"HTTP GET\nURL: %@\nHeaders: %@\nParams: %@",
req.URL.absoluteString,
req.allHTTPHeaderFields ?: @{},
paramStr);
@@ -397,7 +397,7 @@ autoShowBusinessError:YES
if (error) {
#if DEBUG
NSInteger status = [response isKindOfClass:NSHTTPURLResponse.class] ? ((NSHTTPURLResponse *)response).statusCode : 0;
KBLOG(@"请求失败\nURL: %@\n状态: %ld\n错误: %@\nUserInfo: %@",
KBLOG(@"Request failed\nURL: %@\nStatus: %ld\nError: %@\nUserInfo: %@",
req.URL.absoluteString,
(long)status,
error.localizedDescription,
@@ -409,7 +409,7 @@ autoShowBusinessError:YES
NSData *data = (NSData *)responseObject;
if (![data isKindOfClass:[NSData class]]) {
#if DEBUG
KBLOG(@"无效响应\nURL: %@\n说明: %@", req.URL.absoluteString, KBLocalized(@"No data received"));
KBLOG(@"Invalid response\nURL: %@\nReason: %@", req.URL.absoluteString, KBLocalized(@"No data received"));
#endif
if (completion) completion(nil, response, [NSError errorWithDomain:KBNetworkErrorDomain code:KBNetworkErrorInvalidResponse userInfo:@{NSLocalizedDescriptionKey:KBLocalized(@"No data")}]);
return;
@@ -436,7 +436,7 @@ autoShowBusinessError:YES
id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonErr];
if (jsonErr) {
#if DEBUG
KBLOG(@"响应解析失败(JSON)\nURL: %@\n错误: %@",
KBLOG(@"Response decode failed (JSON)\nURL: %@\nError: %@",
req.URL.absoluteString,
jsonErr.localizedDescription);
#endif
@@ -453,7 +453,7 @@ autoShowBusinessError:YES
NSString *pretty = [self kb_prettyJSONStringFromObject:json] ?: @"(null)";
pretty = [self kb_trimmedString:pretty maxLength:4096];
NSInteger status = [response isKindOfClass:NSHTTPURLResponse.class] ? ((NSHTTPURLResponse *)response).statusCode : 0;
KBLOG(@"\n[KBNetwork] 响应成功(JSON)\nURL: %@\n状态: %ld\nContent-Type: %@\n数据: %@\n",
KBLOG(@"Response OK (JSON)\nURL: %@\nStatus: %ld\nContent-Type: %@\nData: %@",
req.URL.absoluteString,
(long)status,
ct ?: @"",