mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 04:16:00 +08:00
fishhook nwlog_legacy_v to avoid log spam on websocket reconnect
Reviewed By: mmmulani, javache Differential Revision: D5570896 fbshipit-source-id: be98f500434bd2a0113b9abca20c9f21102c09d1
This commit is contained in:
committed by
Facebook Github Bot
parent
898790d88a
commit
878b7e42fa
@@ -11,11 +11,27 @@
|
||||
|
||||
#import <React/RCTConvert.h>
|
||||
#import <React/RCTDefines.h>
|
||||
#import <fishhook/fishhook.h>
|
||||
|
||||
#import "RCTSRWebSocket.h"
|
||||
|
||||
#if RCT_DEV // Only supported in dev mode
|
||||
|
||||
static void (*orig_nwlog_legacy_v)(int, char*, va_list);
|
||||
|
||||
static void my_nwlog_legacy_v(int level, char *format, va_list args) {
|
||||
static const uint buffer_size = 256;
|
||||
static char buffer[buffer_size];
|
||||
va_list copy;
|
||||
va_copy(copy, args);
|
||||
vsnprintf(buffer, buffer_size, format, copy);
|
||||
va_end(copy);
|
||||
|
||||
if (strstr(buffer, "nw_connection_get_connected_socket_block_invoke") == NULL) {
|
||||
orig_nwlog_legacy_v(level, format, args);
|
||||
}
|
||||
}
|
||||
|
||||
@interface RCTReconnectingWebSocket () <RCTSRWebSocketDelegate>
|
||||
@end
|
||||
|
||||
@@ -26,6 +42,16 @@
|
||||
|
||||
@synthesize delegate = _delegate;
|
||||
|
||||
+ (void)load
|
||||
{
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
rebind_symbols((struct rebinding[1]){
|
||||
{"nwlog_legacy_v", my_nwlog_legacy_v, (void *)&orig_nwlog_legacy_v}
|
||||
}, 1);
|
||||
});
|
||||
}
|
||||
|
||||
- (instancetype)initWithURL:(NSURL *)url
|
||||
{
|
||||
if (self = [super init]) {
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
1338BBE01B04ACC80064A9C9 /* RCTSRWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDD1B04ACC80064A9C9 /* RCTSRWebSocket.m */; };
|
||||
1338BBE11B04ACC80064A9C9 /* RCTWebSocketExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDF1B04ACC80064A9C9 /* RCTWebSocketExecutor.m */; };
|
||||
13526A521F362F7F0008EF00 /* libfishhook.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 13526A511F362F7F0008EF00 /* libfishhook.a */; };
|
||||
2D3B5F3D1D9B165B00451313 /* RCTSRWebSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDD1B04ACC80064A9C9 /* RCTSRWebSocket.m */; };
|
||||
2D3B5F3E1D9B165B00451313 /* RCTWebSocketExecutor.m in Sources */ = {isa = PBXBuildFile; fileRef = 1338BBDF1B04ACC80064A9C9 /* RCTWebSocketExecutor.m */; };
|
||||
2D3B5F3F1D9B165B00451313 /* RCTWebSocketObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 3DB9106E1C74B1ED00838BBE /* RCTWebSocketObserver.m */; };
|
||||
@@ -24,6 +25,7 @@
|
||||
1338BBDD1B04ACC80064A9C9 /* RCTSRWebSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSRWebSocket.m; sourceTree = "<group>"; };
|
||||
1338BBDE1B04ACC80064A9C9 /* RCTWebSocketExecutor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebSocketExecutor.h; sourceTree = "<group>"; };
|
||||
1338BBDF1B04ACC80064A9C9 /* RCTWebSocketExecutor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTWebSocketExecutor.m; sourceTree = "<group>"; };
|
||||
13526A511F362F7F0008EF00 /* libfishhook.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfishhook.a; path = "libfishhook.a"; sourceTree = "<group>"; };
|
||||
2D2A28881D9B049200D4039D /* libRCTWebSocket-tvOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libRCTWebSocket-tvOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3C86DF461ADF2C930047B81A /* libRCTWebSocket.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTWebSocket.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3C86DF7A1ADF695F0047B81A /* RCTWebSocketModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTWebSocketModule.h; sourceTree = "<group>"; };
|
||||
@@ -34,7 +36,26 @@
|
||||
A12E9E2D1E5DEC4E0029001B /* RCTReconnectingWebSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTReconnectingWebSocket.m; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
13526A4F1F362F770008EF00 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
13526A521F362F7F0008EF00 /* libfishhook.a in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
13526A501F362F7F0008EF00 /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
13526A511F362F7F0008EF00 /* libfishhook.a */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3C86DF3D1ADF2C930047B81A = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
@@ -49,6 +70,7 @@
|
||||
3C86DF7A1ADF695F0047B81A /* RCTWebSocketModule.h */,
|
||||
3C86DF7B1ADF695F0047B81A /* RCTWebSocketModule.m */,
|
||||
3C86DF471ADF2C930047B81A /* Products */,
|
||||
13526A501F362F7F0008EF00 /* Frameworks */,
|
||||
);
|
||||
indentWidth = 2;
|
||||
sourceTree = "<group>";
|
||||
@@ -87,6 +109,7 @@
|
||||
buildConfigurationList = 3C86DF5A1ADF2C930047B81A /* Build configuration list for PBXNativeTarget "RCTWebSocket" */;
|
||||
buildPhases = (
|
||||
3C86DF421ADF2C930047B81A /* Sources */,
|
||||
13526A4F1F362F770008EF00 /* Frameworks */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user