refactor(logging): centralize console output
This commit is contained in:
@@ -13,6 +13,9 @@ import { ROUTES } from "@/router/routes";
|
||||
|
||||
import { AuthBackground, AuthPanel } from "./components";
|
||||
import styles from "./components/auth-screen.module.css";
|
||||
import { Logger } from "@/utils";
|
||||
|
||||
const log = new Logger("AppAuthAuthScreen");
|
||||
|
||||
export function AuthScreen() {
|
||||
const state = useAuthState();
|
||||
@@ -23,7 +26,7 @@ export function AuthScreen() {
|
||||
// 用 pendingRedirect flag(不是 useRef transition detection)——
|
||||
// re-mount 时 flag 在 auth context 里持久,区分"刚按了"和"re-visit"准确无误。
|
||||
useEffect(() => {
|
||||
console.log("[auth-screen] useEffect (loginStatus + pendingRedirect)", {
|
||||
log.debug("[auth-screen] useEffect (loginStatus + pendingRedirect)", {
|
||||
pending: state.pendingRedirect,
|
||||
loginStatus: state.loginStatus,
|
||||
willRedirect:
|
||||
@@ -31,7 +34,7 @@ export function AuthScreen() {
|
||||
});
|
||||
|
||||
if (state.pendingRedirect && state.loginStatus !== "notLoggedIn") {
|
||||
console.log(
|
||||
log.debug(
|
||||
"[auth-screen] useEffect → router.replace(/chat) [via pendingRedirect flag]",
|
||||
);
|
||||
authDispatch({ type: "AuthClearPendingRedirect" });
|
||||
|
||||
@@ -14,6 +14,9 @@ import { AuthTextField } from "./auth-text-field";
|
||||
import { AuthPrimaryButton } from "./auth-primary-button";
|
||||
import { AuthErrorMessage } from "./auth-error-message";
|
||||
import styles from "./email-form.module.css";
|
||||
import { Logger } from "@/utils";
|
||||
|
||||
const log = new Logger("AppAuthComponentsEmailLoginForm");
|
||||
|
||||
export interface EmailLoginFormProps {
|
||||
globalError?: string | null;
|
||||
@@ -44,7 +47,7 @@ export function EmailLoginForm({
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
console.log("[email-login-form] submit ENTRY", {
|
||||
log.debug("[email-login-form] submit ENTRY", {
|
||||
emailLength: email.length,
|
||||
emailPreview: email.slice(0, 8),
|
||||
passwordLength: password.length,
|
||||
@@ -53,7 +56,7 @@ export function EmailLoginForm({
|
||||
const passwordErr = validatePassword(password);
|
||||
if (emailErr || passwordErr) {
|
||||
const firstErr = emailErr ?? passwordErr ?? null;
|
||||
console.warn(
|
||||
log.warn(
|
||||
"[email-login-form] submit VALIDATION FAILED (silent return)",
|
||||
{ emailErr, passwordErr, surfaced: firstErr },
|
||||
);
|
||||
@@ -61,7 +64,7 @@ export function EmailLoginForm({
|
||||
return;
|
||||
}
|
||||
setValidationError(null);
|
||||
console.log("[email-login-form] submit dispatching AuthEmailLoginSubmitted");
|
||||
log.debug("[email-login-form] submit dispatching AuthEmailLoginSubmitted");
|
||||
dispatch({ type: "AuthEmailLoginSubmitted", email, password });
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,9 @@ import { AuthTextField } from "./auth-text-field";
|
||||
import { AuthPrimaryButton } from "./auth-primary-button";
|
||||
import { AuthErrorMessage } from "./auth-error-message";
|
||||
import styles from "./email-form.module.css";
|
||||
import { Logger } from "@/utils";
|
||||
|
||||
const log = new Logger("AppAuthComponentsEmailRegisterForm");
|
||||
|
||||
export interface EmailRegisterFormProps {
|
||||
globalError?: string | null;
|
||||
@@ -66,7 +69,7 @@ export function EmailRegisterForm({
|
||||
};
|
||||
|
||||
const submit = () => {
|
||||
console.log("[email-register-form] submit ENTRY", {
|
||||
log.debug("[email-register-form] submit ENTRY", {
|
||||
emailLength: email.length,
|
||||
emailPreview: email.slice(0, 8),
|
||||
passwordLength: password.length,
|
||||
@@ -81,7 +84,7 @@ export function EmailRegisterForm({
|
||||
// 按 username → email → password → confirm 顺序挑第一个错(与字段顺序一致)
|
||||
const firstErr =
|
||||
usernameErr ?? emailErr ?? passwordErr ?? confirmErr ?? null;
|
||||
console.warn(
|
||||
log.warn(
|
||||
"[email-register-form] submit VALIDATION FAILED (silent return)",
|
||||
{
|
||||
emailErr,
|
||||
@@ -95,7 +98,7 @@ export function EmailRegisterForm({
|
||||
return;
|
||||
}
|
||||
setValidationError(null);
|
||||
console.log(
|
||||
log.debug(
|
||||
"[email-register-form] submit dispatching AuthEmailRegisterSubmitted",
|
||||
);
|
||||
dispatch({
|
||||
|
||||
Reference in New Issue
Block a user