diff --git a/src/app/chat/components/chat-input-bar.tsx b/src/app/chat/components/chat-input-bar.tsx index 2bc32532..27c42de0 100644 --- a/src/app/chat/components/chat-input-bar.tsx +++ b/src/app/chat/components/chat-input-bar.tsx @@ -31,12 +31,6 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) { containerRef: barRef, active: isFocused, onKeyboardDismiss: () => { - log.important("info", "[chat-input-bar] keyboard dismissed", { - contentLength: input.length, - hasContent, - disabled, - wasFocused: isFocused, - }); setIsFocused(false); }, }); @@ -45,21 +39,11 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) { setInput(value); }; - const handleFocusChange = (focused: boolean) => { - log.important("info", "[chat-input-bar] focus change", { - focused, - contentLength: input.length, - hasContent, - disabled, - }); - setIsFocused(focused); - }; - const handleSend = (source: "click" | "keyboard" | "pointerdown") => { if (source === "click") { const elapsed = Date.now() - lastPointerSendAtRef.current; if (elapsed >= 0 && elapsed < POINTER_SEND_CLICK_DEDUPE_MS) { - log.important("info", "[chat-input-bar] suppress duplicate click", { + log.debug("[chat-input-bar] suppress duplicate click", { elapsed, contentLength: input.length, hasContent, @@ -78,13 +62,6 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) { disabled, isFocused, }); - log.important("info", "[chat-input-bar] send", { - source, - contentLength: input.length, - hasContent, - disabled, - isFocused, - }); dispatch({ type: "ChatSendMessage", content: input }); setInput(""); textareaRef.current?.focus(); @@ -106,7 +83,7 @@ export function ChatInputBar({ disabled = false }: ChatInputBarProps) { value={input} onChange={handleInputChange} onSubmit={() => handleSend("keyboard")} - onFocusChange={handleFocusChange} + onFocusChange={setIsFocused} disabled={disabled} /> { timeoutIds.forEach((id) => window.clearTimeout(id)); @@ -103,7 +99,7 @@ export function useKeyboardHeight({ lastInputLift = nextLift; setInputLiftVar(nextLift); - log.important("info", "[keyboard] apply", { + log.debug("[keyboard] apply", { reason, inputLift: nextLift, fallback: nextLift === FALLBACK_INPUT_LIFT_PX, @@ -118,7 +114,7 @@ export function useKeyboardHeight({ applyLift(0, reason); blurKeyboardTarget(targetRef?.current); onKeyboardDismissRef.current?.(); - log.important("info", "[keyboard] released", { + log.debug("[keyboard] released", { reason, snapshot: formatSnapshot(readKeyboardSnapshot()), }); @@ -175,7 +171,7 @@ export function useKeyboardHeight({ const target = targetRef?.current; const container = containerRef?.current; if (event.target instanceof Node && container?.contains(event.target)) { - log.important("info", "[keyboard] keep active for input container tap", { + log.debug("[keyboard] keep active for input container tap", { snapshot: formatSnapshot(readKeyboardSnapshot()), }); return; diff --git a/src/utils/logger-sentry-reporter.ts b/src/utils/logger-sentry-reporter.ts index 1a5b2fcb..6347d740 100644 --- a/src/utils/logger-sentry-reporter.ts +++ b/src/utils/logger-sentry-reporter.ts @@ -1,7 +1,7 @@ import * as Sentry from "@sentry/nextjs"; import type { CaptureContext, SeverityLevel } from "@sentry/nextjs"; -export type RemoteLogLevel = "debug" | "info" | "warn" | "error" | "fatal"; +export type RemoteLogLevel = "warn" | "error" | "fatal"; export interface SentryLogPayload { level: RemoteLogLevel; diff --git a/src/utils/logger.ts b/src/utils/logger.ts index f4805828..22091916 100644 --- a/src/utils/logger.ts +++ b/src/utils/logger.ts @@ -79,11 +79,6 @@ export class Logger { this.write("fatal", args); } - important(level: RemoteLogLevel, ...args: LogArgs): void { - Logger.reportProductionLog(level, this.component, args, true); - this.writeLocal(level, args); - } - /** * 把日志中的任意数据转成人眼友好的多行文本。 * - object / array: pretty JSON @@ -151,11 +146,8 @@ export class Logger { } private write(level: LogLevel, args: LogArgs): void { - Logger.reportProductionLog(level, this.component, args); - this.writeLocal(level, args); - } + Logger.reportImportantProductionLog(level, this.component, args); - private writeLocal(level: LogLevel, args: LogArgs): void { if (Logger.shouldUseBrowserConsole()) { Logger.writeBrowserConsole(level, this.component, args); return; @@ -192,14 +184,12 @@ export class Logger { ); } - private static reportProductionLog( + private static reportImportantProductionLog( level: LogLevel, component: string, args: LogArgs, - force = false, ): void { - if (!force && !Logger.shouldReportToRemote(level)) return; - if (force && !AppEnvUtil.isProduction()) return; + if (!Logger.shouldReportToRemote(level)) return; const { message, data } = Logger.toBrowserConsolePayload(args); reportSentryLog({