From 359e40363933c5013e260132ad110acbcca395a8 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Thu, 9 Dec 2021 09:47:01 -0800 Subject: [PATCH] Disable idb stdout buffering for logs Summary: Changelog: Disable idb stdout buffering for logs. Show logs on iOS devices without buffering. Currently, idb buffers log output if it's redirected to a non-TTY. It is the default behavior for Python (read more about it [here](https://eklitzke.org/stdout-buffering)). It leads to users seeing logs only in large chunks because the size of the buffer is substantial. Setting PYTHONUNBUFFERED to a non-empty string disables Python output buffering. Reviewed By: lblasa Differential Revision: D32984711 fbshipit-source-id: 3e0a889b6b60b6d266f4a0c1894db937868c7433 --- .../src/devices/ios/IOSBridge.tsx | 6 +++++- .../src/devices/ios/__tests__/IOSBridge.node.tsx | 12 ++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx index 1cc0c80a3..df230a792 100644 --- a/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx +++ b/desktop/flipper-server-core/src/devices/ios/IOSBridge.tsx @@ -70,7 +70,11 @@ export function idbStartLogListener( return child_process.spawn( idbPath, ['log', '--udid', udid, '--', ...getLogExtraArgs(deviceType)], - {}, + { + env: { + PYTHONUNBUFFERED: '1', + }, + }, ); } diff --git a/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx b/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx index 10ee78e74..8239a0eea 100644 --- a/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx +++ b/desktop/flipper-server-core/src/devices/ios/__tests__/IOSBridge.node.tsx @@ -67,7 +67,11 @@ test('uses idb when present and xcode detected', async () => { '--debug', '--info', ], - {}, + { + env: { + PYTHONUNBUFFERED: '1', + }, + }, ); }); @@ -85,7 +89,11 @@ test('uses idb when present and xcode detected and physical device connected', a '--', // no further args; not supported by idb atm ], - {}, + { + env: { + PYTHONUNBUFFERED: '1', + }, + }, ); });