mirror of
https://github.com/VSCodeVim/Vim.git
synced 2024-08-17 00:00:26 +03:00
feat: use winston/winston-console-for-electron for logging
This commit is contained in:
parent
6980886315
commit
3b2631ed46
@ -20,7 +20,7 @@ import { Notation } from './src/configuration/notation';
|
||||
import { StatusBar } from './src/statusBar';
|
||||
import { taskQueue } from './src/taskQueue';
|
||||
import { ModeHandlerMap } from './src/mode/modeHandlerMap';
|
||||
import { Logger } from './src/util/logger';
|
||||
import logger from './src/util/logger';
|
||||
|
||||
let extensionContext: vscode.ExtensionContext;
|
||||
|
||||
@ -95,7 +95,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
let compositionState = new CompositionState();
|
||||
|
||||
extensionContext.subscriptions.push(StatusBar);
|
||||
extensionContext.subscriptions.push(Logger);
|
||||
|
||||
// Reload active configurations
|
||||
vscode.workspace.onDidChangeConfiguration(() => {
|
||||
@ -366,5 +365,5 @@ async function handleActiveEditorChange(): Promise<void> {
|
||||
}
|
||||
|
||||
process.on('unhandledRejection', function(reason: any, p: any) {
|
||||
Logger.debug(`Unhandled Rejection at: Promise ${p}. Reason: ${reason}.`);
|
||||
logger.error(`Unhandled Rejection at: Promise ${p}. Reason: ${reason}.`);
|
||||
});
|
||||
|
186
package-lock.json
generated
186
package-lock.json
generated
@ -275,6 +275,14 @@
|
||||
"integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=",
|
||||
"dev": true
|
||||
},
|
||||
"async": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.1.tgz",
|
||||
"integrity": "sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ==",
|
||||
"requires": {
|
||||
"lodash": "^4.17.10"
|
||||
}
|
||||
},
|
||||
"asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
@ -621,6 +629,22 @@
|
||||
"object-visit": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"color": {
|
||||
"version": "0.8.0",
|
||||
"resolved": "https://registry.npmjs.org/color/-/color-0.8.0.tgz",
|
||||
"integrity": "sha1-iQwHw/1OZJU3Y4kRz2keVFi2/KU=",
|
||||
"requires": {
|
||||
"color-convert": "^0.5.0",
|
||||
"color-string": "^0.3.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"color-convert": {
|
||||
"version": "0.5.3",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-0.5.3.tgz",
|
||||
"integrity": "sha1-vbbGnOZg+t/+CwAHzER+G59ygr0="
|
||||
}
|
||||
}
|
||||
},
|
||||
"color-convert": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz",
|
||||
@ -633,8 +657,15 @@
|
||||
"color-name": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz",
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=",
|
||||
"dev": true
|
||||
"integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU="
|
||||
},
|
||||
"color-string": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/color-string/-/color-string-0.3.0.tgz",
|
||||
"integrity": "sha1-J9RvtnAlxcL6JZk7+/V55HhBuZE=",
|
||||
"requires": {
|
||||
"color-name": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"color-support": {
|
||||
"version": "1.1.3",
|
||||
@ -642,6 +673,25 @@
|
||||
"integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==",
|
||||
"dev": true
|
||||
},
|
||||
"colornames": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/colornames/-/colornames-0.0.2.tgz",
|
||||
"integrity": "sha1-2BH9bIT1kClJmorEQ2ICk1uSvjE="
|
||||
},
|
||||
"colors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/colors/-/colors-1.3.0.tgz",
|
||||
"integrity": "sha512-EDpX3a7wHMWFA7PUHWPHNWqOxIIRSJetuwl0AS5Oi/5FMV8kWm69RTlgm00GKjBO1xFHMtBbL49yRtMMdticBw=="
|
||||
},
|
||||
"colorspace": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/colorspace/-/colorspace-1.0.1.tgz",
|
||||
"integrity": "sha1-yZx5btMRKLmHalLh7l7gOkpxl0k=",
|
||||
"requires": {
|
||||
"color": "0.8.x",
|
||||
"text-hex": "0.0.x"
|
||||
}
|
||||
},
|
||||
"combined-stream": {
|
||||
"version": "1.0.6",
|
||||
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
|
||||
@ -752,15 +802,6 @@
|
||||
"integrity": "sha1-QGXiATz5+5Ft39gu+1Bq1MZ2kGI=",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"debug-fabulous": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug-fabulous/-/debug-fabulous-1.1.0.tgz",
|
||||
@ -894,6 +935,16 @@
|
||||
"integrity": "sha1-9B8cEL5LAOh7XxPaaAdZ8sW/0+I=",
|
||||
"dev": true
|
||||
},
|
||||
"diagnostics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.0.tgz",
|
||||
"integrity": "sha1-4QkJALSVI+hSe+IPCBJ1IF8q42o=",
|
||||
"requires": {
|
||||
"colorspace": "1.0.x",
|
||||
"enabled": "1.0.x",
|
||||
"kuler": "0.0.x"
|
||||
}
|
||||
},
|
||||
"diff": {
|
||||
"version": "3.5.0",
|
||||
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
|
||||
@ -988,6 +1039,14 @@
|
||||
"jsbn": "~0.1.0"
|
||||
}
|
||||
},
|
||||
"enabled": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/enabled/-/enabled-1.0.2.tgz",
|
||||
"integrity": "sha1-ll9lE9LC0cX0ZStkouM5ZGf8L5M=",
|
||||
"requires": {
|
||||
"env-variable": "0.0.x"
|
||||
}
|
||||
},
|
||||
"end-of-stream": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-0.1.5.tgz",
|
||||
@ -997,6 +1056,11 @@
|
||||
"once": "~1.3.0"
|
||||
}
|
||||
},
|
||||
"env-variable": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/env-variable/-/env-variable-0.0.4.tgz",
|
||||
"integrity": "sha512-+jpGxSWG4vr6gVxUHOc4p+ilPnql7NzZxOZBxNldsKGjCF+97df3CbuX7XMaDa5oAVkKQj4rKp38rYdC4VcpDg=="
|
||||
},
|
||||
"error-ex": {
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz",
|
||||
@ -1122,6 +1186,15 @@
|
||||
"to-regex": "^3.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"define-property": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
|
||||
@ -1332,6 +1405,11 @@
|
||||
"pend": "~1.2.0"
|
||||
}
|
||||
},
|
||||
"fecha": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/fecha/-/fecha-2.3.3.tgz",
|
||||
"integrity": "sha512-lUGBnIamTAwk4znq5BcqsDaxSmZ9nDVJaij6NvRt/Tg4R69gERA+otPKbS86ROw9nxVMw2/mp1fnaiWqbs6Sdg=="
|
||||
},
|
||||
"filename-regex": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
|
||||
@ -3535,6 +3613,14 @@
|
||||
"integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==",
|
||||
"dev": true
|
||||
},
|
||||
"kuler": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/kuler/-/kuler-0.0.0.tgz",
|
||||
"integrity": "sha1-tmu0a5NOVQ9Z2BiEjgq7pPf1VTw=",
|
||||
"requires": {
|
||||
"colornames": "0.0.2"
|
||||
}
|
||||
},
|
||||
"lazystream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/lazystream/-/lazystream-1.0.0.tgz",
|
||||
@ -3729,6 +3815,24 @@
|
||||
"lodash.escape": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"logform": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/logform/-/logform-1.7.0.tgz",
|
||||
"integrity": "sha512-IyyAkQiA0I3LEar69J0bR5kg7204883jsWW4os9ypXiEsHueuPwfEClC3aSelhG+pIbMD0l23nAkz5VRXZYMWA==",
|
||||
"requires": {
|
||||
"colors": "^1.2.1",
|
||||
"fecha": "^2.3.3",
|
||||
"ms": "^2.1.1",
|
||||
"triple-beam": "^1.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ms": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
|
||||
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"loud-rejection": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/loud-rejection/-/loud-rejection-1.6.0.tgz",
|
||||
@ -4296,6 +4400,11 @@
|
||||
"wrappy": "1"
|
||||
}
|
||||
},
|
||||
"one-time": {
|
||||
"version": "0.0.4",
|
||||
"resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz",
|
||||
"integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4="
|
||||
},
|
||||
"orchestrator": {
|
||||
"version": "0.3.8",
|
||||
"resolved": "https://registry.npmjs.org/orchestrator/-/orchestrator-0.3.8.tgz",
|
||||
@ -5037,6 +5146,15 @@
|
||||
"use": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"define-property": {
|
||||
"version": "0.2.5",
|
||||
"resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz",
|
||||
@ -5249,6 +5367,11 @@
|
||||
"tweetnacl": "~0.14.0"
|
||||
}
|
||||
},
|
||||
"stack-trace": {
|
||||
"version": "0.0.10",
|
||||
"resolved": "https://registry.npmjs.org/stack-trace/-/stack-trace-0.0.10.tgz",
|
||||
"integrity": "sha1-VHxws0fo0ytOEI6hoqFZ5f3eGcA="
|
||||
},
|
||||
"stat-mode": {
|
||||
"version": "0.2.2",
|
||||
"resolved": "https://registry.npmjs.org/stat-mode/-/stat-mode-0.2.2.tgz",
|
||||
@ -5406,6 +5529,11 @@
|
||||
"inherits": "2"
|
||||
}
|
||||
},
|
||||
"text-hex": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "https://registry.npmjs.org/text-hex/-/text-hex-0.0.0.tgz",
|
||||
"integrity": "sha1-V4+8haapJjbkLdF7QdAhjM6esrM="
|
||||
},
|
||||
"through": {
|
||||
"version": "2.3.8",
|
||||
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
|
||||
@ -5538,6 +5666,11 @@
|
||||
"integrity": "sha1-WIeWa7WCpFA6QetST301ARgVphM=",
|
||||
"dev": true
|
||||
},
|
||||
"triple-beam": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/triple-beam/-/triple-beam-1.3.0.tgz",
|
||||
"integrity": "sha512-XrHUvV5HpdLmIj4uVMxHggLbFSZYIn7HEWsqePZcI50pco+MPqJ50wMGY794X7AOOhxOBAjbkqfAbEe/QMp2Lw=="
|
||||
},
|
||||
"tslib": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.1.tgz",
|
||||
@ -6114,6 +6247,37 @@
|
||||
"isexe": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"winston": {
|
||||
"version": "3.0.0-rc6",
|
||||
"resolved": "https://registry.npmjs.org/winston/-/winston-3.0.0-rc6.tgz",
|
||||
"integrity": "sha512-4QwLccPbU/aJMA+j6uYTQ8TobwLKPWhpceJZwz1lkQ+wYv7bxGyAHIdbfEOrxsKHD8zRCcgCXPbbpV3BDRD1rw==",
|
||||
"requires": {
|
||||
"async": "^2.6.0",
|
||||
"diagnostics": "^1.0.1",
|
||||
"is-stream": "^1.1.0",
|
||||
"logform": "^1.7.0",
|
||||
"one-time": "0.0.4",
|
||||
"stack-trace": "0.0.x",
|
||||
"triple-beam": "^1.3.0",
|
||||
"winston-transport": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"winston-console-for-electron": {
|
||||
"version": "0.0.3",
|
||||
"resolved": "https://registry.npmjs.org/winston-console-for-electron/-/winston-console-for-electron-0.0.3.tgz",
|
||||
"integrity": "sha512-wwAdjWYgqsqJiMxir1LMfySFKOn8EJ7rgoA2EBxHnMZ5Dw6i6FV/ZfeNzzceDej6E4Zx9Iw35Fjr1g/rMkVQMQ==",
|
||||
"requires": {
|
||||
"winston-transport": "4.1.0"
|
||||
}
|
||||
},
|
||||
"winston-transport": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/winston-transport/-/winston-transport-4.1.0.tgz",
|
||||
"integrity": "sha512-rNMfXfGfTyiOrAJ9KLLy0nlow98NyD0oNCOSnP3jnNVHoKsJGLDsa8BaOH+ftKDR5pZKJMBhbQNEft7Vr+dJLw==",
|
||||
"requires": {
|
||||
"triple-beam": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
|
||||
|
11
package.json
11
package.json
@ -340,6 +340,13 @@
|
||||
"title": "Vim Configuration",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"vim.debug": {
|
||||
"type": "object",
|
||||
"description": "Extension debugging options",
|
||||
"default": {
|
||||
"loggingLevel": "error"
|
||||
}
|
||||
},
|
||||
"vim.otherModesKeyBindings": {
|
||||
"type": "array",
|
||||
"description": "Remapped keys in normal mode. Allows mapping to vim commands or vscode actions. See README for more."
|
||||
@ -587,7 +594,9 @@
|
||||
"lodash": "4.17.10",
|
||||
"neovim-client": "2.1.0",
|
||||
"promised-neovim-client": "2.0.2",
|
||||
"untildify": "3.0.3"
|
||||
"untildify": "3.0.3",
|
||||
"winston": "^3.0.0-rc6",
|
||||
"winston-console-for-electron": "0.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/clipboardy": "1.1.0",
|
||||
|
@ -1,13 +1,12 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { configuration } from '../configuration/configuration';
|
||||
import { Neovim } from '../neovim/neovim';
|
||||
import logger from '../util/logger';
|
||||
import { VimState } from '../state/vimState';
|
||||
import { StatusBar } from '../statusBar';
|
||||
import * as parser from './parser';
|
||||
import * as util from '../util';
|
||||
import { VimError, ErrorCode } from '../error';
|
||||
import { Logger } from '../util/logger';
|
||||
import { CommandLineHistory } from './commandLineHistory';
|
||||
|
||||
export class CommandLine {
|
||||
@ -15,7 +14,7 @@ export class CommandLine {
|
||||
|
||||
public static async PromptAndRun(initialText: string, vimState: VimState): Promise<void> {
|
||||
if (!vscode.window.activeTextEditor) {
|
||||
Logger.debug('CommandLine: No active document');
|
||||
logger.debug('CommandLine: No active document');
|
||||
return;
|
||||
}
|
||||
|
||||
@ -79,7 +78,7 @@ export class CommandLine {
|
||||
vimState: VimState
|
||||
): Promise<string | undefined> {
|
||||
if (!vscode.window.activeTextEditor) {
|
||||
Logger.debug('CommandLine: No active document.');
|
||||
logger.debug('CommandLine: No active document.');
|
||||
return '';
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { configuration } from '../configuration/configuration';
|
||||
import { Logger } from '../util/logger';
|
||||
import logger from '../util/logger';
|
||||
|
||||
export class CommandLineHistory {
|
||||
private _history: string[] = [];
|
||||
@ -49,14 +49,14 @@ export class CommandLineHistory {
|
||||
|
||||
if (err) {
|
||||
if (err.code === 'ENOENT') {
|
||||
Logger.debug('CommandLineHistory: History does not exist.');
|
||||
logger.debug('CommandLineHistory: History does not exist.');
|
||||
// add ccommands that were run before history was loaded.
|
||||
if (this._history.length > 0) {
|
||||
this.save();
|
||||
}
|
||||
resolve();
|
||||
} else {
|
||||
Logger.error(err.message, 'Failed to load history.');
|
||||
logger.error(`Failed to load history. err=${err.message}.`);
|
||||
reject();
|
||||
}
|
||||
return;
|
||||
@ -77,14 +77,14 @@ export class CommandLineHistory {
|
||||
}
|
||||
resolve();
|
||||
} else {
|
||||
Logger.error(
|
||||
logger.error(
|
||||
'CommandLineHistory: The history format is unknown.',
|
||||
'Failed to load history.'
|
||||
);
|
||||
reject();
|
||||
}
|
||||
} catch (e) {
|
||||
Logger.error(e.message, 'Failed to load history.');
|
||||
logger.error(e.message, 'Failed to load history.');
|
||||
reject();
|
||||
}
|
||||
});
|
||||
@ -94,7 +94,7 @@ export class CommandLineHistory {
|
||||
public async save(): Promise<void> {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (this._is_loading) {
|
||||
Logger.debug('CommandLineHistory: Failed to save history because history is loading.');
|
||||
logger.debug('CommandLineHistory: Failed to save history because history is loading.');
|
||||
resolve();
|
||||
return;
|
||||
}
|
||||
@ -105,7 +105,7 @@ export class CommandLineHistory {
|
||||
if (!err) {
|
||||
resolve();
|
||||
} else {
|
||||
Logger.error(err.message, 'Failed to save history.');
|
||||
logger.error(err.message, 'Failed to save history.');
|
||||
reject();
|
||||
}
|
||||
});
|
||||
|
@ -3,7 +3,12 @@ import * as vscode from 'vscode';
|
||||
import { Globals } from '../globals';
|
||||
import { taskQueue } from '../taskQueue';
|
||||
import { Notation } from './notation';
|
||||
import { IConfiguration, IKeyRemapping, IModeSpecificStrings } from './iconfiguration';
|
||||
import {
|
||||
IConfiguration,
|
||||
IKeyRemapping,
|
||||
IModeSpecificStrings,
|
||||
IDebugConfiguration,
|
||||
} from './iconfiguration';
|
||||
|
||||
const packagejson: {
|
||||
contributes: {
|
||||
@ -230,6 +235,10 @@ class Configuration implements IConfiguration {
|
||||
replace: '#000000',
|
||||
};
|
||||
|
||||
debug: IDebugConfiguration = {
|
||||
loggingLevel: 'error',
|
||||
};
|
||||
|
||||
searchHighlightColor = 'rgba(150, 150, 255, 0.3)';
|
||||
|
||||
@overlapSetting({ codeName: 'tabSize', default: 8 })
|
||||
@ -368,4 +377,4 @@ function overlapSetting(args: {
|
||||
};
|
||||
}
|
||||
|
||||
export let configuration = new Configuration();
|
||||
export const configuration = new Configuration();
|
||||
|
@ -15,6 +15,14 @@ export interface IKeyRemapping {
|
||||
commands?: { command: string; args: any[] }[];
|
||||
}
|
||||
|
||||
export interface IDebugConfiguration {
|
||||
/**
|
||||
* Maximum level of messages to log.
|
||||
* Supported values: ['error', 'warn', 'info', 'verbose', 'debug', 'silly']
|
||||
*/
|
||||
loggingLevel: string;
|
||||
}
|
||||
|
||||
export interface IConfiguration {
|
||||
/**
|
||||
* Use the system's clipboard when copying.
|
||||
@ -131,6 +139,11 @@ export interface IConfiguration {
|
||||
*/
|
||||
statusBarColors: IModeSpecificStrings<string>;
|
||||
|
||||
/**
|
||||
* Extension debugging settings
|
||||
*/
|
||||
debug: IDebugConfiguration;
|
||||
|
||||
/**
|
||||
* Color of search highlights.
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@ import { Position } from './../common/motion/position';
|
||||
import { RecordedState } from './../state/recordedState';
|
||||
import { VimState } from './../state/vimState';
|
||||
import { TextEditor } from './../textEditor';
|
||||
import { Logger } from './../util/logger';
|
||||
import logger from './../util/logger';
|
||||
|
||||
const diffEngine = new DiffMatchPatch.diff_match_patch();
|
||||
diffEngine.Diff_Timeout = 1; // 1 second
|
||||
@ -184,7 +184,7 @@ export class HistoryTracker {
|
||||
private get currentHistoryStep(): HistoryStep {
|
||||
if (this.currentHistoryStepIndex === -1) {
|
||||
let msg = 'HistoryTracker: Tried to modify history at index -1';
|
||||
Logger.debug(msg);
|
||||
logger.debug(msg);
|
||||
throw new Error(msg);
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ export class HistoryTracker {
|
||||
*/
|
||||
async undoAndRemoveChanges(n: number): Promise<void> {
|
||||
if (this.currentHistoryStep.changes.length < n) {
|
||||
Logger.debug('HistoryTracker: Something bad happened in removeChange');
|
||||
logger.debug('HistoryTracker: Something bad happened in removeChange');
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ import {
|
||||
TextTransformations,
|
||||
} from './../transformations/transformations';
|
||||
import { Mode, ModeName, VSCodeVimCursorType } from './mode';
|
||||
import { Logger } from '../util/logger';
|
||||
import logger from '../util/logger';
|
||||
|
||||
export class ModeHandler implements vscode.Disposable {
|
||||
private _disposables: vscode.Disposable[] = [];
|
||||
@ -865,7 +865,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
|
||||
if (textTransformations.length > 0) {
|
||||
if (areAnyTransformationsOverlapping(textTransformations)) {
|
||||
Logger.debug(
|
||||
logger.debug(
|
||||
`Text transformations are overlapping. Falling back to serial
|
||||
transformations. This is generally a very bad sign. Try to make
|
||||
your text transformations operate on non-overlapping ranges.`
|
||||
@ -1370,7 +1370,7 @@ export class ModeHandler implements vscode.Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
let text = [];
|
||||
let text: string[] = [];
|
||||
|
||||
if (configuration.showmodename) {
|
||||
text.push(this.currentMode.getStatusBarText(this.vimState));
|
||||
|
@ -5,12 +5,11 @@ import { attach, Nvim } from 'promised-neovim-client';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { configuration } from '../configuration/configuration';
|
||||
import { ModeName } from '../mode/mode';
|
||||
import { Register, RegisterMode } from '../register/register';
|
||||
import { TextEditor } from '../textEditor';
|
||||
import { Position } from './../common/motion/position';
|
||||
import { VimState } from './../state/vimState';
|
||||
import { Logger } from '../util/logger';
|
||||
import logger from '../util/logger';
|
||||
|
||||
export class Neovim implements vscode.Disposable {
|
||||
private process: ChildProcess;
|
||||
@ -25,7 +24,7 @@ export class Neovim implements vscode.Disposable {
|
||||
cwd: dir,
|
||||
});
|
||||
this.process.on('error', err => {
|
||||
Logger.error(err.message, `Neovim: Error spawning neovim. Error=${err.message}.`);
|
||||
logger.error(err.message, `Neovim: Error spawning neovim. Error=${err.message}.`);
|
||||
configuration.enableNeovim = false;
|
||||
});
|
||||
this.nvim = await attach(this.process.stdin, this.process.stdout);
|
||||
@ -115,7 +114,7 @@ export class Neovim implements vscode.Disposable {
|
||||
fixedLines.join('\n')
|
||||
);
|
||||
|
||||
Logger.debug(
|
||||
logger.debug(
|
||||
`Neovim: ${lines.length} lines in nvim but ${TextEditor.getLineCount()} in editor.`
|
||||
);
|
||||
|
||||
|
@ -69,7 +69,7 @@ export class RecordedState {
|
||||
*/
|
||||
public getCurrentCommandWithoutCountPrefix(): string[] {
|
||||
const commandList = this.commandList;
|
||||
const result = [];
|
||||
const result: string[] = [];
|
||||
let previousWasCount = true;
|
||||
|
||||
for (const commandKey of commandList) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { configuration } from '../../src/configuration/configuration';
|
||||
import { configuration } from '../configuration/configuration';
|
||||
import { Position } from './../common/motion/position';
|
||||
import { ModeName } from './../mode/mode';
|
||||
import { TextEditor } from './../textEditor';
|
||||
@ -111,7 +111,7 @@ export class SearchState {
|
||||
const finalPos = new Position(TextEditor.getLineCount() - 1, 0).getLineEndIncludingEOL();
|
||||
const text = TextEditor.getText(new vscode.Range(new Position(0, 0), finalPos));
|
||||
const lineLengths = text.split('\n').map(x => x.length + 1);
|
||||
let sumLineLengths = [];
|
||||
let sumLineLengths: number[] = [];
|
||||
let curLength = 0;
|
||||
for (const length of lineLengths) {
|
||||
sumLineLengths.push(curLength);
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { Nvim } from 'promised-neovim-client';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { ModeName } from '../mode/mode';
|
||||
@ -13,7 +12,7 @@ import { GlobalState } from './../state/globalState';
|
||||
import { ReplaceState } from './../state/replaceState';
|
||||
import { RecordedState } from './recordedState';
|
||||
import { Neovim } from '../neovim/neovim';
|
||||
import { Logger } from '../util/logger';
|
||||
import logger from '../util/logger';
|
||||
|
||||
/**
|
||||
* The VimState class holds permanent state that carries over from action
|
||||
@ -147,7 +146,7 @@ export class VimState implements vscode.Disposable {
|
||||
public set allCursors(value: Range[]) {
|
||||
for (const cursor of value) {
|
||||
if (!cursor.start.isValid() || !cursor.stop.isValid()) {
|
||||
Logger.debug('VimState: invalid value for set cursor position. This is probably bad?');
|
||||
logger.debug('VimState: invalid value for set cursor position. This is probably bad?');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
import { ModeName } from './mode/mode';
|
||||
|
||||
class StatusBarImpl implements vscode.Disposable {
|
||||
@ -57,4 +56,4 @@ class StatusBarImpl implements vscode.Disposable {
|
||||
}
|
||||
}
|
||||
|
||||
export let StatusBar = new StatusBarImpl();
|
||||
export const StatusBar = new StatusBarImpl();
|
||||
|
@ -3,7 +3,7 @@ import * as vscode from 'vscode';
|
||||
|
||||
import { Position } from './common/motion/position';
|
||||
import { Range } from './common/motion/range';
|
||||
import { Logger } from './util/logger';
|
||||
import logger from './util/logger';
|
||||
|
||||
export async function showInfo(message: string): Promise<{}> {
|
||||
return vscode.window.showInformationMessage('Vim: ' + message) as {};
|
||||
@ -20,7 +20,7 @@ export class Clipboard {
|
||||
try {
|
||||
clipboardy.writeSync(text);
|
||||
} catch (e) {
|
||||
Logger.error(e, `Clipboard: Error copying to clipboard. Error=${e}`);
|
||||
logger.error(e, `Clipboard: Error copying to clipboard. Error=${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,7 +85,7 @@ export async function getExternalExtensionDirPath(): Promise<string> {
|
||||
if (!err || err.code === 'EEXIST') {
|
||||
resolve(extensionFolder);
|
||||
} else {
|
||||
Logger.debug(err.message);
|
||||
logger.error(err.message);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
|
@ -1,64 +1,11 @@
|
||||
import * as vscode from 'vscode';
|
||||
import { configuration } from '../configuration/configuration';
|
||||
import * as winston from 'winston';
|
||||
import { ConsoleForElectron } from 'winston-console-for-electron';
|
||||
|
||||
enum LoggingLevel {
|
||||
Error = 0,
|
||||
Warn = 1,
|
||||
Debug = 2,
|
||||
}
|
||||
const logger = winston.createLogger({
|
||||
level: configuration.debug.loggingLevel,
|
||||
format: winston.format.simple(),
|
||||
transports: [new ConsoleForElectron()],
|
||||
});
|
||||
|
||||
class LoggerImpl implements vscode.Disposable {
|
||||
private _channel: vscode.OutputChannel;
|
||||
|
||||
constructor() {
|
||||
this._channel = vscode.window.createOutputChannel('vscodevim');
|
||||
}
|
||||
|
||||
public debug(message?: string): void {
|
||||
this.emitMessage(LoggingLevel.Debug, message);
|
||||
}
|
||||
|
||||
public error(message?: string, friendlyMessage?: string): void {
|
||||
this.emitMessage(LoggingLevel.Error, message);
|
||||
vscode.window.showErrorMessage(`Error: ${friendlyMessage} || ${message}`);
|
||||
}
|
||||
|
||||
private emitMessage(loggingLevel: LoggingLevel, message?: string) {
|
||||
if (message === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
message = `${LoggerImpl.getNow()} - ${message}`;
|
||||
|
||||
this._channel.appendLine(message);
|
||||
|
||||
switch (loggingLevel) {
|
||||
case LoggingLevel.Error:
|
||||
console.error(message);
|
||||
break;
|
||||
case LoggingLevel.Warn:
|
||||
console.warn(message);
|
||||
break;
|
||||
case LoggingLevel.Debug:
|
||||
console.log(message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private static getNow(): string {
|
||||
const now = new Date();
|
||||
let time = [String(now.getHours()), String(now.getMinutes()), String(now.getSeconds())];
|
||||
for (let i = 0; i < time.length; i++) {
|
||||
if (Number(time[i]) < 10) {
|
||||
time[i] = '0' + time[i];
|
||||
}
|
||||
}
|
||||
|
||||
return time.join(':');
|
||||
}
|
||||
|
||||
dispose() {
|
||||
this._channel.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
export let Logger = new LoggerImpl();
|
||||
export default logger;
|
||||
|
@ -40,6 +40,9 @@ export class Configuration implements IConfiguration {
|
||||
visualblock: '#86592d';
|
||||
replace: '#000000';
|
||||
};
|
||||
debug: {
|
||||
loggingLevel: 'info';
|
||||
};
|
||||
searchHighlightColor = 'rgba(150, 150, 255, 0.3)';
|
||||
tabstop = 2;
|
||||
userCursor = vscode.TextEditorCursorStyle.Line;
|
||||
|
@ -3,7 +3,6 @@
|
||||
"module": "commonjs",
|
||||
"target": "es6",
|
||||
"outDir": "out",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitReturns": true,
|
||||
"noUnusedLocals": false,
|
||||
"noUnusedParameters": false,
|
||||
|
Loading…
Reference in New Issue
Block a user