mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-22 15:34:49 +01:00
feat: Logger
This commit is contained in:
parent
480e2fd32c
commit
fa6a0b2399
1 changed files with 6 additions and 5 deletions
|
@ -2,15 +2,15 @@ import * as vscode from 'vscode';
|
|||
import * as codemp from '../index'; // TODO why won't it work with a custom name???
|
||||
import * as codemplogic from './codemp';
|
||||
|
||||
export let LOGGER = vscode.window.createOutputChannel("codemp", {log: true});
|
||||
|
||||
// extension is activated the very first time the command is executed
|
||||
export function activate(context: vscode.ExtensionContext) {
|
||||
// Use the console to output diagnostic information (console.log) and errors (console.error)
|
||||
console.log('Congratulations, your extension "codempvscode" is now active!');
|
||||
|
||||
// start codemp log poller
|
||||
let channel = vscode.window.createOutputChannel("codemp", {log: true});
|
||||
let logger = new codemp.JsLogger(false);
|
||||
log_poller_task(logger, channel); // don't await it! run it in background forever
|
||||
log_poller_task(new codemp.JsLogger(true)); // don't await it! run it in background forever
|
||||
|
||||
// register commands: the commandId parameter must match the command field in package.json
|
||||
for (let cmd of [
|
||||
|
@ -22,18 +22,19 @@ export function activate(context: vscode.ExtensionContext) {
|
|||
vscode.commands.registerCommand('codempvscode.listBuffers', codemplogic.listBuffers),
|
||||
// vscode.commands.registerCommand('codempvscode.disconnectBuffer', codemplogic.disconnectBuffer),
|
||||
vscode.commands.registerCommand('codempvscode.sync', codemplogic.sync),
|
||||
vscode.commands.registerCommand('codempvscode.printOpCache', codemplogic.printOpCache)
|
||||
]) {
|
||||
context.subscriptions.push(cmd);
|
||||
}
|
||||
}
|
||||
|
||||
async function log_poller_task(logger: codemp.JsLogger, channel: vscode.LogOutputChannel) {
|
||||
async function log_poller_task(logger: codemp.JsLogger) {
|
||||
console.log("starting logger task");
|
||||
while (true) {
|
||||
let message = await logger.message();
|
||||
if (message === null) break;
|
||||
console.log(message);
|
||||
channel.info(message);
|
||||
LOGGER.info(message);
|
||||
}
|
||||
console.log("stopping logger task");
|
||||
}
|
Loading…
Reference in a new issue