Skip to content

Simplify server logger #17271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
4 commits merged into from
Aug 8, 2017
Merged

Simplify server logger #17271

4 commits merged into from
Aug 8, 2017

Conversation

ghost
Copy link

@ghost ghost commented Jul 18, 2017

Just have group instead of separate startGroup and endGroup.
Consolidate all noop test loggers.
Don't expose msg.

@ghost ghost requested a review from sheetalkamat July 18, 2017 17:55
Copy link
Member

@sandersn sandersn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactor looks solid although perhaps somebody else who is familiar with the server code should also review.

info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
info(project.filesToString());
info("-----------------------------------------------");
counter++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove the count updating responsibility from printProjects and replace it with const counter = this.externalProjects.length + this.configuredProjects.length + this.inferredProjects.length. Then printProjects can be lifted out of this function entirely.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandersn, counter is used on line 948, though its still feasible to do something like:

function printProjects(projects: Project[], counter: number) {
  for (const project of projects) {
    ...
    counter++;
  }
  return counter;
}

And then use it like this:

let counter = 0;
counter = printProjects(this.externalProjects, counter);
counter = printProjects(this.configuredProjects, counter);
printProjects(this.inferredProjects, counter);

info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
info(project.filesToString());
info("-----------------------------------------------");
counter++;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sandersn, counter is used on line 948, though its still feasible to do something like:

function printProjects(projects: Project[], counter: number) {
  for (const project of projects) {
    ...
    counter++;
  }
  return counter;
}

And then use it like this:

let counter = 0;
counter = printProjects(this.externalProjects, counter);
counter = printProjects(this.configuredProjects, counter);
printProjects(this.inferredProjects, counter);

@@ -172,22 +170,24 @@ namespace ts.server {
}

perftrc(s: string) {
this.msg(s, Msg.Perf);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we instead turn Msg into a string enum? That would allow us to continue to find all references if necessary.

getLogFileName(): string;
}

export namespace Msg {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not turn this into a string enum?

Copy link
Author

@ghost ghost Aug 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should only be one reference to each kind of message -- one each in perftrc(), info(), and err().

@rbuckton
Copy link
Member

rbuckton commented Aug 8, 2017

Odd. It looks like Travis caught an error due to an invalid cast, but Jenkins didn't.

@ghost
Copy link
Author

ghost commented Aug 8, 2017

I think the validity of the cast recently changed, so it might have to do with the TypeScript versions they're using.

@sandersn
Copy link
Member

sandersn commented Aug 8, 2017

Yeah, I just saw it locally after merging from master.

@ghost
Copy link
Author

ghost commented Aug 8, 2017

Fix is already in. #17685

@ghost ghost merged commit d99a492 into master Aug 8, 2017
@ghost ghost deleted the group branch August 8, 2017 18:22
@ghost ghost mentioned this pull request Aug 18, 2017
@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants