Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions 5 src/harness/harnessLanguageService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ namespace Harness.LanguageService {
this.host.log(message);
}

err(message: string): void {
msg(message: string): void {
this.host.log(message);
}

Expand All @@ -702,7 +702,8 @@ namespace Harness.LanguageService {
return false;
}

group() { throw ts.notImplemented(); }
startGroup() { throw ts.notImplemented(); }
endGroup() { throw ts.notImplemented(); }

perftrc(message: string): void {
return this.host.log(message);
Expand Down
5 changes: 3 additions & 2 deletions 5 src/harness/unittests/tsserverProjectSystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ namespace ts.projectSystem {
loggingEnabled: () => false,
perftrc: noop,
info: noop,
err: noop,
group: noop,
msg: noop,
startGroup: noop,
endGroup: noop,
getLogFileName: (): string => undefined
};

Expand Down
32 changes: 16 additions & 16 deletions 32 src/server/editorServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -958,28 +958,28 @@ namespace ts.server {
return;
}

this.logger.group(info => {
let counter = 0;
counter = printProjects(this.externalProjects, info, counter);
counter = printProjects(this.configuredProjects, info, counter);
printProjects(this.inferredProjects, info, counter);

info("Open files: ");
for (const rootFile of this.openFiles) {
info(`\t${rootFile.fileName}`);
}
});

function printProjects(projects: Project[], info: (msg: string) => void, counter: number): number {
this.logger.startGroup();
let counter = 0;
const printProjects = (projects: Project[], counter: number): number => {
for (const project of projects) {
project.updateGraph();
info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
info(project.filesToString());
info("-----------------------------------------------");
this.logger.info(`Project '${project.getProjectName()}' (${ProjectKind[project.projectKind]}) ${counter}`);
this.logger.info(project.filesToString());
this.logger.info("-----------------------------------------------");
counter++;
}
return counter;
};
counter = printProjects(this.externalProjects, counter);
counter = printProjects(this.configuredProjects, counter);
printProjects(this.inferredProjects, counter);

this.logger.info("Open files: ");
for (const rootFile of this.openFiles) {
this.logger.info(`\t${rootFile.fileName}`);
}

this.logger.endGroup();
}

private findConfiguredProjectByProjectName(configFileName: NormalizedPath) {
Expand Down
28 changes: 15 additions & 13 deletions 28 src/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ namespace ts.server {
class Logger implements server.Logger {
private fd = -1;
private seq = 0;
private inGroup = false;
private firstInGroup = true;

constructor(private readonly logFilename: string,
private readonly traceToConsole: boolean,
Expand Down Expand Up @@ -169,24 +171,24 @@ namespace ts.server {
}

perftrc(s: string) {
this.msg(s, "Perf");
this.msg(s, Msg.Perf);
}

info(s: string) {
this.msg(s, "Info");
this.msg(s, Msg.Info);
}

err(s: string) {
this.msg(s, "Err");
this.msg(s, Msg.Err);
}

group(logGroupEntries: (log: (msg: string) => void) => void) {
let firstInGroup = false;
logGroupEntries(s => {
this.msg(s, "Info", /*inGroup*/ true, firstInGroup);
firstInGroup = false;
});
this.seq++;
startGroup() {
this.inGroup = true;
this.firstInGroup = true;
}

endGroup() {
this.inGroup = false;
}

loggingEnabled() {
Expand All @@ -197,16 +199,16 @@ namespace ts.server {
return this.loggingEnabled() && this.level >= level;
}

private msg(s: string, type: string, inGroup = false, firstInGroup = false) {
msg(s: string, type: Msg.Types = Msg.Err) {
if (!this.canWrite) return;

s = `[${nowString()}] ${s}\n`;
if (!inGroup || firstInGroup) {
if (!this.inGroup || this.firstInGroup) {
const prefix = Logger.padStringRight(type + " " + this.seq.toString(), " ");
s = prefix + s;
}
this.write(s);
if (!inGroup) {
if (!this.inGroup) {
this.seq++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions 4 src/server/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ namespace ts.server {
msg += "\n" + (<StackTraceError>err).stack;
}
}
this.logger.err(msg);
this.logger.msg(msg, Msg.Err);
}

public send(msg: protocol.Message) {
Expand Down Expand Up @@ -1947,7 +1947,7 @@ namespace ts.server {
return this.executeWithRequestId(request.seq, () => handler(request));
}
else {
this.logger.err(`Unrecognized JSON command: ${JSON.stringify(request)}`);
this.logger.msg(`Unrecognized JSON command: ${JSON.stringify(request)}`, Msg.Err);
this.output(undefined, CommandNames.Unknown, request.seq, `Unrecognized JSON command: ${request.command}`);
return { responseRequired: false };
}
Expand Down
17 changes: 13 additions & 4 deletions 17 src/server/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@ namespace ts.server {
loggingEnabled(): boolean;
perftrc(s: string): void;
info(s: string): void;
err(s: string): void;
group(logGroupEntries: (log: (msg: string) => void) => void): void;
startGroup(): void;
endGroup(): void;
msg(s: string, type?: Msg.Types): void;
getLogFileName(): string;
}

export namespace Msg {
export type Err = "Err";
export const Err: Err = "Err";
export type Info = "Info";
export const Info: Info = "Info";
export type Perf = "Perf";
export const Perf: Perf = "Perf";
export type Types = Err | Info | Perf;
}

function getProjectRootPath(project: Project): Path {
switch (project.projectKind) {
case ProjectKind.Configured:
Expand Down Expand Up @@ -115,9 +126,7 @@ namespace ts.server {
}

export function createNormalizedPathMap<T>(): NormalizedPathMap<T> {
/* tslint:disable:no-null-keyword */
const map = createMap<T>();
/* tslint:enable:no-null-keyword */
return {
get(path) {
return map.get(path);
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.