Skip to content

Commit

Permalink
[Fix] Prevent last run output to leak to next run's logs (#3454)
Browse files Browse the repository at this point in the history
* Prevent last log output to leak to next run

* Don't initialize log on append, only on init
  • Loading branch information
arielj authored Jan 29, 2024
1 parent e01bcbd commit 5fecd85
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/backend/logger/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ const logsWriters: Record<string, LogWriter> = {}

class LogWriter {
gameInfo: GameInfo
queue: string[] | undefined
queue: string[]
initialized: boolean
timeoutId: NodeJS.Timeout | undefined
filePath: string
Expand All @@ -369,11 +369,10 @@ class LogWriter {
this.gameInfo = gameInfo
this.initialized = false
this.filePath = lastPlayLogFileLocation(gameInfo.app_name)
this.queue = []
}

logMessage(message: string) {
this.queue ??= []

// push messages to append to the log
this.queue.push(message)

Expand Down Expand Up @@ -465,8 +464,7 @@ class LogWriter {
}

export function appendGameLog(gameInfo: GameInfo, message: string) {
logsWriters[gameInfo.app_name] ??= new LogWriter(gameInfo)
logsWriters[gameInfo.app_name].logMessage(message)
logsWriters[gameInfo.app_name]?.logMessage(message)
}

export function initGameLog(gameInfo: GameInfo) {
Expand Down

0 comments on commit 5fecd85

Please sign in to comment.