Skip to content

Commit 53e438d

Browse files
committed
chore: removed redundant logs
1 parent 0046c3d commit 53e438d

File tree

19 files changed

+81
-157
lines changed

19 files changed

+81
-157
lines changed

src/client/app/actions.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ export async function subscribeUser(subscription) {
6868
{ upsert: true }
6969
)
7070

71-
console.log(`[Actions] Subscription saved for user: ${userId}`)
7271
return { success: true }
7372
} catch (error) {
7473
console.error("[Actions] Error saving subscription:", error)
@@ -95,9 +94,6 @@ export async function unsubscribeUser(endpoint) {
9594
{ $pull: { "userData.pwa_subscriptions": { endpoint: endpoint } } }
9695
)
9796

98-
console.log(
99-
`[Actions] Subscription with endpoint ${endpoint} removed for user: ${userId}`
100-
)
10197
return { success: true }
10298
} catch (error) {
10399
console.error("[Actions] Error removing subscription:", error)
@@ -144,9 +140,6 @@ export async function sendNotificationToCurrentUser(payload) {
144140
!Array.isArray(subscriptions) ||
145141
subscriptions.length === 0
146142
) {
147-
console.log(
148-
`[Actions] No push subscription found for user ${userId}.`
149-
)
150143
return { success: false, error: "No subscription found for user." }
151144
}
152145

@@ -156,9 +149,6 @@ export async function sendNotificationToCurrentUser(payload) {
156149
.sendNotification(subscription, JSON.stringify(payload))
157150
.then(() => {
158151
successCount++
159-
console.log(
160-
`[Actions] Push notification sent successfully to endpoint for user ${userId}.`
161-
)
162152
})
163153
.catch(async (error) => {
164154
console.error(

src/client/app/chat/page.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -979,9 +979,6 @@ export default function ChatPage() {
979979
onDisconnected: () => handleStatusChange("disconnected"),
980980
onAudioStream: (stream) => {
981981
if (remoteAudioRef.current) {
982-
console.log(
983-
"Received remote audio stream, attaching to audio element."
984-
)
985982
remoteAudioRef.current.srcObject = stream
986983
remoteAudioRef.current
987984
.play()

src/client/app/page.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ const Home = () => {
8888

8989
if (!user) {
9090
// User is not authenticated. Redirect to the Auth0 login page.
91-
console.log("No user session found, redirecting to login.")
9291
router.push("/auth/login")
9392
return
9493
}

src/client/components/LayoutWrapper.js

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -288,14 +288,12 @@ export default function LayoutWrapper({ children }) {
288288
// The 'load' event ensures that SW registration doesn't delay page rendering.
289289
window.addEventListener("load", function () {
290290
navigator.serviceWorker.register("/sw.js").then(
291-
function (registration) {
292-
console.log(
293-
"ServiceWorker registration successful with scope: ",
294-
registration.scope
295-
)
296-
},
291+
function (registration) {},
297292
function (err) {
298-
console.log("ServiceWorker registration failed: ", err)
293+
console.error(
294+
"ServiceWorker registration failed: ",
295+
err
296+
)
299297
}
300298
)
301299
})
@@ -356,7 +354,6 @@ export default function LayoutWrapper({ children }) {
356354

357355
const subscribeToPushNotifications = useCallback(async () => {
358356
if (!("serviceWorker" in navigator) || !("PushManager" in window)) {
359-
console.log("Push notifications not supported by this browser.")
360357
return
361358
}
362359
if (!process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY) {
@@ -377,7 +374,6 @@ export default function LayoutWrapper({ children }) {
377374
return
378375
}
379376

380-
console.log("Permission granted. Subscribing...")
381377
const applicationServerKey = urlBase64ToUint8Array(
382378
process.env.NEXT_PUBLIC_VAPID_PUBLIC_KEY
383379
)
@@ -387,12 +383,9 @@ export default function LayoutWrapper({ children }) {
387383
applicationServerKey
388384
})
389385

390-
console.log("New subscription created:", subscription)
391386
const serializedSub = JSON.parse(JSON.stringify(subscription))
392387
await subscribeUser(serializedSub)
393388
toast.success("Subscribed to push notifications!")
394-
} else {
395-
console.log("User is already subscribed.")
396389
}
397390
} catch (error) {
398391
console.error("Error during push notification subscription:", error)
@@ -420,8 +413,6 @@ export default function LayoutWrapper({ children }) {
420413
)
421414
}
422415

423-
console.log(user?.[`${process.env.NEXT_PUBLIC_AUTH0_NAMESPACE}/roles`])
424-
425416
// ... (rest of the component is unchanged)
426417
return (
427418
<PlanContext.Provider

src/client/lib/webrtc-client.js

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@ export class WebRTCClient {
1919
}
2020

2121
async connect(deviceId, authToken, rtcToken) {
22-
console.log("Connecting WebRTC client with deviceId:", deviceId)
23-
console.log("Using authToken:", authToken)
24-
console.log("Using rtcToken:", rtcToken)
25-
2622
if (!authToken) {
2723
throw new Error("Authentication token is required to connect.")
2824
}
@@ -37,49 +33,27 @@ export class WebRTCClient {
3733
this.peerConnection = new RTCPeerConnection({
3834
iceServers: this.iceServers
3935
})
40-
console.log("Created RTCPeerConnection with config:", {
41-
iceServers: this.iceServers
42-
})
43-
44-
console.log("Created RTCPeerConnection:", this.peerConnection)
4536

4637
// --- MODIFICATION: Queue ICE candidates instead of sending immediately ---
4738
this.peerConnection.onicecandidate = (event) => {
4839
if (event.candidate) {
49-
console.log(
50-
"ICE Candidate Found, queueing:",
51-
event.candidate
52-
)
5340
this.iceCandidateQueue.push(event.candidate)
54-
} else {
55-
console.log("All ICE candidates have been gathered.")
5641
}
5742
}
5843

5944
this.peerConnection.oniceconnectionstatechange = (event) => {
6045
const state = this.peerConnection.iceConnectionState
61-
console.log(
62-
`%cICE Connection State Change: ${state}`,
63-
"font-weight: bold; color: blue;"
64-
)
6546
}
6647

6748
this.peerConnection.onconnectionstatechange = (event) => {
6849
const state = this.peerConnection.connectionState
69-
console.log(
70-
`%cPeer Connection State Change: ${state}`,
71-
"font-weight: bold; color: green;"
72-
)
7350

7451
// --- START MODIFICATION: Handle temporary disconnections ---
7552
// If connection is established or re-established, clear any pending disconnect timer.
7653
if (state === "connected") {
7754
if (this.disconnectTimer) {
7855
clearTimeout(this.disconnectTimer)
7956
this.disconnectTimer = null
80-
console.log(
81-
"WebRTC reconnected. Disconnect timer cleared."
82-
)
8357
}
8458
this.options.onConnected?.()
8559
}
@@ -113,13 +87,6 @@ export class WebRTCClient {
11387
// --- END MODIFICATION ---
11488
}
11589

116-
this.peerConnection.ondatachannel = (event) => {
117-
console.log(
118-
"Data Channel established by remote peer:",
119-
event.channel
120-
)
121-
}
122-
12390
const audioConstraints = {
12491
...(deviceId && { deviceId: { exact: deviceId } }),
12592
noiseSuppression: false,
@@ -130,7 +97,6 @@ export class WebRTCClient {
13097
})
13198

13299
this.setupAudioAnalysis()
133-
console.log("Acquired media stream:", this.mediaStream)
134100

135101
this.mediaStream.getTracks().forEach((track) => {
136102
if (this.peerConnection) {
@@ -139,7 +105,6 @@ export class WebRTCClient {
139105
})
140106

141107
this.peerConnection.addEventListener("track", (event) => {
142-
console.log("Received track event:", event)
143108
this.options.onAudioStream?.(event.streams[0])
144109
})
145110

@@ -181,13 +146,9 @@ export class WebRTCClient {
181146
}
182147

183148
const serverResponse = await response.json()
184-
console.log("Received server answer:", serverResponse)
185149
await this.peerConnection.setRemoteDescription(serverResponse)
186150

187151
// --- MODIFICATION: Send all queued ICE candidates now ---
188-
console.log(
189-
`Sending ${this.iceCandidateQueue.length} queued ICE candidates...`
190-
)
191152
for (const candidate of this.iceCandidateQueue) {
192153
fetch(`${this.serverUrl}/voice/webrtc/offer`, {
193154
method: "POST",
@@ -207,9 +168,6 @@ export class WebRTCClient {
207168
}
208169
this.iceCandidateQueue = [] // Clear the queue
209170

210-
console.log(
211-
"WebRTC signaling complete. Waiting for connection to establish..."
212-
)
213171
} catch (error) {
214172
console.error("Error connecting WebRTC:", error)
215173
this.disconnect()
@@ -277,10 +235,6 @@ export class WebRTCClient {
277235
}
278236

279237
disconnect() {
280-
// --- NEW: Add a log here for clarity on manual disconnects ---
281-
console.log("Disconnect called. Cleaning up WebRTC resources.")
282-
// --- END NEW ---
283-
284238
if (this.disconnectTimer) {
285239
clearTimeout(this.disconnectTimer)
286240
this.disconnectTimer = null

src/client/utils/webSocketAudioClient.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ export class WebSocketClient {
1818
this.analyser = null
1919
this.token = null
2020
this.chatId = null
21-
22-
console.log(`[VoiceClient] Initialized. Server URL: ${this.serverUrl}`)
2321
}
2422

2523
async connect(deviceId, token) {
@@ -71,7 +69,6 @@ export class WebSocketClient {
7169

7270
try {
7371
await this.audioContext.audioWorklet.addModule("/audioProcessor.js")
74-
console.log("[VoiceClient] AudioWorklet module loaded.")
7572
} catch (e) {
7673
console.error("[VoiceClient] Failed to load AudioWorklet:", e)
7774
throw new Error("Could not load audio processor.")
@@ -128,7 +125,6 @@ export class WebSocketClient {
128125
if (!this.ws) return
129126

130127
this.ws.onopen = () => {
131-
console.log("[VoiceClient] WebSocket connection opened.")
132128
if (this.token) {
133129
this.ws.send(
134130
JSON.stringify({
@@ -173,9 +169,6 @@ export class WebSocketClient {
173169
}
174170

175171
this.ws.onclose = (event) => {
176-
console.log(
177-
`[VoiceClient] WebSocket closed: Code=${event.code}, Reason: ${event.reason}`
178-
)
179172
this.options.onDisconnected?.()
180173
this.cleanup()
181174
}

src/server/main/analytics.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
import os
22
from posthog import Posthog
3+
import logging
34

45
# It's important to use the API key directly, not the public/project key, for backend events.
56
POSTHOG_KEY = os.getenv("POSTHOG_KEY")
67
POSTHOG_HOST = os.getenv("POSTHOG_HOST")
78

9+
logger = logging.getLogger(__name__)
10+
811
posthog_client = None
912
if POSTHOG_KEY and POSTHOG_HOST:
1013
posthog_client = Posthog(project_api_key=POSTHOG_KEY, host=POSTHOG_HOST)
11-
print("PostHog client initialized for backend tracking.")
14+
logger.info("PostHog client initialized for backend tracking.")
1215
else:
13-
print("PostHog API key or host not found. Backend event tracking is disabled.")
16+
logger.warning("PostHog API key or host not found. Backend event tracking is disabled.")
1417

1518
def capture_event(user_id: str, event_name: str, properties: dict = None):
1619
"""

src/server/main/app.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,15 @@
22
import datetime
33
from datetime import timezone
44
START_TIME = time.time()
5-
print(f"[{datetime.datetime.now()}] [STARTUP] Main Server application script execution started.")
65

76
import os
87
import platform
98
import logging
109
logging.basicConfig(level=logging.INFO)
1110
import socket
1211

12+
logger = logging.getLogger(__name__)
13+
1314
if platform.system() == 'Windows':
1415
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
1516
try:
@@ -19,8 +20,8 @@
1920
local_ip = '127.0.0.1'
2021
finally:
2122
s.close()
22-
23-
logging.info(f"Detected local IP: {local_ip}")
23+
24+
logger.info(f"Detected local IP: {local_ip}")
2425

2526
os.environ['WEBRTC_IP'] = local_ip
2627

@@ -130,17 +131,17 @@ def initialize_tts():
130131

131132
@asynccontextmanager
132133
async def lifespan(app_instance: FastAPI):
133-
print(f"[{datetime.datetime.now(timezone.utc).isoformat()}] [LIFESPAN] App startup...")
134+
logger.info("App startup...")
134135
await mongo_manager.initialize_db()
135136
initialize_stt()
136137
initialize_tts()
137-
print(f"[{datetime.datetime.now(timezone.utc).isoformat()}] [LIFESPAN] App startup complete.")
138+
logger.info("App startup complete.")
138139
yield
139-
print(f"[{datetime.datetime.now(timezone.utc).isoformat()}] [LIFESPAN] App shutdown sequence initiated...")
140+
logger.info("App shutdown sequence initiated...")
140141
if mongo_manager and mongo_manager.client:
141142
mongo_manager.client.close()
142143
await close_memories_pg_pool()
143-
print(f"[{datetime.datetime.now(timezone.utc).isoformat()}] [LIFESPAN] App shutdown complete.")
144+
logger.info("App shutdown complete.")
144145

145146
app = FastAPI(title="Sentient Main Server", version="2.2.0", docs_url="/docs", redoc_url="/redoc", lifespan=lifespan)
146147

@@ -186,7 +187,7 @@ async def health():
186187
}
187188

188189
END_TIME = time.time()
189-
print(f"[{datetime.datetime.now()}] [APP_PY_LOADED] Main Server app.py loaded in {END_TIME - START_TIME:.2f} seconds.")
190+
logger.info(f"Main Server app.py loaded in {END_TIME - START_TIME:.2f} seconds.")
190191

191192
if __name__ == "__main__":
192193
import uvicorn

0 commit comments

Comments
 (0)