mcp-server-debug-thinking
Version:
Graph-based MCP server for systematic debugging using Problem-Solution Trees and Hypothesis-Experiment-Learning cycles
75 lines • 2.52 kB
JavaScript
import chalk from "chalk";
export var LogLevel;
(function (LogLevel) {
LogLevel[LogLevel["DEBUG"] = 0] = "DEBUG";
LogLevel[LogLevel["INFO"] = 1] = "INFO";
LogLevel[LogLevel["WARN"] = 2] = "WARN";
LogLevel[LogLevel["ERROR"] = 3] = "ERROR";
LogLevel[LogLevel["NONE"] = 4] = "NONE";
})(LogLevel || (LogLevel = {}));
export class Logger {
level;
disableLogging;
constructor() {
this.disableLogging = (process.env.DISABLE_DEBUG_LOGGING || "").toLowerCase() === "true";
this.level = this.disableLogging ? LogLevel.NONE : LogLevel.INFO;
// ログレベルのオーバーライドを許可
const envLevel = process.env.DEBUG_LOG_LEVEL?.toUpperCase();
if (envLevel && envLevel in LogLevel) {
this.level = LogLevel[envLevel];
}
}
debug(message, ...args) {
if (this.level <= LogLevel.DEBUG) {
console.error(chalk.gray(`[DEBUG] ${message}`), ...args);
}
}
info(message, ...args) {
if (this.level <= LogLevel.INFO) {
console.error(message, ...args);
}
}
warn(message, ...args) {
if (this.level <= LogLevel.WARN) {
console.error(chalk.yellow(message), ...args);
}
}
error(message, ...args) {
if (this.level <= LogLevel.ERROR) {
console.error(chalk.red(message), ...args);
}
}
success(message, ...args) {
if (this.level <= LogLevel.INFO) {
console.error(chalk.green(message), ...args);
}
}
dim(message, ...args) {
if (this.level <= LogLevel.INFO) {
console.error(chalk.dim(message), ...args);
}
}
bold(message, ...args) {
if (this.level <= LogLevel.INFO) {
console.error(chalk.bold(message), ...args);
}
}
session(action, sessionId) {
if (this.level <= LogLevel.INFO) {
if (action === "start") {
console.error(chalk.bold.blue(`\n🚀 Started debug session: ${sessionId}\n`));
}
else {
console.error(chalk.bold.red(`\n🏁 Ended debug session: ${sessionId}\n`));
}
}
}
search(query, resultCount) {
if (this.level <= LogLevel.INFO) {
console.error(chalk.cyan("🔍 Searching with query:"), query);
console.error(chalk.green(`✓ Found ${resultCount} matches`));
}
}
}
export const logger = new Logger();
//# sourceMappingURL=logger.js.map