mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 03:26:07 +00:00
Silence annoying logs in iOS 11
Summary: Apple changed what messages get logged when a web socket connection fails. Lets hide them to make life better for engineers. Reviewed By: javache Differential Revision: D5879306 fbshipit-source-id: cde06405b4af251159269218bf922916a79ac840
This commit is contained in:
parent
6ce69dc925
commit
f01c73d84f
@ -13,6 +13,10 @@
|
||||
#import <React/RCTDefines.h>
|
||||
#import <fishhook/fishhook.h>
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
|
||||
#import <os/log.h>
|
||||
#endif /* __IPHONE_11_0 */
|
||||
|
||||
#import "RCTSRWebSocket.h"
|
||||
|
||||
#if RCT_DEV // Only supported in dev mode
|
||||
@ -27,11 +31,25 @@ static void my_nwlog_legacy_v(int level, char *format, va_list args) {
|
||||
vsnprintf(buffer, buffer_size, format, copy);
|
||||
va_end(copy);
|
||||
|
||||
if (strstr(buffer, "nw_connection_get_connected_socket_block_invoke") == NULL) {
|
||||
if (strstr(buffer, "nw_connection_get_connected_socket_block_invoke") == NULL &&
|
||||
strstr(buffer, "Connection has no connected handler") == NULL) {
|
||||
orig_nwlog_legacy_v(level, format, args);
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
|
||||
|
||||
static void (*orig_os_log_error_impl)(void *dso, os_log_t log, os_log_type_t type, const char *format, uint8_t *buf, uint32_t size);
|
||||
|
||||
static void my_os_log_error_impl(void *dso, os_log_t log, os_log_type_t type, const char *format, uint8_t *buf, uint32_t size)
|
||||
{
|
||||
if (strstr(format, "TCP Conn %p Failed : error %ld:%d") == NULL) {
|
||||
orig_os_log_error_impl(dso, log, type, format, buf, size);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* __IPHONE_11_0 */
|
||||
|
||||
@interface RCTReconnectingWebSocket () <RCTSRWebSocketDelegate>
|
||||
@end
|
||||
|
||||
@ -49,6 +67,11 @@ static void my_nwlog_legacy_v(int level, char *format, va_list args) {
|
||||
rebind_symbols((struct rebinding[1]){
|
||||
{"nwlog_legacy_v", my_nwlog_legacy_v, (void *)&orig_nwlog_legacy_v}
|
||||
}, 1);
|
||||
#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */
|
||||
rebind_symbols((struct rebinding[1]){
|
||||
{"_os_log_error_impl", my_os_log_error_impl, (void *)&orig_os_log_error_impl}
|
||||
}, 1);
|
||||
#endif /* __IPHONE_11_0 */
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user