File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ import { ChatEntry } from '@/components/livekit/chat/chat-entry';
1414import { ChatMessageView } from '@/components/livekit/chat/chat-message-view' ;
1515import { MediaTiles } from '@/components/livekit/media-tiles' ;
1616import useChatAndTranscription from '@/hooks/useChatAndTranscription' ;
17- // import { useDebugMode } from '@/hooks/useDebug';
17+ import { useDebugMode } from '@/hooks/useDebug' ;
1818import type { AppConfig } from '@/lib/types' ;
1919import { cn } from '@/lib/utils' ;
2020
@@ -39,8 +39,9 @@ export const SessionView = ({
3939 const { messages, send } = useChatAndTranscription ( ) ;
4040 const room = useRoomContext ( ) ;
4141
42- // Uncomment the below to see verbose logs showing the underlying connection lifecycle
43- // useDebugMode();
42+ useDebugMode ( {
43+ enabled : process . env . NODE_END !== 'production' ,
44+ } ) ;
4445
4546 async function handleSendMessage ( message : string ) {
4647 await send ( message ) ;
Original file line number Diff line number Diff line change @@ -2,10 +2,17 @@ import * as React from 'react';
22import { LogLevel , setLogLevel } from 'livekit-client' ;
33import { useRoomContext } from '@livekit/components-react' ;
44
5- export const useDebugMode = ( { logLevel } : { logLevel ?: LogLevel } = { } ) => {
5+ export const useDebugMode = ( options : { logLevel ?: LogLevel ; enabled ?: boolean } = { } ) => {
66 const room = useRoomContext ( ) ;
7+ const logLevel = options . logLevel ?? 'debug' ;
8+ const enabled = options . enabled ?? true ;
79
810 React . useEffect ( ( ) => {
11+ if ( ! enabled ) {
12+ setLogLevel ( 'silent' ) ;
13+ return ;
14+ }
15+
916 setLogLevel ( logLevel ?? 'debug' ) ;
1017
1118 // @ts -expect-error
@@ -14,6 +21,7 @@ export const useDebugMode = ({ logLevel }: { logLevel?: LogLevel } = {}) => {
1421 return ( ) => {
1522 // @ts -expect-error
1623 window . __lk_room = undefined ;
24+ setLogLevel ( 'silent' ) ;
1725 } ;
18- } , [ room , logLevel ] ) ;
26+ } , [ room , enabled , logLevel ] ) ;
1927} ;
You can’t perform that action at this time.
0 commit comments