mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-21 16:01:35 +08:00
* Revert "feat: optimize minapp cache with LRU (#8160)"
This reverts commit f0043b4be5.
* feat: integrate logger service and enhance logging throughout the application
- Added a new LoggerService to standardize logging across the application.
- Replaced console.error and console.warn calls with logger methods for improved consistency and error tracking.
- Introduced a new IPC channel for logging messages to the main process.
- Updated various components and services to utilize the new logging system, enhancing error handling and debugging capabilities.
* refactor: enhance logging and error handling across various components
- Integrated the LoggerService for consistent logging throughout the application.
- Updated multiple components and services to utilize the new logging system, improving error tracking and debugging capabilities.
- Refactored file handling and error management in several services to enhance reliability and clarity.
- Improved the structure and readability of the codebase by removing redundant checks and simplifying logic.
* chore: update TypeScript configuration and enhance test setup
- Added test mock paths to tsconfig.web.json for improved test coverage.
- Configured Vitest to include a setup file for main tests, ensuring consistent test environment.
- Updated IPC logger context for better clarity in logging.
- Enhanced LoggerService to handle undefined values gracefully.
- Mocked LoggerService globally in renderer tests to streamline testing process.
* refactor: standardize logging across ProxyManager and ReduxService
- Replaced instances of Logger with logger for consistent logging implementation.
- Improved logging clarity in ProxyManager's configureProxy method and ReduxService's state handling.
- Enhanced error logging in ReduxService to align with the new logging system.
* refactor: reorganize LoggerService for improved clarity and consistency
- Moved the definition of SYSTEM_INFO, APP_VERSION, and DEFAULT_LEVEL to enhance code organization.
- Simplified the getIsDev function in the renderer LoggerService for better readability.
- Updated logging conditions to ensure messages are logged correctly based on context.
* docs: add usage instructions for LoggerService and clean up logging code
- Included important usage instructions for LoggerService in both English and Chinese.
- Commented out the console transport in LoggerService to streamline logging.
- Improved logging message formatting in MCPService for clarity.
- Removed redundant logging statements in SelectionService to enhance code cleanliness.
* refactor: update LoggerService documentation paths and enhance logging implementation
- Changed the documentation paths for LoggerService usage instructions to `docs/technical/how-to-use-logger-en.md` and `docs/technical/how-to-use-logger-zh.md`.
- Replaced console logging with the loggerService in various components, including `MCPSettings`, `BlockManager`, and multiple callback files, to ensure consistent logging practices across the application.
- Improved the clarity and context of log messages for better debugging and monitoring.
* docs: emphasize logger usage guidelines in documentation
- Added a note in both English and Chinese documentation to discourage the use of `console.xxx` for logging unless necessary, promoting consistent logging practices across the application.
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
|
|
// Simple mock LoggerService class for main process
|
|
export class MockMainLoggerService {
|
|
private static instance: MockMainLoggerService
|
|
|
|
public static getInstance(): MockMainLoggerService {
|
|
if (!MockMainLoggerService.instance) {
|
|
MockMainLoggerService.instance = new MockMainLoggerService()
|
|
}
|
|
return MockMainLoggerService.instance
|
|
}
|
|
|
|
public static resetInstance(): void {
|
|
MockMainLoggerService.instance = new MockMainLoggerService()
|
|
}
|
|
|
|
public withContext(): MockMainLoggerService {
|
|
return this
|
|
}
|
|
public finish(): void {}
|
|
public setLevel(): void {}
|
|
public getLevel(): string {
|
|
return 'silly'
|
|
}
|
|
public resetLevel(): void {}
|
|
public getLogsDir(): string {
|
|
return '/mock/logs'
|
|
}
|
|
public getBaseLogger(): any {
|
|
return {}
|
|
}
|
|
public error(...args: any[]): void {
|
|
console.error(...args)
|
|
}
|
|
public warn(...args: any[]): void {
|
|
console.warn(...args)
|
|
}
|
|
public info(...args: any[]): void {
|
|
console.info(...args)
|
|
}
|
|
public verbose(...args: any[]): void {
|
|
console.log(...args)
|
|
}
|
|
public debug(...args: any[]): void {
|
|
console.debug(...args)
|
|
}
|
|
public silly(...args: any[]): void {
|
|
console.log(...args)
|
|
}
|
|
}
|
|
|
|
// Create and export the mock instance
|
|
export const mockMainLoggerService = MockMainLoggerService.getInstance()
|
|
|
|
// Mock the LoggerService module for main process
|
|
const MainLoggerServiceMock = {
|
|
LoggerService: MockMainLoggerService,
|
|
loggerService: mockMainLoggerService
|
|
}
|
|
|
|
export default MainLoggerServiceMock
|