Skip to content

Commit 23813a7

Browse files
authored
[mcp] logging file should be reset for each session (#84425)
1 parent 43aef82 commit 23813a7

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/next/src/server/dev/browser-logs/file-logger.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export interface LogEntry {
88
message: string
99
}
1010

11+
// Logging server and browser logs to a file
1112
export class FileLogger {
1213
private logFilePath: string = ''
1314
private isInitialized: boolean = false
@@ -29,12 +30,10 @@ export class FileLogger {
2930
}
3031

3132
try {
32-
// Create the log file if it doesn't exist
33-
if (!fs.existsSync(this.logFilePath)) {
34-
// ensure the directory exists
35-
fs.mkdirSync(path.dirname(this.logFilePath), { recursive: true })
36-
fs.writeFileSync(this.logFilePath, '')
37-
}
33+
// Clean up the log file on each initialization
34+
// ensure the directory exists
35+
fs.mkdirSync(path.dirname(this.logFilePath), { recursive: true })
36+
fs.writeFileSync(this.logFilePath, '')
3837
this.isInitialized = true
3938
} catch (error) {
4039
console.error(error)

0 commit comments

Comments
 (0)