@ai-capabilities-suite/mcp-debugger-core
Version:
Core debugging engine for Node.js and TypeScript applications. Provides Inspector Protocol integration, breakpoint management, variable inspection, execution control, profiling, hang detection, and source map support.
104 lines • 2.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AuditLogger = void 0;
/**
* Audit logger for debugging operations
* Logs all debugging operations with timestamps and context
*/
class AuditLogger {
constructor(maxLogs = 10000, logToConsole = false) {
this.logs = [];
this.maxLogs = maxLogs;
this.logToConsole = logToConsole;
}
/**
* Log a debugging operation
* @param sessionId Session identifier
* @param operation Operation name
* @param details Operation details
* @param success Whether the operation succeeded
* @param error Optional error message
* @param userId Optional user identifier
*/
log(sessionId, operation, details, success, error, userId) {
const entry = {
timestamp: new Date(),
sessionId,
operation,
details,
success,
error,
userId,
};
this.logs.push(entry);
// Implement log rotation
if (this.logs.length > this.maxLogs) {
this.logs.shift(); // Remove oldest log
}
// Optionally log to console
if (this.logToConsole) {
console.log(JSON.stringify(entry));
}
}
/**
* Get all audit logs
* @returns Array of audit log entries
*/
getAllLogs() {
return [...this.logs];
}
/**
* Get audit logs for a specific session
* @param sessionId Session identifier
* @returns Array of audit log entries for the session
*/
getSessionLogs(sessionId) {
return this.logs.filter((log) => log.sessionId === sessionId);
}
/**
* Get audit logs for a specific operation
* @param operation Operation name
* @returns Array of audit log entries for the operation
*/
getOperationLogs(operation) {
return this.logs.filter((log) => log.operation === operation);
}
/**
* Get failed operations
* @returns Array of audit log entries for failed operations
*/
getFailedOperations() {
return this.logs.filter((log) => !log.success);
}
/**
* Clear all audit logs
*/
clearLogs() {
this.logs = [];
}
/**
* Export logs as JSON
* @returns JSON string of all logs
*/
exportLogsAsJson() {
return JSON.stringify(this.logs, null, 2);
}
/**
* Get logs within a time range
* @param startTime Start time
* @param endTime End time
* @returns Array of audit log entries within the time range
*/
getLogsByTimeRange(startTime, endTime) {
return this.logs.filter((log) => log.timestamp >= startTime && log.timestamp <= endTime);
}
/**
* Get the number of logs
* @returns Number of logs
*/
getLogCount() {
return this.logs.length;
}
}
exports.AuditLogger = AuditLogger;
//# sourceMappingURL=audit-logger.js.map