From b69ff1e90c6197af8a99f0b4bcd404ace4403fb5 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Tue, 13 Feb 2024 20:05:57 +0100 Subject: [PATCH 1/8] chore(example): add support to disable ldk logs --- example/index.js | 2 ++ example/utils/ignoreLogs.ts | 44 +++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 example/utils/ignoreLogs.ts diff --git a/example/index.js b/example/index.js index 9b739329..d4145fbc 100644 --- a/example/index.js +++ b/example/index.js @@ -2,6 +2,8 @@ * @format */ +import './utils/ignoreLogs'; + import { AppRegistry } from 'react-native'; import App from './App'; import { name as appName } from './app.json'; diff --git a/example/utils/ignoreLogs.ts b/example/utils/ignoreLogs.ts new file mode 100644 index 00000000..ac018329 --- /dev/null +++ b/example/utils/ignoreLogs.ts @@ -0,0 +1,44 @@ +import { LogBox } from 'react-native'; + +const ENABLE_LOGBOX = true; +const ENABLE_LDK_LOGS = true; + +if (__DEV__) { + const ignoredLogs: string[] = []; + const ignoredInfo: string[] = []; + const ignoredWarnings: string[] = []; + const ignoredErrors: string[] = []; + + if (!ENABLE_LOGBOX) { + LogBox.ignoreAllLogs(); + } + + if (!ENABLE_LDK_LOGS) { + ignoredLogs.push('LDK:', 'react-native-ldk:', 'DEBUG (JS)', 'ERROR (JS)'); + } + + const withoutIgnored = ( + logger: (...data: any[]) => void, + ignoreList: string[], + ): any => { + return (...args): void => { + let output: string; + try { + output = args.join(' '); + } catch (err) { + // if we can't check if the log should be ignored, just log it + logger(...args); + return; + } + + if (!ignoreList.some((log) => output.includes(log))) { + logger(...args); + } + }; + }; + + console.log = withoutIgnored(console.log, ignoredLogs); + console.info = withoutIgnored(console.info, ignoredInfo); + console.warn = withoutIgnored(console.warn, ignoredWarnings); + console.error = withoutIgnored(console.error, ignoredErrors); +} From 864fba158362972f882c8cdaad40c10b732eb811 Mon Sep 17 00:00:00 2001 From: Ovi Trif Date: Tue, 13 Feb 2024 20:10:04 +0100 Subject: [PATCH 2/8] refactor(example): group related buttons in example app --- example/Dev.tsx | 472 ++++++++++++++++++++++++------------------------ 1 file changed, 241 insertions(+), 231 deletions(-) diff --git a/example/Dev.tsx b/example/Dev.tsx index da0db6a4..bc376758 100644 --- a/example/Dev.tsx +++ b/example/Dev.tsx @@ -259,153 +259,156 @@ const Dev = (): ReactElement => { }} /> -