Skip to content

Commit 1a56d6b

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 fbbeafa commit 1a56d6b

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

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
/**
@@ -1001,4 +982,30 @@ export class Configuration {
1001982
this.setBladeComments(false);
1002983
}
1003984
}
985+
986+
/**
987+
* Logs the environment, configuration settings, and language configs for debugging purposes.
988+
*/
989+
private logDebugInfo() {
990+
const env = {
991+
"OS": process.platform,
992+
"Platform": process.platform,
993+
"VS Code Version": vscode.version,
994+
"VS Code Root Path": vscode.env.appRoot,
995+
"VS Code Built-in Extensions Path": `${vscode.env.appRoot}\\extensions`,
996+
"VS Code Host": vscode.env.appHost,
997+
"VS Code Remote Name": vscode.env.remoteName || "local",
998+
"Other System Env Variables": process.env,
999+
};
1000+
this.logger.debug("Environment:", env);
1001+
1002+
// Log the extension's user configuration settings.
1003+
this.logger.debug("Configuration settings:", this.getConfiguration());
1004+
1005+
// Log the objects for debugging purposes.
1006+
this.logger.debug("The language config filepaths found are:", this.languageConfigFilePaths);
1007+
this.logger.debug("The language configs found are:", this.languageConfigs);
1008+
this.logger.debug("The supported languages for multi-line blocks:", this.readJsonFile(this.multiLineLangDefinitionFilePath));
1009+
this.logger.debug("The supported languages for single-line blocks:", this.readJsonFile(this.singleLineLangDefinitionFilePath));
1010+
}
10041011
}

0 commit comments

Comments
 (0)