Skip to content

Commit 4d94f40

Browse files
kyliauatscott
authored andcommitted
fix: logger should print one timestamp for an entire group
Logger should print a single timestamp for each "group" entry.
1 parent 6258e6b commit 4d94f40

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

client/src/client.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,8 @@ function getProbeLocations(configValue: string|null, bundled: string): string[]
251251
/**
252252
* Construct the arguments that's used to spawn the server process.
253253
* @param ctx vscode extension context
254-
* @param debug true if debug mode is on
255254
*/
256-
function constructArgs(ctx: vscode.ExtensionContext, debug: boolean): string[] {
255+
function constructArgs(ctx: vscode.ExtensionContext): string[] {
257256
const config = vscode.workspace.getConfiguration();
258257
const args: string[] = ['--logToConsole'];
259258

@@ -262,7 +261,7 @@ function constructArgs(ctx: vscode.ExtensionContext, debug: boolean): string[] {
262261
// Log file does not yet exist on disk. It is up to the server to create the file.
263262
const logFile = path.join(ctx.logPath, 'nglangsvc.log');
264263
args.push('--logFile', logFile);
265-
args.push('--logVerbosity', debug ? 'verbose' : ngLog);
264+
args.push('--logVerbosity', ngLog);
266265
}
267266

268267
const ngdk: string|null = config.get('angular.ngdk', null);
@@ -307,7 +306,7 @@ function getServerOptions(ctx: vscode.ExtensionContext, debug: boolean): lsp.Nod
307306
// install prod bundle so we have to check whether dev bundle exists.
308307
module: debug && fs.existsSync(devBundle) ? devBundle : prodBundle,
309308
transport: lsp.TransportKind.ipc,
310-
args: constructArgs(ctx, debug),
309+
args: constructArgs(ctx),
311310
options: {
312311
env: debug ? devEnv : prodEnv,
313312
execArgv: debug ? devExecArgv : prodExecArgv,

server/src/logger.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ class Logger implements ts.server.Logger {
9494
}
9595
}
9696

97-
static padStringRight(str: string, padding: string) {
98-
return (str + padding).slice(0, padding.length);
99-
}
100-
10197
close() {
10298
if (this.loggingEnabled()) {
10399
fs.close(this.fd, noop);
@@ -138,14 +134,14 @@ class Logger implements ts.server.Logger {
138134
return;
139135
}
140136

141-
s = `[${nowString()}] ${s}\n`;
137+
let prefix = '';
142138
if (!this.inGroup || this.firstInGroup) {
143-
const prefix = Logger.padStringRight(type + ' ' + this.seq.toString(), ' ');
144-
s = prefix + s;
139+
this.firstInGroup = false;
140+
prefix = `${type} ${this.seq}`.padEnd(10) + `[${nowString()}] `;
145141
}
142+
const entry = prefix + s + '\n';
146143

147-
const buf = Buffer.from(s);
148-
fs.writeSync(this.fd, buf, 0, buf.length);
144+
fs.writeSync(this.fd, entry);
149145

150146
if (!this.inGroup) {
151147
this.seq++;

0 commit comments

Comments
 (0)