Bladeren bron

Adds setLogScopeExit function

main
Eric Amodio 1 jaar geleden
bovenliggende
commit
331f68e00a
10 gewijzigde bestanden met toevoegingen van 45 en 79 verwijderingen
  1. +7
    -8
      src/annotations/lineAnnotationController.ts
  2. +2
    -4
      src/commands/switchMode.ts
  3. +5
    -4
      src/git/gitProviderService.ts
  4. +2
    -4
      src/plus/gitlab/gitlab.ts
  5. +2
    -4
      src/plus/subscription/authenticationProvider.ts
  6. +6
    -16
      src/system/keyboard.ts
  7. +6
    -0
      src/system/logger.scope.ts
  8. +7
    -19
      src/trackers/gitLineTracker.ts
  9. +4
    -10
      src/views/nodes/fileHistoryTrackerNode.ts
  10. +4
    -10
      src/views/nodes/lineHistoryTrackerNode.ts

+ 7
- 8
src/annotations/lineAnnotationController.ts Bestand weergeven

@ -16,8 +16,8 @@ import { debug, log } from '../system/decorators/log';
import { once } from '../system/event';
import { count, every, filter } from '../system/iterable';
import { Logger } from '../system/logger';
import type { LogScope } from '../system/logger.scope';
import { getLogScope } from '../system/logger.scope';
import type { LogScope} from '../system/logger.scope';
import { getLogScope , setLogScopeExit } from '../system/logger.scope';
import type { PromiseCancelledErrorWithId } from '../system/promise';
import { PromiseCancelledError, raceAll } from '../system/promise';
import { isTextEditor } from '../system/utils';
@ -191,9 +191,10 @@ export class LineAnnotationController implements Disposable {
const selections = this.container.lineTracker.selections;
if (editor == null || selections == null || !isTextEditor(editor)) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} Skipped because there is no valid editor or no valid selections`;
}
setLogScopeExit(
scope,
` ${GlyphChars.Dot} Skipped because there is no valid editor or no valid selections`,
);
this.clear(this._editor);
return;
@ -208,9 +209,7 @@ export class LineAnnotationController implements Disposable {
const cfg = configuration.get('currentLine');
if (this.suspended) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} Skipped because the controller is suspended`;
}
setLogScopeExit(scope, ` ${GlyphChars.Dot} Skipped because the controller is suspended`);
this.clear(editor);
return;

+ 2
- 4
src/commands/switchMode.ts Bestand weergeven

@ -5,7 +5,7 @@ import { showModePicker } from '../quickpicks/modePicker';
import { command } from '../system/command';
import { configuration } from '../system/configuration';
import { log } from '../system/decorators/log';
import { getLogScope } from '../system/logger.scope';
import { getLogScope, setLogScopeExit } from '../system/logger.scope';
import { Command } from './base';
@command()
@ -21,9 +21,7 @@ export class SwitchModeCommand extends Command {
const pick = await showModePicker();
if (pick === undefined) return;
if (scope != null) {
scope.exitDetails = ` \u2014 mode=${pick.key ?? ''}`;
}
setLogScopeExit(scope, ` \u2014 mode=${pick.key ?? ''}`);
const active = configuration.get('mode.active');
if (active === pick.key) return;

+ 5
- 4
src/git/gitProviderService.ts Bestand weergeven

@ -31,7 +31,7 @@ import type { Deferrable } from '../system/function';
import { debounce } from '../system/function';
import { count, filter, first, flatMap, join, map, some } from '../system/iterable';
import { Logger } from '../system/logger';
import { getLogScope } from '../system/logger.scope';
import { getLogScope, setLogScopeExit } from '../system/logger.scope';
import { getBestPath, getScheme, isAbsolute, maybeUri, normalizePath } from '../system/path';
import { cancellable, fastestSettled, getSettledValue, isPromise, PromiseCancelledError } from '../system/promise';
import { VisitedPathsTrie } from '../system/trie';
@ -519,9 +519,10 @@ export class GitProviderService implements Disposable {
);
}
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} workspaceFolders=${workspaceFolders?.length}, git.autoRepositoryDetection=${autoRepositoryDetection}`;
}
setLogScopeExit(
scope,
` ${GlyphChars.Dot} workspaceFolders=${workspaceFolders?.length}, git.autoRepositoryDetection=${autoRepositoryDetection}`,
);
}
getOpenProviders(): GitProvider[] {

+ 2
- 4
src/plus/gitlab/gitlab.ts Bestand weergeven

@ -29,7 +29,7 @@ import { debug } from '../../system/decorators/log';
import { Logger } from '../../system/logger';
import { LogLevel } from '../../system/logger.constants';
import type { LogScope } from '../../system/logger.scope';
import { getLogScope } from '../../system/logger.scope';
import { getLogScope, setLogScopeExit } from '../../system/logger.scope';
import { Stopwatch } from '../../system/stopwatch';
import { equalsIgnoreCase } from '../../system/string';
import type { GitLabCommit, GitLabIssue, GitLabMergeRequest, GitLabMergeRequestREST, GitLabUser } from './models';
@ -674,9 +674,7 @@ $search: String!
const projectId = match[1];
if (scope != null) {
scope.exitDetails = `\u2022 projectId=${projectId}`;
}
setLogScopeExit(scope, ` \u2022 projectId=${projectId}`);
return projectId;
} catch (ex) {
if (ex instanceof ProviderRequestNotFoundError) return undefined;

+ 2
- 4
src/plus/subscription/authenticationProvider.ts Bestand weergeven

@ -8,7 +8,7 @@ import { uuid } from '@env/crypto';
import type { Container, Environment } from '../../container';
import { debug } from '../../system/decorators/log';
import { Logger } from '../../system/logger';
import { getLogScope } from '../../system/logger.scope';
import { getLogScope, setLogScopeExit } from '../../system/logger.scope';
import type { ServerConnection } from './serverConnection';
interface StoredSession {
@ -102,9 +102,7 @@ export class SubscriptionAuthenticationProvider implements AuthenticationProvide
const sessions = await this._sessionsPromise;
const filtered = scopes != null ? sessions.filter(s => getScopesKey(s.scopes) === scopesKey) : sessions;
if (scope != null) {
scope.exitDetails = ` \u2022 Found ${filtered.length} sessions`;
}
setLogScopeExit(scope, ` \u2022 Found ${filtered.length} sessions`);
return filtered;
}

+ 6
- 16
src/system/keyboard.ts Bestand weergeven

@ -5,7 +5,7 @@ import { registerCommand } from './command';
import { setContext } from './context';
import { log } from './decorators/log';
import { Logger } from './logger';
import { getLogScope } from './logger.scope';
import { getLogScope, setLogScopeExit } from './logger.scope';
export declare interface KeyCommand {
onDidPressKey?(key: Keys): void | Promise<void>;
@ -40,9 +40,7 @@ export class KeyboardScope implements Disposable {
const index = mappings.indexOf(this._mapping);
const scope = getLogScope();
if (scope != null) {
scope.exitDetails = ` \u2022 index=${index}`;
}
setLogScopeExit(scope, ` \u2022 index=${index}`);
if (index === mappings.length - 1) {
mappings.pop();
@ -66,9 +64,7 @@ export class KeyboardScope implements Disposable {
const mapping = mappings[mappings.length - 1];
if (mapping !== this._mapping || mapping[key] == null) {
if (scope != null) {
scope.exitDetails = ' \u2022 skipped';
}
setLogScopeExit(scope, ' \u2022 skipped');
return;
}
@ -117,9 +113,7 @@ export class KeyboardScope implements Disposable {
const mapping = mappings[mappings.length - 1];
if (mapping !== this._mapping) {
if (scope != null) {
scope.exitDetails = ' \u2022 skipped';
}
setLogScopeExit(scope, ' \u2022 skipped');
return;
}
@ -176,9 +170,7 @@ export class Keyboard implements Disposable {
const scope = getLogScope();
if (!mappings.length) {
if (scope != null) {
scope.exitDetails = ' \u2022 skipped, no mappings';
}
setLogScopeExit(scope, ' \u2022 skipped, no mappings');
return;
}
@ -191,9 +183,7 @@ export class Keyboard implements Disposable {
command = await command();
}
if (typeof command?.onDidPressKey !== 'function') {
if (scope != null) {
scope.exitDetails = ' \u2022 skipped, no callback';
}
setLogScopeExit(scope, ' \u2022 skipped, no callback');
return;
}

+ 6
- 0
src/system/logger.scope.ts Bestand weergeven

@ -39,3 +39,9 @@ export function getNextLogScopeId(): number {
export function setLogScope(scopeId: number, scope: LogScope) {
scopes.set(scopeId, scope);
}
export function setLogScopeExit(scope: LogScope | undefined, details: string): void {
if (scope == null) return;
scope.exitDetails = details;
}

+ 7
- 19
src/trackers/gitLineTracker.ts Bestand weergeven

@ -5,7 +5,7 @@ import type { Container } from '../container';
import type { GitCommit } from '../git/models/commit';
import { configuration } from '../system/configuration';
import { debug } from '../system/decorators/log';
import { getLogScope } from '../system/logger.scope';
import { getLogScope, setLogScopeExit } from '../system/logger.scope';
import type {
DocumentBlameStateChangeEvent,
DocumentContentChangeEvent,
@ -133,18 +133,14 @@ export class GitLineTracker extends LineTracker {
const scope = getLogScope();
if (!this.includes(selections)) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} lines no longer match`;
}
setLogScopeExit(scope, ` ${GlyphChars.Dot} lines no longer match`);
return false;
}
const trackedDocument = await this.container.tracker.getOrAdd(editor.document);
if (!trackedDocument.isBlameable) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} document is not blameable`;
}
setLogScopeExit(scope, ` ${GlyphChars.Dot} document is not blameable`);
return false;
}
@ -156,9 +152,7 @@ export class GitLineTracker extends LineTracker {
editor?.document,
);
if (blameLine == null) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} blame failed`;
}
setLogScopeExit(scope, ` ${GlyphChars.Dot} blame failed`);
return false;
}
@ -167,9 +161,7 @@ export class GitLineTracker extends LineTracker {
} else {
const blame = await this.container.git.getBlame(trackedDocument.uri, editor.document);
if (blame == null) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} blame failed`;
}
setLogScopeExit(scope, ` ${GlyphChars.Dot} blame failed`);
return false;
}
@ -183,17 +175,13 @@ export class GitLineTracker extends LineTracker {
// Check again because of the awaits above
if (!this.includes(selections)) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} lines no longer match`;
}
setLogScopeExit(scope, ` ${GlyphChars.Dot} lines no longer match`);
return false;
}
if (!trackedDocument.isBlameable) {
if (scope != null) {
scope.exitDetails = ` ${GlyphChars.Dot} document is not blameable`;
}
setLogScopeExit(scope, ` ${GlyphChars.Dot} document is not blameable`);
return false;
}

+ 4
- 10
src/views/nodes/fileHistoryTrackerNode.ts Bestand weergeven

@ -11,7 +11,7 @@ import { debug, log } from '../../system/decorators/log';
import type { Deferrable } from '../../system/function';
import { debounce } from '../../system/function';
import { Logger } from '../../system/logger';
import { getLogScope } from '../../system/logger.scope';
import { getLogScope, setLogScopeExit } from '../../system/logger.scope';
import { isVirtualUri } from '../../system/utils';
import type { FileHistoryView } from '../fileHistoryView';
import { FileHistoryNode } from './fileHistoryNode';
@ -159,16 +159,12 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
this.reset();
if (scope != null) {
scope.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
}
setLogScopeExit(scope, `, uri=${Logger.toLoggable(this._uri)}`);
return false;
}
if (editor.document.uri.path === this.uri.path) {
if (scope != null) {
scope.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
}
setLogScopeExit(scope, `, uri=${Logger.toLoggable(this._uri)}`);
return true;
}
@ -199,9 +195,7 @@ export class FileHistoryTrackerNode extends SubscribeableViewNode
this.resetChild();
}
if (scope != null) {
scope.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
}
setLogScopeExit(scope, `, uri=${Logger.toLoggable(this._uri)}`);
return false;
}

+ 4
- 10
src/views/nodes/lineHistoryTrackerNode.ts Bestand weergeven

@ -11,7 +11,7 @@ import { gate } from '../../system/decorators/gate';
import { debug, log } from '../../system/decorators/log';
import { debounce } from '../../system/function';
import { Logger } from '../../system/logger';
import { getLogScope } from '../../system/logger.scope';
import { getLogScope, setLogScopeExit } from '../../system/logger.scope';
import type { LinesChangeEvent } from '../../trackers/gitLineTracker';
import type { FileHistoryView } from '../fileHistoryView';
import type { LineHistoryView } from '../lineHistoryView';
@ -166,9 +166,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
this.reset();
if (scope != null) {
scope.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
}
setLogScopeExit(scope, `, uri=${Logger.toLoggable(this._uri)}`);
return false;
}
@ -177,9 +175,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
this._selection != null &&
editor.selection.isEqual(this._selection)
) {
if (scope != null) {
scope.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
}
setLogScopeExit(scope, `, uri=${Logger.toLoggable(this._uri)}`);
return true;
}
@ -204,9 +200,7 @@ export class LineHistoryTrackerNode extends SubscribeableViewNode
this.resetChild();
}
if (scope != null) {
scope.exitDetails = `, uri=${Logger.toLoggable(this._uri)}`;
}
setLogScopeExit(scope, `, uri=${Logger.toLoggable(this._uri)}`);
return false;
}

Laden…
Annuleren
Opslaan