Skip to main content
Glama
logger.ts1.43 kB
/** * Logger utility with timestamp formatting for server-side logging * All logs go to stderr to ensure compatibility with MCP communication */ export class Logger { private static formatTimestamp(): string { const now = new Date(); const year = now.getFullYear(); const month = String(now.getMonth() + 1).padStart(2, '0'); const day = String(now.getDate()).padStart(2, '0'); const hours = String(now.getHours()).padStart(2, '0'); const minutes = String(now.getMinutes()).padStart(2, '0'); const seconds = String(now.getSeconds()).padStart(2, '0'); const milliseconds = String(now.getMilliseconds()).padStart(3, '0'); return `[${year}-${month}-${day} ${hours}:${minutes}:${seconds}.${milliseconds}]`; } static log(...args: any[]): void { const timestamp = this.formatTimestamp(); console.error(timestamp, ...args); } static error(...args: any[]): void { const timestamp = this.formatTimestamp(); console.error(timestamp, '[ERROR]', ...args); } static warn(...args: any[]): void { const timestamp = this.formatTimestamp(); console.error(timestamp, '[WARN]', ...args); } static info(...args: any[]): void { const timestamp = this.formatTimestamp(); console.error(timestamp, '[INFO]', ...args); } static debug(...args: any[]): void { const timestamp = this.formatTimestamp(); console.error(timestamp, '[DEBUG]', ...args); } }

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/evalstate/mcp-webcam'

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