Skip to content

Commit

Permalink
Improve logging a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Fields committed Dec 10, 2020
1 parent bf247f8 commit d1aae1b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/transformations/transformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Transformer {
private logger = Logger.get('Transformer');

public addTransformation(transformation: Transformation) {
this.logger.debug(`Adding Transformation ${transformation}`);
this.logger.debug(`Adding Transformation ${JSON.stringify(transformation)}`);
this.transformations.push(transformation);
}

Expand Down
8 changes: 5 additions & 3 deletions src/util/vscodeContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from 'vscode';
import { Logger } from './logger';

type ContextValue = boolean | string;

Expand All @@ -8,17 +9,18 @@ type ContextValue = boolean | string;
* so let's cache the values and only call the API when necessary.
*/
export abstract class VSCodeContext {
private static cache: Map<string, ContextValue> = new Map();
private static readonly cache: Map<string, ContextValue> = new Map();

public static async set(key: string, value: ContextValue): Promise<void> {
const prev = this.get(key);
if (prev !== value) {
VSCodeContext.cache.set(key, value);
Logger.get('vscode-context').debug(`Setting key='${key}' to value='${value}'`);
this.cache.set(key, value);
await vscode.commands.executeCommand('setContext', key, value);
}
}

public static get(key: string): ContextValue | undefined {
return VSCodeContext.cache.get(key);
return this.cache.get(key);
}
}

0 comments on commit d1aae1b

Please sign in to comment.