feat: adds proper logging support
This commit is contained in:
13 files changed
+187
-38
No files matched your search
@@ -5,7 +5,8 @@ import type {
|
||||
} from '@modelcontextprotocol/sdk/types.js';
|
||||
import params, { type QueryParams } from './params.js';
|
||||
import API from '../../BraveAPI/index.js';
|
||||
import { log, stringify } from '../../utils.js';
|
||||
import { stringify } from '../../utils.js';
|
||||
import ClientLogger from '../../ClientLogger.js';
|
||||
|
||||
export const name = 'brave_image_search';
|
||||
|
||||
@@ -44,7 +45,7 @@ export const execute = async (params: QueryParams) => {
|
||||
};
|
||||
|
||||
async function fetchImage(url: string): Promise<{ mimeType: string; data: string } | null> {
|
||||
await log('info', `Fetching image data from ${url}`);
|
||||
await ClientLogger.log('info', `Fetching image data from ${url}`);
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const buffer = await response.arrayBuffer();
|
||||
@@ -53,7 +54,7 @@ async function fetchImage(url: string): Promise<{ mimeType: string; data: string
|
||||
mimeType: response.headers.get('content-type') ?? 'image/jpeg',
|
||||
};
|
||||
} catch (error) {
|
||||
await log('error', `Error fetching image data from ${url}: ${error}`);
|
||||
await ClientLogger.log('error', `Error fetching image data from ${url}: ${error}`);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ import webParams, { type QueryParams as WebQueryParams } from '../web/params.js'
|
||||
import type { CallToolResult, ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
||||
import API from '../../BraveAPI/index.js';
|
||||
import { formatWebResults } from '../web/index.js';
|
||||
import { log, stringify } from '../../utils.js';
|
||||
import { stringify } from '../../utils.js';
|
||||
import { WebSearchApiResponse } from '../web/types.js';
|
||||
|
||||
export const name = 'brave_local_search';
|
||||
|
||||
@@ -3,7 +3,7 @@ import { summarizerQueryParams, type SummarizerQueryParams } from './params.js';
|
||||
import API from '../../BraveAPI/index.js';
|
||||
import { type QueryParams as WebQueryParams } from '../web/params.js';
|
||||
import { SummarizerSearchApiResponse } from './types.js';
|
||||
import { log } from '../../utils.js';
|
||||
import ClientLogger from '../../ClientLogger.js';
|
||||
|
||||
export const name = 'brave_summarizer';
|
||||
|
||||
@@ -82,7 +82,7 @@ const pollForSummary = async (
|
||||
result = response;
|
||||
}
|
||||
} catch (error) {
|
||||
await log('error', `Error polling for summarizer results: ${error}`);
|
||||
await ClientLogger.log('error', `Error polling for summarizer results: ${error}`);
|
||||
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user