Parcourir la source

Shortens log timings

main
Eric Amodio il y a 1 an
Parent
révision
35cfc26028
5 fichiers modifiés avec 26 ajouts et 29 suppressions
  1. +8
    -8
      src/env/node/git/git.ts
  2. +1
    -3
      src/env/node/git/localGitProvider.ts
  3. +13
    -13
      src/hovers/hovers.ts
  4. +3
    -3
      src/system/decorators/log.ts
  5. +1
    -2
      src/system/stopwatch.ts

+ 8
- 8
src/env/node/git/git.ts Voir le fichier

@ -84,12 +84,12 @@ function defaultExceptionHandler(ex: Error, cwd: string | undefined, start?: [nu
if (msg != null && msg.length !== 0) {
for (const warning of Object.values(GitWarnings)) {
if (warning.test(msg)) {
const duration = start !== undefined ? `${getDurationMilliseconds(start)} ms` : '';
const duration = start !== undefined ? ` [${getDurationMilliseconds(start)}ms]` : '';
Logger.warn(
`[${cwd}] Git ${msg
.trim()
.replace(/fatal: /g, '')
.replace(/\r?\n|\r/g, ` ${GlyphChars.Dot} `)} ${GlyphChars.Dot} ${duration}`,
.replace(/\r?\n|\r/g, ` ${GlyphChars.Dot} `)}${duration}`,
);
return '';
}
@ -201,12 +201,12 @@ export class Git {
`[GIT ] ${gitCommand} ${GlyphChars.Dot} ${(exception.message || String(exception) || '')
.trim()
.replace(/fatal: /g, '')
.replace(/\r?\n|\r/g, ` ${GlyphChars.Dot} `)} ${GlyphChars.Dot} ${duration} ms${status}`,
.replace(/\r?\n|\r/g, ` ${GlyphChars.Dot} `)} [${duration}ms]${status}`,
);
} else if (slow) {
Logger.warn(`[GIT ] ${gitCommand} ${GlyphChars.Dot} ${duration} ms${status}`);
Logger.warn(`[GIT ] ${gitCommand} [*${duration}ms]${status}`);
} else {
Logger.log(`[GIT ] ${gitCommand} ${GlyphChars.Dot} ${duration} ms${status}`);
Logger.log(`[GIT ] ${gitCommand} [${duration}ms]${status}`);
}
this.logGitCommand(
`${gitCommand}${exception != null ? ` ${GlyphChars.Dot} FAILED` : ''}${waiting ? ' (waited)' : ''}`,
@ -276,12 +276,12 @@ export class Git {
`[SGIT ] ${gitCommand} ${GlyphChars.Dot} ${(exception.message || String(exception) || '')
.trim()
.replace(/fatal: /g, '')
.replace(/\r?\n|\r/g, ` ${GlyphChars.Dot} `)} ${GlyphChars.Dot} ${duration} ms${status}`,
.replace(/\r?\n|\r/g, ` ${GlyphChars.Dot} `)} [${duration}ms]${status}`,
);
} else if (slow) {
Logger.warn(`[SGIT ] ${gitCommand} ${GlyphChars.Dot} ${duration} ms${status}`);
Logger.warn(`[SGIT ] ${gitCommand} [*${duration}ms]${status}`);
} else {
Logger.log(`[SGIT ] ${gitCommand} ${GlyphChars.Dot} ${duration} ms${status}`);
Logger.log(`[SGIT ] ${gitCommand} [${duration}ms]${status}`);
}
this.logGitCommand(
`${gitCommand}${exception != null ? ` ${GlyphChars.Dot} FAILED` : ''}`,

+ 1
- 3
src/env/node/git/localGitProvider.ts Voir le fichier

@ -369,9 +369,7 @@ export class LocalGitProvider implements GitProvider, Disposable {
} else {
Logger.log(
scope,
`Git (${location.version}) found in ${location.path === 'git' ? 'PATH' : location.path} ${
GlyphChars.Dot
} ${getDurationMilliseconds(start)} ms`,
`Git (${location.version}) found in ${location.path === 'git' ? 'PATH' : location.path} [${getDurationMilliseconds(start)}ms]`,
);
}

+ 13
- 13
src/hovers/hovers.ts Voir le fichier

@ -298,14 +298,14 @@ async function getAutoLinkedIssuesOrPullRequests(message: string, remotes: GitRe
!cfg.autolinks.enhanced ||
!CommitFormatter.has(cfg.detailsMarkdownFormat, 'message')
) {
Logger.debug(scope, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `completed [${getDurationMilliseconds(start)}ms]`);
return undefined;
}
const remote = await Container.instance.git.getBestRemoteWithRichProvider(remotes);
if (remote?.provider == null) {
Logger.debug(scope, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `completed [${getDurationMilliseconds(start)}ms]`);
return undefined;
}
@ -326,9 +326,9 @@ async function getAutoLinkedIssuesOrPullRequests(message: string, remotes: GitRe
scope,
`timed out ${
GlyphChars.Dash
} ${prCount} issue/pull request queries took too long (over ${timeout} ms) ${
GlyphChars.Dot
} ${getDurationMilliseconds(start)} ms`,
} ${prCount} issue/pull request queries took too long (over ${timeout} ms) [${getDurationMilliseconds(
start,
)}ms]`,
);
// const pending = [
@ -350,11 +350,11 @@ async function getAutoLinkedIssuesOrPullRequests(message: string, remotes: GitRe
}
}
Logger.debug(scope, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `completed [${getDurationMilliseconds(start)}ms]`);
return autolinks;
} catch (ex) {
Logger.error(ex, scope, `failed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.error(ex, scope, `failed [${getDurationMilliseconds(start)}ms]`);
return undefined;
}
@ -373,7 +373,7 @@ async function getPullRequestForCommit(
const start = hrtime();
if (!options?.pullRequests) {
Logger.debug(scope, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `completed [${getDurationMilliseconds(start)}ms]`);
return undefined;
}
@ -382,7 +382,7 @@ async function getPullRequestForCommit(
includeDisconnected: true,
});
if (remote?.provider == null) {
Logger.debug(scope, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `completed [${getDurationMilliseconds(start)}ms]`);
return undefined;
}
@ -390,7 +390,7 @@ async function getPullRequestForCommit(
const { provider } = remote;
const connected = provider.maybeConnected ?? (await provider.isConnected());
if (!connected) {
Logger.debug(scope, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `completed [${getDurationMilliseconds(start)}ms]`);
return remote;
}
@ -398,17 +398,17 @@ async function getPullRequestForCommit(
try {
const pr = await Container.instance.git.getPullRequestForCommit(ref, provider, { timeout: 250 });
Logger.debug(scope, `completed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `completed [${getDurationMilliseconds(start)}ms]`);
return pr;
} catch (ex) {
if (ex instanceof PromiseCancelledError) {
Logger.debug(scope, `timed out ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.debug(scope, `timed out [${getDurationMilliseconds(start)}ms]`);
return ex;
}
Logger.error(ex, scope, `failed ${GlyphChars.Dot} ${getDurationMilliseconds(start)} ms`);
Logger.error(ex, scope, `failed [${getDurationMilliseconds(start)}ms]`);
return undefined;
}

+ 3
- 3
src/system/decorators/log.ts Voir le fichier

@ -212,7 +212,7 @@ export function log any>(options?: LogOptions, deb
const start = timed ? hrtime() : undefined;
const logError = (ex: Error) => {
const timing = start !== undefined ? ` \u2022 ${getDurationMilliseconds(start)} ms` : emptyStr;
const timing = start !== undefined ? ` [${getDurationMilliseconds(start)}ms]` : emptyStr;
if (singleLine) {
Logger.error(
ex,
@ -244,10 +244,10 @@ export function log any>(options?: LogOptions, deb
duration = getDurationMilliseconds(start);
if (duration > slowCallWarningThreshold) {
exitLogFn = warnFn;
timing = ` \u2022 ${duration} ms (slow)`;
timing = ` [*${duration}ms] (slow)`;
} else {
exitLogFn = logFn;
timing = ` \u2022 ${duration} ms`;
timing = ` [${duration}ms]`;
}
} else {
timing = emptyStr;

+ 1
- 2
src/system/stopwatch.ts Voir le fichier

@ -1,5 +1,4 @@
import { hrtime } from '@env/hrtime';
import { GlyphChars } from '../constants';
import type { LogProvider } from './logger';
import { defaultLogProvider } from './logger';
import { LogLevel } from './logger.constants';
@ -111,7 +110,7 @@ export class Stopwatch {
this.logProvider.log(
ms > 250 ? LogLevel.Warn : this.logLevel,
logScope,
`${prefix ? `${prefix} ${GlyphChars.Dot} ` : ''}${ms} ms${options?.suffix ?? ''}`,
`${prefix ? `${prefix} ` : ''}[${ms}ms]${options?.suffix ?? ''}`,
);
}

Chargement…
Annuler
Enregistrer