-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathlogger.ts
More file actions
71 lines (63 loc) · 1.55 KB
/
Copy pathlogger.ts
File metadata and controls
71 lines (63 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* Unified logger for consistent logging across the application
*/
const prefix = "[MCP-Mermaid]";
/**
* Log info message
*/
export function info(message: string, ...args: unknown[]): void {
console.log(`${prefix} ℹ️ ${message}`, ...args);
}
/**
* Log warning message
*/
export function warn(message: string, ...args: unknown[]): void {
console.warn(`${prefix} ⚠️ ${message}`, ...args);
}
/**
* Log error message
*/
export function error(message: string, error?: unknown): void {
console.error(`${prefix} ❌ ${message}`, error || "");
}
/**
* Log success message
*/
export function success(message: string, ...args: unknown[]): void {
console.log(`${prefix} ✅ ${message}`, ...args);
}
/**
* Log server startup information
*/
export function serverStartup(
serverType: string,
port: number,
endpoint: string,
): void {
const serverUrl = `http://localhost:${port}${endpoint}`;
const healthUrl = `http://localhost:${port}/health`;
const pingUrl = `http://localhost:${port}/ping`;
console.log(
`${prefix} 🚀 ${serverType} running on: \x1b[32m\u001B[4m${serverUrl}\u001B[0m\x1b[0m`,
);
console.log("\nTest endpoints:");
console.log(`• Health check: \u001B[4m${healthUrl}\u001B[0m`);
console.log(`• Ping test: \u001B[4m${pingUrl}\u001B[0m`);
}
/**
* Log cleanup information
*/
export function cleanup(message: string): void {
console.log(`${prefix} 🧹 ${message}`);
}
/**
* Logger object for backward compatibility
*/
export const Logger = {
info,
warn,
error,
success,
serverStartup,
cleanup,
};