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:
@@ -2,8 +2,11 @@
|
||||
|
||||
import { ActionInputLookUpDictionary, ActionOutputLookUpDictionary, validateActionInputLookUpDictionary } from "./dictionary-action-dto";
|
||||
import { ValidateError } from "@/lib/errors";
|
||||
import { createLogger } from "@/lib/logger";
|
||||
import { serviceLookUp } from "./dictionary-service";
|
||||
|
||||
const log = createLogger("dictionary-action");
|
||||
|
||||
export const actionLookUpDictionary = async (dto: ActionInputLookUpDictionary): Promise<ActionOutputLookUpDictionary> => {
|
||||
try {
|
||||
return {
|
||||
@@ -18,7 +21,7 @@ export const actionLookUpDictionary = async (dto: ActionInputLookUpDictionary):
|
||||
message: e.message
|
||||
};
|
||||
}
|
||||
console.log(e);
|
||||
log.error("Dictionary lookup failed", { error: e });
|
||||
return {
|
||||
success: false,
|
||||
message: 'Unknown error occured.'
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import { executeDictionaryLookup } from "@/lib/bigmodel/dictionary/orchestrator";
|
||||
import { repoCreateLookUp, repoCreateLookUpWithItemAndEntries, repoSelectLastLookUpResult } from "./dictionary-repository";
|
||||
import { ServiceInputLookUp } from "./dictionary-service-dto";
|
||||
import { createLogger } from "@/lib/logger";
|
||||
|
||||
const log = createLogger("dictionary-service");
|
||||
|
||||
export const serviceLookUp = async (dto: ServiceInputLookUp) => {
|
||||
const {
|
||||
@@ -39,7 +42,7 @@ export const serviceLookUp = async (dto: ServiceInputLookUp) => {
|
||||
},
|
||||
response.entries
|
||||
).catch(error => {
|
||||
console.error('Failed to save dictionary data:', error);
|
||||
log.error("Failed to save dictionary data", { error });
|
||||
});
|
||||
|
||||
return response;
|
||||
@@ -51,7 +54,7 @@ export const serviceLookUp = async (dto: ServiceInputLookUp) => {
|
||||
definitionLang: definitionLang,
|
||||
dictionaryItemId: lastLookUpResult.id
|
||||
}).catch(error => {
|
||||
console.error('Failed to save dictionary data:', error);
|
||||
log.error("Failed to save dictionary data", { error });
|
||||
});
|
||||
return {
|
||||
standardForm: lastLookUpResult.standardForm,
|
||||
|
||||
Reference in New Issue
Block a user