瀏覽代碼

Adds mode logging - #725

main
Eric Amodio 5 年之前
父節點
當前提交
8ec5ceb815
共有 4 個文件被更改,包括 20 次插入5 次删除
  1. +11
    -0
      src/commands/switchMode.ts
  2. +7
    -3
      src/extension.ts
  3. +1
    -1
      src/logger.ts
  4. +1
    -1
      src/system/decorators/log.ts

+ 11
- 0
src/commands/switchMode.ts 查看文件

@ -4,6 +4,8 @@ import { configuration } from '../configuration';
import { Container } from '../container';
import { ModesQuickPick } from '../quickpicks';
import { command, Command, Commands } from './common';
import { log } from '../system/decorators/log';
import { Logger } from '../logger';
@command()
export class SwitchModeCommand extends Command {
@ -11,10 +13,17 @@ export class SwitchModeCommand extends Command {
super(Commands.SwitchMode);
}
@log({ args: false, correlate: true, singleLine: true, timed: false })
async execute() {
const cc = Logger.getCorrelationContext();
const pick = await ModesQuickPick.show();
if (pick === undefined) return;
if (cc) {
cc.exitDetails = ` \u2014 mode=${pick.key || ''}`;
}
const active = Container.config.mode.active;
if (active === pick.key) return;
@ -39,6 +48,7 @@ export class ToggleReviewModeCommand extends Command {
super(Commands.ToggleReviewMode);
}
@log({ args: false, singleLine: true, timed: false })
async execute() {
if (!Object.keys(Container.config.modes).includes('review')) return;
@ -53,6 +63,7 @@ export class ToggleZenModeCommand extends Command {
super(Commands.ToggleZenMode);
}
@log({ args: false, singleLine: true, timed: false })
async execute() {
if (!Object.keys(Container.config.modes).includes('zen')) return;

+ 7
- 3
src/extension.ts 查看文件

@ -36,7 +36,7 @@ export async function activate(context: ExtensionContext) {
const enabled = workspace.getConfiguration('git', null!).get<boolean>('enabled', true);
if (!enabled) {
Logger.log(`GitLens(v${gitlensVersion}) was NOT activated -- "git.enabled": false`);
Logger.log(`GitLens (v${gitlensVersion}) was NOT activated -- "git.enabled": false`);
setCommandContext(CommandContext.Enabled, false);
void Messages.showGitDisabledErrorMessage();
@ -55,7 +55,7 @@ export async function activate(context: ExtensionContext) {
await GitService.initialize();
}
catch (ex) {
Logger.error(ex, `GitLens(v${gitlensVersion}).activate`);
Logger.error(ex, `GitLens (v${gitlensVersion}) activate`);
setCommandContext(CommandContext.Enabled, false);
if (ex.message.includes('Unable to find git')) {
@ -88,7 +88,11 @@ export async function activate(context: ExtensionContext) {
// Constantly over my data cap so stop collecting initialized event
// Telemetry.trackEvent('initialized', Objects.flatten(cfg, 'config', true));
Logger.log(`GitLens(v${gitlensVersion}) activated ${GlyphChars.Dot} ${Strings.getDurationMilliseconds(start)} ms`);
Logger.log(
`GitLens (v${gitlensVersion}${cfg.mode.active ? `, mode: ${cfg.mode.active}` : ''}) activated ${
GlyphChars.Dot
} ${Strings.getDurationMilliseconds(start)} ms`
);
}
export function deactivate() {

+ 1
- 1
src/logger.ts 查看文件

@ -256,7 +256,7 @@ export class Logger {
}
const loggableParams = params.map(p => this.toLoggable(p)).join(', ');
return ` \u2014 ${loggableParams}` || emptyStr;
return loggableParams.length !== 0 ? ` \u2014 ${loggableParams}` : emptyStr;
}
private static _isDebugging: boolean | undefined;

+ 1
- 1
src/system/decorators/log.ts 查看文件

@ -190,7 +190,7 @@ export function log any>(
}
}
if (options.timed || options.exit != null) {
if (options.singleLine || options.timed || options.exit != null) {
const start = options.timed ? process.hrtime() : undefined;
const logError = (ex: Error) => {

Loading…
取消
儲存