Adjustments to profile saving logging logic
Bundle up profile save time and display in one line + do not log to file Don't log when each profile is saved Do not log to file how much fuel is left in generator
This commit is contained in:
parent
973b74bd98
commit
b34edb0d3b
@ -487,7 +487,8 @@ export class HideoutHelper
|
||||
fuelItemInSlot.upd = this.getAreaUpdObject(1, fuelRemaining, pointsConsumed);
|
||||
|
||||
this.logger.debug(
|
||||
`$Profile: ${pmcData._id} Generator has: ${fuelRemaining} fuel left in slot ${i + 1}`,
|
||||
`Profile: ${pmcData._id} Generator has: ${fuelRemaining} fuel left in slot ${i + 1}`,
|
||||
true,
|
||||
);
|
||||
hasFuelRemaining = true;
|
||||
|
||||
|
@ -79,10 +79,13 @@ export class SaveServer
|
||||
public save(): void
|
||||
{
|
||||
// Save every profile
|
||||
let totalTime = 0;
|
||||
for (const sessionID in this.profiles)
|
||||
{
|
||||
this.saveProfile(sessionID);
|
||||
totalTime += this.saveProfile(sessionID);
|
||||
}
|
||||
|
||||
this.logger.debug(`Saved ${Object.keys(this.profiles).length} profiles, took: ${totalTime.toFixed(2)}ms`, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -172,7 +175,7 @@ export class SaveServer
|
||||
// File found, store in profiles[]
|
||||
const start = performance.now();
|
||||
this.profiles[sessionID] = this.jsonUtil.deserialize(this.vfs.readFile(filePath), filename);
|
||||
this.logger.debug(`Profile ${sessionID} took ${performance.now() - start}ms to load.`);
|
||||
this.logger.debug(`Profile: ${sessionID} took: ${performance.now() - start}ms to load.`, true);
|
||||
}
|
||||
|
||||
// Run callbacks
|
||||
@ -186,8 +189,9 @@ export class SaveServer
|
||||
* Save changes from in-memory profile to user/profiles json
|
||||
* Execute onBeforeSaveCallbacks callbacks prior to being saved to json
|
||||
* @param sessionID profile id (user/profiles/id.json)
|
||||
* @returns time taken to save in MS
|
||||
*/
|
||||
public saveProfile(sessionID: string): void
|
||||
public saveProfile(sessionID: string): number
|
||||
{
|
||||
const filePath = `${this.profileFilepath}${sessionID}.json`;
|
||||
|
||||
@ -217,9 +221,9 @@ export class SaveServer
|
||||
this.saveMd5[sessionID] = String(fmd5);
|
||||
// save profile to disk
|
||||
this.vfs.writeFile(filePath, jsonProfile);
|
||||
this.logger.debug(this.localisationService.getText("profile_saved", sessionID), true);
|
||||
}
|
||||
this.logger.debug(`Profile ${sessionID} took ${performance.now() - start}ms to save.`);
|
||||
|
||||
return Number(performance.now() - start);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user