Skip to content

Commit 41b1930

Browse files
committed
Better project logging
1 parent f972743 commit 41b1930

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

src/server/editorServices.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,8 @@ namespace ts.server {
10371037
}
10381038

10391039
private removeProject(project: Project) {
1040-
this.logger.info(`remove project: ${project.projectName}\nFiles::${project.getRootFiles().toString()}`);
1040+
this.logger.info("`remove Project::");
1041+
project.print();
10411042

10421043
project.close();
10431044
if (Debug.shouldAssert(AssertionLevel.Normal)) {
@@ -1477,19 +1478,9 @@ namespace ts.server {
14771478

14781479
const writeProjectFileNames = this.logger.hasLevel(LogLevel.verbose);
14791480
this.logger.startGroup();
1480-
let counter = 0;
1481-
const printProjects = (projects: Project[], counter: number): number => {
1482-
for (const project of projects) {
1483-
this.logger.info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
1484-
this.logger.info(project.filesToString(writeProjectFileNames));
1485-
this.logger.info("-----------------------------------------------");
1486-
counter++;
1487-
}
1488-
return counter;
1489-
};
1490-
counter = printProjects(this.externalProjects, counter);
1491-
counter = printProjects(arrayFrom(this.configuredProjects.values()), counter);
1492-
printProjects(this.inferredProjects, counter);
1481+
let counter = printProjectsWithCounter(this.externalProjects, 0);
1482+
counter = printProjectsWithCounter(arrayFrom(this.configuredProjects.values()), counter);
1483+
printProjectsWithCounter(this.inferredProjects, counter);
14931484

14941485
this.logger.info("Open files: ");
14951486
this.openFiles.forEach((projectRootPath, path) => {
@@ -2909,4 +2900,12 @@ namespace ts.server {
29092900
export function isConfigFile(config: ScriptInfoOrConfig): config is TsConfigSourceFile {
29102901
return (config as TsConfigSourceFile).kind !== undefined;
29112902
}
2903+
2904+
function printProjectsWithCounter(projects: Project[], counter: number) {
2905+
for (const project of projects) {
2906+
project.print(counter);
2907+
counter++;
2908+
}
2909+
return counter;
2910+
}
29122911
}

src/server/project.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,12 @@ namespace ts.server {
995995
return strBuilder;
996996
}
997997

998+
print(counter?: number) {
999+
this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]}) ${counter === undefined ? "" : counter}`);
1000+
this.writeLog(this.filesToString(this.projectService.logger.hasLevel(LogLevel.verbose)));
1001+
this.writeLog("-----------------------------------------------");
1002+
}
1003+
9981004
setCompilerOptions(compilerOptions: CompilerOptions) {
9991005
if (compilerOptions) {
10001006
compilerOptions.allowNonTsExtensions = true;

0 commit comments

Comments
 (0)