Skip to main content
Glama

bnbchain-mcp

Official
by bnb-chain
logger.ts1.72 kB
import * as util from "node:util" enum LogLevel { DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3 } type LogLevelStrings = keyof typeof LogLevel class Logger { private static currentLevel: LogLevel = Logger.getLogLevelFromEnv() private static getLogLevelFromEnv(): LogLevel { const envLevel = ( process.env.LOG_LEVEL || "INFO" ).toUpperCase() as LogLevelStrings return LogLevel[envLevel] ?? LogLevel.INFO } private static shouldLog(level: LogLevel): boolean { return level >= this.currentLevel } private static formatMessage( level: LogLevelStrings, message: string, meta?: any ): string { const timestamp = new Date().toISOString() const metaStr = meta ? " " + util.inspect(meta, { depth: 5, colors: true }) : "" return `[${timestamp}] ${level}: ${message}${metaStr}` } static setLogLevel(level: LogLevelStrings) { this.currentLevel = LogLevel[level] } static debug(message: string, meta?: any) { if (this.shouldLog(LogLevel.DEBUG)) { console.debug(this.formatMessage("DEBUG", message, meta)) } } static info(message: string, meta?: any) { if (this.shouldLog(LogLevel.INFO)) { console.info(this.formatMessage("INFO", message, meta)) } } static warn(message: string, meta?: any) { if (this.shouldLog(LogLevel.WARN)) { console.warn(this.formatMessage("WARN", message, meta)) } } static error(message: string, meta?: any) { if (this.shouldLog(LogLevel.ERROR)) { console.error(this.formatMessage("ERROR", message, meta)) } } static getLevel(): LogLevelStrings { return LogLevel[this.currentLevel] as LogLevelStrings } } export default Logger

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/bnb-chain/bnbchain-mcp'

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