Skip to main content
Glama
LogAnalyzer.ts1.99 kB
import { BaseDiagnosticTool } from './BaseDiagnosticTool'; import { DiagnosticReport, DiagnosticResult, DiagnosticStatus } from '../types'; import fs from 'fs'; import path from 'path'; export class LogAnalyzer extends BaseDiagnosticTool { public readonly name = 'LogAnalyzer'; public readonly description = 'Analyzes application logs for errors and patterns.'; // In a real implementation, this would be configurable private logFilePath = path.resolve(process.cwd(), 'logs/app.log'); public async run(): Promise<DiagnosticReport> { const results: DiagnosticResult[] = []; let overallStatus: DiagnosticStatus = 'passing'; const logFileResult = this.checkLogFile(); results.push(logFileResult); if (logFileResult.status !== 'passing') { overallStatus = logFileResult.status; } else { // If the log file exists, we could analyze it. // For now, we'll just report that it's present. } return { tool: this.name, timestamp: new Date(), overallStatus, results, }; } private checkLogFile(): DiagnosticResult { try { if (fs.existsSync(this.logFilePath)) { const stats = fs.statSync(this.logFilePath); return { check: 'Log File Existence', status: 'passing', message: `Log file found at ${this.logFilePath}.`, details: { size: stats.size, lastModified: stats.mtime } }; } else { return { check: 'Log File Existence', status: 'warning', message: `Log file not found at ${this.logFilePath}.`, details: 'Logging may not be configured or no logs have been generated yet.' }; } } catch (error) { return { check: 'Log File Existence', status: 'failing', message: 'Error checking for log file.', details: error instanceof Error ? error.message : String(error), }; } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/learnwithcc/tally-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server