fix: remove console.log statements, use console.debug where needed
Per Obsidian plugin submission requirements, only console.warn, console.error, and console.debug are allowed. Changes: - Removed console.log from main.ts (API key generation and migration) - Removed console.log from mcp-server.ts (server start/stop messages) - Replaced console.log with console.debug in notifications.ts - Updated tests to expect console.debug instead of console.log All functionality is preserved - server status is still shown via Notice and status bar, and tool calls are still logged when enabled.
This commit is contained in:
@@ -18,7 +18,6 @@ export default class MCPServerPlugin extends Plugin {
|
|||||||
|
|
||||||
// Auto-generate API key if not set
|
// Auto-generate API key if not set
|
||||||
if (!this.settings.apiKey || this.settings.apiKey.trim() === '') {
|
if (!this.settings.apiKey || this.settings.apiKey.trim() === '') {
|
||||||
console.log('Generating new API key...');
|
|
||||||
this.settings.apiKey = generateApiKey();
|
this.settings.apiKey = generateApiKey();
|
||||||
await this.saveSettings();
|
await this.saveSettings();
|
||||||
}
|
}
|
||||||
@@ -30,7 +29,6 @@ export default class MCPServerPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
const legacySettings = this.settings as LegacySettings;
|
const legacySettings = this.settings as LegacySettings;
|
||||||
if ('enableCORS' in legacySettings || 'allowedOrigins' in legacySettings) {
|
if ('enableCORS' in legacySettings || 'allowedOrigins' in legacySettings) {
|
||||||
console.log('Migrating legacy CORS settings...');
|
|
||||||
delete legacySettings.enableCORS;
|
delete legacySettings.enableCORS;
|
||||||
delete legacySettings.allowedOrigins;
|
delete legacySettings.allowedOrigins;
|
||||||
await this.saveSettings();
|
await this.saveSettings();
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ export class MCPServer {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
this.server = this.app.listen(this.settings.port, '127.0.0.1', () => {
|
this.server = this.app.listen(this.settings.port, '127.0.0.1', () => {
|
||||||
console.log(`MCP Server listening on http://127.0.0.1:${this.settings.port}/mcp`);
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -126,7 +125,6 @@ export class MCPServer {
|
|||||||
if (err) {
|
if (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
} else {
|
} else {
|
||||||
console.log('MCP Server stopped');
|
|
||||||
this.server = null;
|
this.server = null;
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ export class NotificationManager {
|
|||||||
|
|
||||||
// Log to console if enabled
|
// Log to console if enabled
|
||||||
if (this.settings.logToConsole) {
|
if (this.settings.logToConsole) {
|
||||||
console.log(`[MCP] Tool call: ${toolName}`, args);
|
console.debug(`[MCP] Tool call: ${toolName}`, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ describe('NotificationManager', () => {
|
|||||||
settings.logToConsole = true;
|
settings.logToConsole = true;
|
||||||
manager = new NotificationManager(app, settings);
|
manager = new NotificationManager(app, settings);
|
||||||
|
|
||||||
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
|
const consoleSpy = jest.spyOn(console, 'debug').mockImplementation();
|
||||||
|
|
||||||
manager.showToolCall('read_note', { path: 'test.md' });
|
manager.showToolCall('read_note', { path: 'test.md' });
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ describe('NotificationManager', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not log to console when disabled', () => {
|
it('should not log to console when disabled', () => {
|
||||||
const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
|
const consoleSpy = jest.spyOn(console, 'debug').mockImplementation();
|
||||||
|
|
||||||
manager.showToolCall('read_note', { path: 'test.md' });
|
manager.showToolCall('read_note', { path: 'test.md' });
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user