@@ -214,43 +214,43 @@ const consoleLogs: string[] = [];
214
214
const operationLogs : string [ ] = [ ] ;
215
215
216
216
function log ( message : string , level : 'info' | 'error' | 'debug' = 'info' ) {
217
- // const timestamp = new Date().toISOString();
218
- // const logMessage = `[${timestamp}] [${level.toUpperCase()}] ${message}`;
219
- // operationLogs.push(logMessage);
217
+ const timestamp = new Date ( ) . toISOString ( ) ;
218
+ const logMessage = `[${ timestamp } ] [${ level . toUpperCase ( ) } ] ${ message } ` ;
219
+ operationLogs . push ( logMessage ) ;
220
220
221
- // // Write to file
222
- // fs.appendFileSync(LOG_FILE, logMessage + '\n');
221
+ // Write to file
222
+ fs . appendFileSync ( LOG_FILE , logMessage + '\n' ) ;
223
223
224
- // // Console output to stderr
225
- // if (process.env.DEBUG || level === 'error') {
226
- // console.error(logMessage);
227
- // }
224
+ // Console output to stderr
225
+ if ( process . env . DEBUG || level === 'error' ) {
226
+ console . error ( logMessage ) ;
227
+ }
228
228
229
- // // Send logging message to client for important events
230
- // if (serverInstance && (level === 'info' || level === 'error')) {
231
- // serverInstance.sendLoggingMessage({
232
- // level: level,
233
- // data: message,
234
- // });
235
- // }
229
+ // Send logging message to client for important events
230
+ if ( serverInstance && ( level === 'info' || level === 'error' ) ) {
231
+ serverInstance . sendLoggingMessage ( {
232
+ level : level ,
233
+ data : message ,
234
+ } ) ;
235
+ }
236
236
}
237
237
238
238
function logRequest ( type : string , params : any ) {
239
- // const requestLog = {
240
- // timestamp: new Date().toISOString(),
241
- // type,
242
- // params,
243
- // };
244
- // log(`REQUEST: ${JSON.stringify(requestLog, null, 2)}`, 'debug');
239
+ const requestLog = {
240
+ timestamp : new Date ( ) . toISOString ( ) ,
241
+ type,
242
+ params,
243
+ } ;
244
+ log ( `REQUEST: ${ JSON . stringify ( requestLog , null , 2 ) } ` , 'debug' ) ;
245
245
}
246
246
247
247
function logResponse ( type : string , response : any ) {
248
- // const responseLog = {
249
- // timestamp: new Date().toISOString(),
250
- // type,
251
- // response,
252
- // };
253
- // log(`RESPONSE: ${JSON.stringify(responseLog, null, 2)}`, 'debug');
248
+ const responseLog = {
249
+ timestamp : new Date ( ) . toISOString ( ) ,
250
+ type,
251
+ response,
252
+ } ;
253
+ log ( `RESPONSE: ${ JSON . stringify ( responseLog , null , 2 ) } ` , 'debug' ) ;
254
254
}
255
255
256
256
// Ensure Stagehand is initialized
@@ -506,6 +506,7 @@ const server = new Server(
506
506
capabilities : {
507
507
resources : { } ,
508
508
tools : { } ,
509
+ logging : { } ,
509
510
} ,
510
511
}
511
512
) ;
0 commit comments