MCPcopy
hub / github.com/lightningpixel/modly / archiveCurrentSession

Function archiveCurrentSession

electron/main/logger.ts:24–51  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

22}
23
24export function archiveCurrentSession(): void {
25 const logsDir = getLogsDir()
26 const hasLogs = LOG_FILES.some(f => existsSync(join(logsDir, f)))
27 if (!hasLogs) return
28
29 const timestamp = new Date().toISOString().replace(/:/g, '-').slice(0, 19)
30 const sessionsDir = join(logsDir, 'sessions')
31 const sessionDir = join(sessionsDir, timestamp)
32 mkdirSync(sessionDir, { recursive: true })
33
34 for (const file of LOG_FILES) {
35 const src = join(logsDir, file)
36 if (existsSync(src)) {
37 try { renameSync(src, join(sessionDir, file)) } catch {}
38 }
39 }
40
41 // Keep only last MAX_SESSIONS
42 try {
43 const sessions = readdirSync(sessionsDir)
44 .filter(f => statSync(join(sessionsDir, f)).isDirectory())
45 .sort()
46 .reverse()
47 for (const old of sessions.slice(MAX_SESSIONS)) {
48 rmSync(join(sessionsDir, old), { recursive: true, force: true })
49 }
50 } catch {}
51}
52
53export const logger = {
54 info: (msg: string) => { console.log(msg); writeTo('modly.log', line('INFO', msg)) },

Callers 1

index.tsFile · 0.90

Calls 2

getLogsDirFunction · 0.85
filterMethod · 0.80

Tested by

no test coverage detected