Download src/utils/debug-log.js from VanyaJ/bada-terminal: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/utils/debug-log.js
- Command line
-
hf download hf://VanyaJ/bada-terminal/src/utils/debug-log.js
-
curl -L -o debug-log.js https://huggingface.co/VanyaJ/bada-terminal/resolve/main/src/utils/debug-log.js
1.35 kB
| const fs = require('fs'); | |
| const path = require('path'); | |
| let CLAUDE_DIR = null; | |
| let isRotating = false; | |
| function setClaudeDir(dir) { | |
| CLAUDE_DIR = dir; | |
| } | |
| async function writeDebugLog(msg) { | |
| try { | |
| if (!CLAUDE_DIR) { | |
| const os = require('os'); | |
| CLAUDE_DIR = path.join(os.homedir(), '.claude'); | |
| } | |
| const logPath = path.join(CLAUDE_DIR, 'desktop-cli-debug.log'); | |
| // ํ์ผ ๋กํ ์ด์ (๋น๋๊ธฐ๋ก ์คํํ๋, ๋ฐฑ๊ทธ๋ผ์ด๋์์ ์งํํ์ฌ ๋ฉ์ธ ๋ฃจํ ๋ธ๋กํน ๋ฐฉ์ง) | |
| if (!isRotating) { | |
| isRotating = true; | |
| fs.promises.stat(logPath).then(async (stat) => { | |
| if (stat.size > 5 * 1024 * 1024) { | |
| try { | |
| const content = await fs.promises.readFile(logPath, 'utf-8'); | |
| const lines = content.split('\n'); | |
| await fs.promises.writeFile(logPath, lines.slice(-1000).join('\n'), 'utf-8'); | |
| } catch (err) { | |
| console.error('[Logger] Rotation error:', err.message); | |
| } | |
| } | |
| isRotating = false; | |
| }).catch(() => { | |
| isRotating = false; | |
| }); | |
| } | |
| const time = new Date().toISOString(); | |
| await fs.promises.appendFile(logPath, `[${time}] ${msg}\n`, 'utf-8'); | |
| } catch (e) { | |
| console.warn('[Logger] Fallback debug log:', msg); | |
| } | |
| } | |
| module.exports = { | |
| setClaudeDir, | |
| writeDebugLog | |
| }; | |