MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / copyLogsToClipboard

Function copyLogsToClipboard

src/components/lspInfoDialog/index.js:51–81  ·  view source on GitHub ↗
(serverId, serverLabel)

Source from the content-addressed store, hash-verified

49}
50
51function copyLogsToClipboard(serverId, serverLabel) {
52 const logs = getLspLogs(serverId);
53 if (logs.length === 0) {
54 toast("No logs to copy");
55 return;
56 }
57
58 const text = logs
59 .map((log) => {
60 const time = log.timestamp.toLocaleTimeString("en-US", {
61 hour12: false,
62 hour: "2-digit",
63 minute: "2-digit",
64 second: "2-digit",
65 });
66 return `[${time}] [${log.level.toUpperCase()}] ${log.message}`;
67 })
68 .join("\n");
69
70 const header = `=== ${serverLabel} LSP Logs ===\n`;
71
72 if (navigator.clipboard?.writeText) {
73 navigator.clipboard.writeText(header + text).catch(() => {
74 toast("Failed to copy");
75 });
76 } else if (cordova?.plugins?.clipboard) {
77 cordova.plugins.clipboard.copy(header + text);
78 } else {
79 toast("Clipboard not available");
80 }
81}
82
83async function restartServer(serverId) {
84 addLspLog(serverId, "info", "Restart requested by user");

Callers

nothing calls this directly

Calls 3

getLspLogsFunction · 0.90
writeTextMethod · 0.80
copyMethod · 0.65

Tested by

no test coverage detected