Skip to content

Commit 5860fe7

Browse files
committed
Better project logging
1 parent 1d5521b commit 5860fe7

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
@@ -1041,7 +1041,8 @@ namespace ts.server {
10411041
}
10421042

10431043
private removeProject(project: Project) {
1044-
this.logger.info(`remove project: ${project.projectName}\nFiles::${project.getRootFiles().toString()}`);
1044+
this.logger.info("`remove Project::");
1045+
project.print();
10451046

10461047
project.close();
10471048
if (Debug.shouldAssert(AssertionLevel.Normal)) {
@@ -1487,19 +1488,9 @@ namespace ts.server {
14871488

14881489
const writeProjectFileNames = this.logger.hasLevel(LogLevel.verbose);
14891490
this.logger.startGroup();
1490-
let counter = 0;
1491-
const printProjects = (projects: Project[], counter: number): number => {
1492-
for (const project of projects) {
1493-
this.logger.info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
1494-
this.logger.info(project.filesToString(writeProjectFileNames));
1495-
this.logger.info("-----------------------------------------------");
1496-
counter++;
1497-
}
1498-
return counter;
1499-
};
1500-
counter = printProjects(this.externalProjects, counter);
1501-
counter = printProjects(arrayFrom(this.configuredProjects.values()), counter);
1502-
printProjects(this.inferredProjects, counter);
1491+
let counter = printProjectsWithCounter(this.externalProjects, 0);
1492+
counter = printProjectsWithCounter(arrayFrom(this.configuredProjects.values()), counter);
1493+
printProjectsWithCounter(this.inferredProjects, counter);
15031494

15041495
this.logger.info("Open files: ");
15051496
this.openFiles.forEach((projectRootPath, path) => {
@@ -2970,4 +2961,12 @@ namespace ts.server {
29702961
export function isConfigFile(config: ScriptInfoOrConfig): config is TsConfigSourceFile {
29712962
return (config as TsConfigSourceFile).kind !== undefined;
29722963
}
2964+
2965+
function printProjectsWithCounter(projects: Project[], counter: number) {
2966+
for (const project of projects) {
2967+
project.print(counter);
2968+
counter++;
2969+
}
2970+
return counter;
2971+
}
29732972
}

src/server/project.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,12 @@ namespace ts.server {
999999
return strBuilder;
10001000
}
10011001

1002+
print(counter?: number) {
1003+
this.writeLog(`Project '${this.projectName}' (${ProjectKind[this.projectKind]}) ${counter === undefined ? "" : counter}`);
1004+
this.writeLog(this.filesToString(this.projectService.logger.hasLevel(LogLevel.verbose)));
1005+
this.writeLog("-----------------------------------------------");
1006+
}
1007+
10021008
setCompilerOptions(compilerOptions: CompilerOptions) {
10031009
if (compilerOptions) {
10041010
compilerOptions.allowNonTsExtensions = true;

0 commit comments

Comments
 (0)