日志控制

This commit is contained in:
chen wei bo
2025-09-21 20:25:42 +08:00
parent 8f90c1d7cf
commit e78f6b937e
13 changed files with 122 additions and 107 deletions
+15 -14
View File
@@ -3,6 +3,7 @@ import { Dialog } from "./DialogData";
import { ConfigManager } from "../manager/ConfigManager";
import { DataId, DataManager } from "./DataManager";
import { GirlData } from "./GirlData";
import { logger } from "db://assets/Scripts/Main/Common/Logger";
/**
* 单个角色的聊天数据结构
@@ -44,7 +45,7 @@ export class ChatModel {
*/
public initializeRole(categoryId: string, girlId: number): boolean {
if (girlId <= 0) {
console.error("ChatModel: Invalid roleId provided");
logger.error("ChatModel: Invalid roleId provided");
return false;
}
@@ -52,7 +53,7 @@ export class ChatModel {
if (this.rolesData.has(girlId)) {
this.currentGirlId = girlId;
this.updateLastActiveTime(girlId);
console.log(`ChatModel: Switched to existing role ${girlId}`);
logger.log(`ChatModel: Switched to existing role ${girlId}`);
return true;
}
@@ -64,7 +65,7 @@ export class ChatModel {
this.rolesData.set(girlId, newRoleData);
this.currentGirlId = girlId;
console.log(`ChatModel: Initialized new role ${girlId}`);
logger.log(`ChatModel: Initialized new role ${girlId}`);
return true;
}
@@ -152,7 +153,7 @@ export class ChatModel {
if (oldestRoleId !== null) {
this.rolesData.delete(oldestRoleId);
console.log(`ChatModel: Cleaned up unused role ${oldestRoleId} data`);
logger.log(`ChatModel: Cleaned up unused role ${oldestRoleId} data`);
}
}
@@ -238,7 +239,7 @@ export class ChatModel {
public clearDialogs(roleId?: number): void {
const targetRoleId = roleId || this.currentGirlId;
if (!targetRoleId) {
console.warn("ChatModel: Cannot clear dialogs - no active role");
logger.warn("ChatModel: Cannot clear dialogs - no active role");
return;
}
@@ -246,7 +247,7 @@ export class ChatModel {
if (roleData) {
roleData.dialogs = [];
this.updateLastActiveTime(targetRoleId);
console.log(`ChatModel: Dialogs cleared for role ${targetRoleId}`);
logger.log(`ChatModel: Dialogs cleared for role ${targetRoleId}`);
}
}
@@ -272,13 +273,13 @@ export class ChatModel {
public setCurrentEmotion(emotion: VideoEmotion, roleId?: number): void {
const targetRoleId = roleId || this.currentGirlId;
if (!targetRoleId) {
console.warn("ChatModel: Cannot set emotion - no active role");
logger.warn("ChatModel: Cannot set emotion - no active role");
return;
}
const roleData = this.rolesData.get(targetRoleId);
if (!roleData) {
console.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`);
logger.warn(`ChatModel: Role data not found for roleId ${targetRoleId}`);
return;
}
@@ -286,7 +287,7 @@ export class ChatModel {
const oldEmotion = roleData.currentEmotion;
roleData.currentEmotion = emotion;
this.updateLastActiveTime(targetRoleId);
console.log(
logger.log(
`ChatModel: Role ${targetRoleId} emotion changed from ${VideoEmotion[oldEmotion]} to ${VideoEmotion[emotion]}`
);
}
@@ -423,7 +424,7 @@ export class ChatModel {
public reset(): void {
this.rolesData.clear();
this.currentGirlId = null;
console.log(
logger.log(
"ChatModel: All role data cleared and model reset to initial state"
);
}
@@ -441,7 +442,7 @@ export class ChatModel {
this.currentGirlId = null;
}
console.log(`ChatModel: Role ${roleId} data cleared`);
logger.log(`ChatModel: Role ${roleId} data cleared`);
}
}
@@ -452,13 +453,13 @@ export class ChatModel {
public validate(roleId?: number): boolean {
const targetRoleId = roleId || this.currentGirlId;
if (!targetRoleId) {
console.error("ChatModel: No active role");
logger.error("ChatModel: No active role");
return false;
}
const roleData = this.rolesData.get(targetRoleId);
if (!roleData) {
console.error(`ChatModel: Role data not found for ${targetRoleId}`);
logger.error(`ChatModel: Role data not found for ${targetRoleId}`);
return false;
}
return true;
@@ -500,7 +501,7 @@ export class ChatModel {
public setMaxCachedRoles(maxCount: number): void {
if (maxCount > 0) {
this.maxCachedRoles = maxCount;
console.log(`ChatModel: Max cached roles set to ${maxCount}`);
logger.log(`ChatModel: Max cached roles set to ${maxCount}`);
// 如果当前缓存超过新限制,清理多余的
this.manageMemory();
+2 -1
View File
@@ -3,6 +3,7 @@
*/
import { BaseData } from "./BaseData";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
import { logger } from "db://assets/Scripts/Main/Common/Logger";
export class ShopData extends BaseData {
// 商品数据
@@ -41,7 +42,7 @@ export class ShopData extends BaseData {
this._goods.set(vo.id, vo);
this._goodIds.push(vo.id);
}
console.log("设置商品数据:", this._goods);
logger.log("设置商品数据:", this._goods);
}
/** 获取所有商品数据 */
+2 -1
View File
@@ -3,6 +3,7 @@
*/
import { BaseData } from "./BaseData";
import proto from 'db://assets/Scripts/proto/proto.pb.js';
import { logger } from "db://assets/Scripts/Main/Common/Logger";
export class ThemeData extends BaseData {
// 主题数据
@@ -43,7 +44,7 @@ export class ThemeData extends BaseData {
this._themes.set(vo.id, vo);
this._themeIds.push(vo.id);
}
console.log("设置主题数据:", this._themes);
logger.log("设置主题数据:", this._themes);
}
/** 获取所有主题数据 */