refactor[Logger]: replace console logging with logger service (#8271)

* refactor: replace console logging with logger service across multiple components

- Updated various files to utilize the logger service instead of console.log for improved logging consistency and error tracking.
- Enhanced logging levels to better categorize messages, including debug and error levels.
- Refactored logging in components such as ApiClientFactory, KnowledgeService, and MemoryProcessor to align with the new logging standards.

* refactor: update logging level in App component from error to info

- Changed the logging level in the App component to provide a more appropriate context for initialization messages, enhancing clarity in the logging output.

* refactor(logging): replace console.log with logger service in middleware and update ESLint comments

- Updated the logging implementation in the createSimpleLoggingMiddleware function to use logger.debug and logger.error instead of console.log and console.error for improved logging consistency.
- Added eslint-disable comments for restricted syntax in preload and useAppInit hooks to suppress warnings.
This commit is contained in:
fullex
2025-07-18 16:01:03 +08:00
committed by GitHub
parent f9c5ca258a
commit 7764ffc8bb
32 changed files with 118 additions and 75 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ class FileStorage {
findDuplicateFile = async (filePath: string): Promise<FileMetadata | null> => {
const stats = fs.statSync(filePath)
console.log('stats', stats, filePath)
logger.debug('stats', stats, filePath)
const fileSize = stats.size
const files = await fs.promises.readdir(this.storageDir)
+1 -1
View File
@@ -156,7 +156,7 @@ class KnowledgeService {
}
public delete = async (_: Electron.IpcMainInvokeEvent, id: string): Promise<void> => {
console.log('id', id)
logger.debug('delete id', id)
const dbPath = path.join(this.storageDir, id)
if (fs.existsSync(dbPath)) {
fs.rmSync(dbPath, { recursive: true })
+1 -1
View File
@@ -622,7 +622,7 @@ class McpService {
const client = await this.initClient(server)
const result = await client.callTool({ name, arguments: args }, undefined, {
onprogress: (process) => {
console.log('[MCP] Progress:', process.progress / (process.total || 1))
logger.debug(`Progress: ${process.progress / (process.total || 1)}`)
window.api.mcp.setProgress(process.progress / (process.total || 1))
},
timeout: server.timeout ? server.timeout * 1000 : 60000, // Default timeout of 1 minute