refactor: 替换服务端 console.log/error 为 winston logger
- folder-action.ts: 18处 console.log -> log.error - auth-action.ts: 4处 console.error -> log.error - dictionary-action/service.ts: 3处 -> log.error - translator-action/service.ts: 3处 -> log.error - bigmodel/translator/orchestrator.ts: console -> log.debug/info/error - bigmodel/tts.ts: console -> log.error/warn - bigmodel/dictionary/*.ts: console -> log.error/debug/info 客户端代码(browser、page.tsx)保留 console.error
This commit is contained in:
@@ -4,6 +4,7 @@ import { auth } from "@/auth";
|
||||
import { headers } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import { ValidateError } from "@/lib/errors";
|
||||
import { createLogger } from "@/lib/logger";
|
||||
import {
|
||||
ActionInputGetUserProfileByUsername,
|
||||
ActionInputSignIn,
|
||||
@@ -23,6 +24,8 @@ import {
|
||||
// Re-export types for use in components
|
||||
export type { ActionOutputAuth, ActionOutputUserProfile } from "./auth-action-dto";
|
||||
|
||||
const log = createLogger("auth-action");
|
||||
|
||||
/**
|
||||
* Sign up action
|
||||
* Creates a new user account
|
||||
@@ -68,7 +71,7 @@ export async function actionSignUp(prevState: ActionOutputAuth | undefined, form
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
console.error("Sign up error:", e);
|
||||
log.error("Sign up failed", { error: e });
|
||||
return {
|
||||
success: false,
|
||||
message: "Registration failed. Please try again later.",
|
||||
@@ -121,7 +124,7 @@ export async function actionSignIn(_prevState: ActionOutputAuth | undefined, for
|
||||
message: e.message,
|
||||
};
|
||||
}
|
||||
console.error("Sign in error:", e);
|
||||
log.error("Sign in failed", { error: e });
|
||||
return {
|
||||
success: false,
|
||||
message: "Sign in failed. Please check your credentials.",
|
||||
@@ -144,7 +147,7 @@ export async function signOutAction() {
|
||||
if (e instanceof Error && e.message.includes('NEXT_REDIRECT')) {
|
||||
throw e;
|
||||
}
|
||||
console.error("Sign out error:", e);
|
||||
log.error("Sign out failed", { error: e });
|
||||
redirect("/login");
|
||||
}
|
||||
}
|
||||
@@ -170,7 +173,7 @@ export async function actionGetUserProfileByUsername(dto: ActionInputGetUserProf
|
||||
data: userProfile,
|
||||
};
|
||||
} catch (e) {
|
||||
console.error("Get user profile error:", e);
|
||||
log.error("Get user profile failed", { error: e });
|
||||
return {
|
||||
success: false,
|
||||
message: "Failed to retrieve user profile",
|
||||
|
||||
Reference in New Issue
Block a user