Skip to content

Commit

Permalink
Log workshop subscribed info, enable debug logging
Browse files Browse the repository at this point in the history
  • Loading branch information
FLSoz committed Mar 29, 2022
1 parent 6d57d24 commit 30a0ad9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "terratech-steam-mod-loader",
"productName": "ttsm",
"description": "Mod loader for TerraTech that handles Steam Workshop mod configurations",
"version": "1.4.0",
"version": "1.4.1",
"scripts": {
"build": "concurrently \"npm run build:main\" \"npm run build:renderer\"",
"build:main": "cross-env NODE_ENV=production TS_NODE_TRANSPILE_ONLY=true webpack --config ./.erb/configs/webpack.config.main.prod.ts",
Expand Down
2 changes: 1 addition & 1 deletion release/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "terratech-steam-mod-loader",
"productName": "ttsm",
"description": "Mod loader for TerraTech that handles Steam Workshop mod configurations",
"version": "1.4.0",
"version": "1.4.1",
"main": "./dist/main/main.js",
"author": {
"name": "FLSoz",
Expand Down
12 changes: 6 additions & 6 deletions src/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const isDevelopment = process.env.NODE_ENV === 'development' || process.env.DEBU

export default class AppUpdater {
constructor() {
log.transports.file.level = isDevelopment ? 'debug' : 'info';
log.transports.file.level = 'debug'; // isDevelopment ? 'debug' : 'info';
autoUpdater.logger = log;
autoUpdater.checkForUpdatesAndNotify();
}
Expand Down Expand Up @@ -58,7 +58,7 @@ const installExtensions = async () => {
extensions.map((name) => installer[name]),
forceDownload
)
.catch(log.info);
.catch(log.error);
};

const createWindow = async () => {
Expand Down Expand Up @@ -309,7 +309,7 @@ ipcMain.on(ValidChannel.READ_COLLECTION, async (event, collection) => {
data.name = collection;
event.reply(ValidChannel.READ_COLLECTION, data as ModCollection);
} catch (error) {
log.info(`Failed to read collection: ${collection}`);
log.error(`Failed to read collection: ${collection}`);
log.error(error);
event.reply(ValidChannel.READ_COLLECTION, null);
}
Expand Down Expand Up @@ -451,7 +451,7 @@ ipcMain.handle(ValidChannel.LAUNCH_GAME, async (_event, gameExec, workshopID, cl
ipcMain.handle(ValidChannel.WRITE_FILE, async (_event, pathParams: PathParams, data) => {
const filepath = path.join(...pathParams.prefixes, pathParams.path);
log.info(`Writing json file ${filepath}`);
log.info(`Writing ${data} to file ${filepath}`);
log.debug(`Writing ${data} to file ${filepath}`);
try {
fs.writeFileSync(filepath, data, 'utf8');
return true;
Expand All @@ -475,11 +475,11 @@ ipcMain.handle(ValidChannel.UPDATE_FILE, async (_event, pathParams: PathParams,
data[key] = value;
}
});
log.info(`Writing ${JSON.stringify(data)} to file ${filepath}`);
log.debug(`Writing ${JSON.stringify(data)} to file ${filepath}`);
fs.writeFileSync(filepath, JSON.stringify(data, null, 4), 'utf8');
return true;
} catch (error) {
log.info(`Unable to parse file ${filepath} contents into json: ${raw}`);
log.error(`Unable to parse file ${filepath} contents into json: ${raw}`);
log.error(error);
try {
fs.writeFileSync(filepath, JSON.stringify(newData, null, 4), 'utf8');
Expand Down
6 changes: 5 additions & 1 deletion src/main/mod-fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ async function processSteamModResults(steamDetails: SteamUGCDetails[]): Promise<
}
}
if (validMod) {
log.info(JSON.stringify(potentialMod, (_, v) => (typeof v === 'bigint' ? v.toString() : v), 2));
log.debug(JSON.stringify(potentialMod, (_, v) => (typeof v === 'bigint' ? v.toString() : v), 2));
return potentialMod;
}
return null;
Expand Down Expand Up @@ -333,6 +333,9 @@ export default class ModFetcher {
let lastProcessed = 1;
const workshopMap: Map<bigint, ModData> = new Map();

const allSubscribedItems: bigint[] = Steamworks.getSubscribedItems();
log.debug(`All subscribed items: [${allSubscribedItems}]`);

// We make 2 assumptions:
// 1. We are done if and only if reading a page returns 0 results
// 2. The subscription list will not change mid-pull
Expand All @@ -345,6 +348,7 @@ export default class ModFetcher {
this.loadedMods += numReturned;
numProcessedWorkshop += numReturned;
lastProcessed = numReturned;
log.debug(`Total items: ${totalItems}, Returned by Steam: ${numReturned}, Processed this chunk: ${items.length}`);

// eslint-disable-next-line no-await-in-loop
const data: ModData[] = await processSteamModResults(items);
Expand Down

0 comments on commit 30a0ad9

Please sign in to comment.