From 1971f594cf29253e621d531898d269a7a5ff359c Mon Sep 17 00:00:00 2001 From: lebaudantoine Date: Fri, 2 Aug 2024 14:28:12 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=87(frontend)=20remove=20LiveKit=20log?= =?UTF-8?q?s=20in=20production?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enabling logs by default in clients during production feels insecure. Therefore, I have silenced all LiveKit logs. This might pose a challenge if we need to debug a user in the future, but currently, we don’t require these logs. Additionally, my utils file and function work as intended, though there is room for improvement. --- src/frontend/src/App.tsx | 5 +++++ src/frontend/src/utils/livekit.ts | 6 ++++++ 2 files changed, 11 insertions(+) create mode 100644 src/frontend/src/utils/livekit.ts diff --git a/src/frontend/src/App.tsx b/src/frontend/src/App.tsx index 4c61e898..aab0ef18 100644 --- a/src/frontend/src/App.tsx +++ b/src/frontend/src/App.tsx @@ -10,12 +10,17 @@ import { Layout } from './layout/Layout' import { NotFoundScreen } from './components/NotFoundScreen' import { routes } from './routes' import './i18n/init' +import { silenceLiveKitLogs } from "@/utils/livekit.ts"; const queryClient = new QueryClient() function App() { const { i18n } = useTranslation() useLang(i18n.language) + + const isProduction = import.meta.env.PROD + silenceLiveKitLogs(isProduction) + return ( diff --git a/src/frontend/src/utils/livekit.ts b/src/frontend/src/utils/livekit.ts new file mode 100644 index 00000000..86d52d4b --- /dev/null +++ b/src/frontend/src/utils/livekit.ts @@ -0,0 +1,6 @@ +import { LogLevel, setLogLevel } from "livekit-client"; + + +export const silenceLiveKitLogs = (shouldSilenceLogs: boolean) => { + setLogLevel(shouldSilenceLogs ? LogLevel.silent : LogLevel.debug); +}