Unverified Commit 23813a77 authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

[mcp] logging file should be reset for each session (#84425)

parent 43aef82b
...@@ -8,6 +8,7 @@ export interface LogEntry { ...@@ -8,6 +8,7 @@ export interface LogEntry {
message: string message: string
} }
// Logging server and browser logs to a file
export class FileLogger { export class FileLogger {
private logFilePath: string = '' private logFilePath: string = ''
private isInitialized: boolean = false private isInitialized: boolean = false
...@@ -29,12 +30,10 @@ export class FileLogger { ...@@ -29,12 +30,10 @@ export class FileLogger {
} }
try { try {
// Create the log file if it doesn't exist // Clean up the log file on each initialization
if (!fs.existsSync(this.logFilePath)) { // ensure the directory exists
// ensure the directory exists fs.mkdirSync(path.dirname(this.logFilePath), { recursive: true })
fs.mkdirSync(path.dirname(this.logFilePath), { recursive: true }) fs.writeFileSync(this.logFilePath, '')
fs.writeFileSync(this.logFilePath, '')
}
this.isInitialized = true this.isInitialized = true
} catch (error) { } catch (error) {
console.error(error) console.error(error)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment