mirror of
https://github.com/hoornet/vega.git
synced 2026-06-08 06:01:57 -07:00
Polish pass 14 — silence remaining console calls in production
- feedDiagnostics.ts: guard styled console.log with isDev, plain log → debug.log - main.tsx: error boundary console.error → debug.error
This commit is contained in:
+15
-10
@@ -7,6 +7,9 @@
|
||||
*/
|
||||
|
||||
import { getNDK } from "./nostr/core";
|
||||
import { debug } from "./debug";
|
||||
|
||||
const isDev = import.meta.env.DEV;
|
||||
|
||||
const DIAG_KEY = "wrystr_feed_diag";
|
||||
const MAX_ENTRIES = 200;
|
||||
@@ -52,15 +55,17 @@ export function logDiag(entry: DiagEntry) {
|
||||
? "color: #ffaa00; font-weight: bold"
|
||||
: "color: #44aa44";
|
||||
|
||||
console.log(
|
||||
`%c[FeedDiag] ${entry.action}`,
|
||||
style,
|
||||
entry.durationMs != null ? `${entry.durationMs}ms` : "",
|
||||
entry.eventsReturned != null ? `${entry.eventsReturned} events` : "",
|
||||
entry.newestEventAge != null ? `newest: ${formatAge(entry.newestEventAge)}` : "",
|
||||
entry.error || "",
|
||||
entry.details || "",
|
||||
);
|
||||
if (isDev) {
|
||||
console.log(
|
||||
`%c[FeedDiag] ${entry.action}`,
|
||||
style,
|
||||
entry.durationMs != null ? `${entry.durationMs}ms` : "",
|
||||
entry.eventsReturned != null ? `${entry.eventsReturned} events` : "",
|
||||
entry.newestEventAge != null ? `newest: ${formatAge(entry.newestEventAge)}` : "",
|
||||
entry.error || "",
|
||||
entry.details || "",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function formatAge(seconds: number): string {
|
||||
@@ -208,6 +213,6 @@ if (typeof window !== "undefined") {
|
||||
|
||||
(window as unknown as Record<string, unknown>).__feedDiagClear = () => {
|
||||
localStorage.removeItem(DIAG_KEY);
|
||||
console.log("Feed diagnostics cleared");
|
||||
debug.log("Feed diagnostics cleared");
|
||||
};
|
||||
}
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
import "./lib/tauri-dev-mock"; // must be first — mocks Tauri invoke() in browser dev mode
|
||||
import { StrictMode, Component, type ReactNode } from "react";
|
||||
import { debug } from "./lib/debug";
|
||||
import { createRoot } from "react-dom/client";
|
||||
import App from "./App";
|
||||
import "./index.css";
|
||||
@@ -10,7 +11,7 @@ class ErrorBoundary extends Component<{ children: ReactNode }, { error: Error |
|
||||
state: { error: Error | null } = { error: null };
|
||||
static getDerivedStateFromError(error: Error) { return { error }; }
|
||||
componentDidCatch(error: Error, info: React.ErrorInfo) {
|
||||
console.error("[Vega] React error boundary caught:", error, info.componentStack);
|
||||
debug.error("[Vega] React error boundary caught:", error, info.componentStack);
|
||||
}
|
||||
render() {
|
||||
if (this.state.error) {
|
||||
|
||||
Reference in New Issue
Block a user