Browse Source

Adds better logging

main
Eric Amodio 1 year ago
parent
commit
466609511d
2 changed files with 24 additions and 0 deletions
  1. +23
    -0
      src/git/gitProviderService.ts
  2. +1
    -0
      src/git/models/repository.ts

+ 23
- 0
src/git/gitProviderService.ts View File

@ -121,6 +121,13 @@ export class GitProviderService implements Disposable {
get onDidChangeProviders(): Event<GitProvidersChangeEvent> {
return this._onDidChangeProviders.event;
}
@debug<GitProviderService['fireProvidersChanged']>({
args: {
0: added => `(${added?.length ?? 0}) ${added?.map(p => p.descriptor.id).join(', ')}`,
1: removed => `(${removed?.length ?? 0}) ${removed?.map(p => p.descriptor.id).join(', ')}`,
},
})
private fireProvidersChanged(added?: GitProvider[], removed?: GitProvider[]) {
if (this.container.telemetry.enabled) {
this.container.telemetry.setGlobalAttributes({
@ -143,6 +150,12 @@ export class GitProviderService implements Disposable {
return this._onDidChangeRepositories.event;
}
@debug<GitProviderService['fireRepositoriesChanged']>({
args: {
0: added => `(${added?.length ?? 0}) ${added?.map(r => r.id).join(', ')}`,
1: removed => `(${removed?.length ?? 0}) ${removed?.map(r => r.id).join(', ')}`,
},
})
private fireRepositoriesChanged(added?: Repository[], removed?: Repository[]) {
if (this.container.telemetry.enabled) {
const openSchemes = this.openRepositories.map(r => r.uri.scheme);
@ -415,12 +428,16 @@ export class GitProviderService implements Disposable {
provider,
...disposables,
provider.onDidChange(() => {
Logger.debug(`GitProvider(${id}).onDidChange()`);
const { workspaceFolders } = workspace;
if (workspaceFolders?.length) {
void this.discoverRepositories(workspaceFolders, { force: true });
}
}),
provider.onDidChangeRepository(async e => {
Logger.debug(`GitProvider(${id}).onDidChangeRepository(e=${e.repository.toString()})`);
if (
e.changed(
RepositoryChange.Remotes,
@ -455,12 +472,18 @@ export class GitProviderService implements Disposable {
}),
provider.onDidCloseRepository(e => {
const repository = this._repositories.get(e.uri);
Logger.debug(
`GitProvider(${id}).onDidCloseRepository(e=${repository?.toString() ?? e.uri.toString()})`,
);
if (repository != null) {
repository.closed = true;
}
}),
provider.onDidOpenRepository(e => {
const repository = this._repositories.get(e.uri);
Logger.debug(`GitProvider(${id}).onDidOpenRepository(e=${repository?.toString() ?? e.uri.toString()})`);
if (repository != null) {
repository.closed = false;
} else {

+ 1
- 0
src/git/models/repository.ts View File

@ -471,6 +471,7 @@ export class Repository implements Disposable {
const changed = this._closed !== value;
this._closed = value;
if (changed) {
Logger.debug(`Repository(${this.id}).closed(${value})`);
this.fireChange(this._closed ? RepositoryChange.Closed : RepositoryChange.Opened);
}
}

Loading…
Cancel
Save