Skip to content

Commit 83bb535

Browse files
committed
refactor: extract debug logging from constructor into new method
- Added the new `logDebugInfo` method to log all debugging information to the Output channel. - Extracted all the debug logging from the `constructor` into it's own method to keep the constructor clean. - Changed the format of the data logged for the supported languages. Instead of logging the `Map`s, we now utilise the auto-generated language definitions files. This is because the single-line languages are reformatted in a human-readable way to output to the file, so it would be better reading this formatted file than the JS `Map`.
1 parent a376ba7 commit 83bb535

1 file changed

Lines changed: 27 additions & 20 deletions

File tree

src/configuration.ts

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -65,33 +65,14 @@ export class Configuration {
6565
const extensionVersion = vscode.extensions.getExtension(extensionId)?.packageJSON.version;
6666
this.logger.info(`Extension: ${extensionId} (${extensionVersion})`);
6767

68-
const env = {
69-
"OS": process.platform,
70-
"Platform": process.platform,
71-
"VS Code Version": vscode.version,
72-
"VS Code Root Path": vscode.env.appRoot,
73-
"VS Code Built-in Extensions Path": `${vscode.env.appRoot}\\extensions`,
74-
"VS Code Host": vscode.env.appHost,
75-
"VS Code Remote Name": vscode.env.remoteName || "local",
76-
"Other System Env Variables": process.env,
77-
};
78-
this.logger.debug("Environment:", env);
79-
80-
// Log the extension's user configuration settings.
81-
this.logger.debug("Configuration settings:", this.getConfiguration());
82-
8368
this.findAllLanguageConfigFilePaths();
8469
this.setLanguageConfigDefinitions();
8570

8671
this.setMultiLineCommentLanguageDefinitions();
8772
this.setSingleLineCommentLanguageDefinitions();
8873
this.writeCommentLanguageDefinitionsToJsonFile();
8974

90-
// Log the objects for debugging purposes.
91-
this.logger.debug("The language config filepaths found are:", this.languageConfigFilePaths);
92-
this.logger.debug("The language configs found are:", this.languageConfigs);
93-
this.logger.debug("The supported languages for multi-line blocks:", this.multiLineBlocksMap);
94-
this.logger.debug("The supported languages single-line blocks:", this.singleLineBlocksMap);
75+
this.logDebugInfo();
9576
}
9677

9778
/**
@@ -993,4 +974,30 @@ export class Configuration {
993974
this.setBladeComments(false);
994975
}
995976
}
977+
978+
/**
979+
* Logs the environment, configuration settings, and language configs for debugging purposes.
980+
*/
981+
private logDebugInfo() {
982+
const env = {
983+
"OS": process.platform,
984+
"Platform": process.platform,
985+
"VS Code Version": vscode.version,
986+
"VS Code Root Path": vscode.env.appRoot,
987+
"VS Code Built-in Extensions Path": `${vscode.env.appRoot}\\extensions`,
988+
"VS Code Host": vscode.env.appHost,
989+
"VS Code Remote Name": vscode.env.remoteName || "local",
990+
"Other System Env Variables": process.env,
991+
};
992+
this.logger.debug("Environment:", env);
993+
994+
// Log the extension's user configuration settings.
995+
this.logger.debug("Configuration settings:", this.getConfiguration());
996+
997+
// Log the objects for debugging purposes.
998+
this.logger.debug("The language config filepaths found are:", this.languageConfigFilePaths);
999+
this.logger.debug("The language configs found are:", this.languageConfigs);
1000+
this.logger.debug("The supported languages for multi-line blocks:", this.readJsonFile(this.multiLineLangDefinitionFilePath));
1001+
this.logger.debug("The supported languages for single-line blocks:", this.readJsonFile(this.singleLineLangDefinitionFilePath));
1002+
}
9961003
}

0 commit comments

Comments
 (0)