From b1277a762e20ca5e9d5e130a707b1ee0b6d7cf75 Mon Sep 17 00:00:00 2001 From: bobbydigitales Date: Thu, 22 May 2025 22:39:23 -0700 Subject: [PATCH] Truncate log messages in html so it doesn\'t kill phones. Fix id in log message --- src/log.ts | 5 +++-- src/main2.ts | 4 ++-- static/main2.js | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/log.ts b/src/log.ts index d8ed441..c268602 100644 --- a/src/log.ts +++ b/src/log.ts @@ -31,7 +31,8 @@ export function log(...args: any[]): any { let logLine = `[${new Date().toLocaleTimeString()}]: `; for (let arg of args) { - logLine += (typeof arg === "string" || arg instanceof String) ? arg : JSON.stringify(arg, null, 4); + let completeLine = (typeof arg === "string" || arg instanceof String) ? arg : JSON.stringify(arg, null, 4); + logLine += completeLine.substring(0, 500); } logLines.push(logLine + "\n"); @@ -42,4 +43,4 @@ export function log(...args: any[]): any { renderLog(); return [...args]; -} \ No newline at end of file +} diff --git a/src/main2.ts b/src/main2.ts index f37c89c..1d084d5 100644 --- a/src/main2.ts +++ b/src/main2.ts @@ -341,7 +341,7 @@ class App { for (let post of posts) { - console.log.apply(null, log(`[app] sendPostForUser sending post [${logID(post.id)}] to [${logID(requestingPeerID)}]`, userID, post)); + console.log.apply(null, log(`[app] sendPostForUser sending post [${logID(post.post_id)}] to [${logID(requestingPeerID)}]`, userID, post)); this.peerManager?.rpc.sendPostForUser(requestingPeerID, userID, post); } @@ -362,7 +362,7 @@ class App { clearTimeout(this.renderTimer); } - this.renderTimer = setTimeout(()=>{this.render()}, 1000) + this.renderTimer = setTimeout(()=>{this.render()}, 200); // } }); diff --git a/static/main2.js b/static/main2.js index f42d826..23f8591 100644 --- a/static/main2.js +++ b/static/main2.js @@ -201,7 +201,7 @@ class App { this.peerManager.registerRPC('getPostsForUser', async (requestingPeerID, userID, postIDs) => { let posts = await this.sync.getPostsForUser(userID, postIDs); for (let post of posts) { - console.log.apply(null, log(`[app] sendPostForUser sending post [${logID(post.id)}] to [${logID(requestingPeerID)}]`, userID, post)); + console.log.apply(null, log(`[app] sendPostForUser sending post [${logID(post.post_id)}] to [${logID(requestingPeerID)}]`, userID, post)); this.peerManager?.rpc.sendPostForUser(requestingPeerID, userID, post); } // return posts; @@ -217,7 +217,7 @@ class App { if (this.renderTimer) { clearTimeout(this.renderTimer); } - this.renderTimer = setTimeout(() => { this.render(); }, 1000); + this.renderTimer = setTimeout(() => { this.render(); }, 200); // } }); await this.peerManager.connect();