vscode-texinfo/src/logger.ts

48 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2020-10-22 22:37:47 +00:00
/**
* logger.ts
2021-03-16 12:01:13 +00:00
*
* Copyright (C) 2020,2021 CismonX <admin@cismon.net>
*
* This file is part of vscode-texinfo.
*
* vscode-texinfo is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* vscode-texinfo is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* vscode-texinfo. If not, see <https://www.gnu.org/licenses/>.
2020-10-22 22:37:47 +00:00
*/
import * as vscode from 'vscode';
/**
* Logger which prints message to VSCode output channel.
*/
2021-08-11 17:23:04 +00:00
export default class Logger implements vscode.Disposable
{
2021-04-19 12:43:20 +00:00
log(message: string) {
2021-08-11 17:23:04 +00:00
const dateTime = new Date().toLocaleString(
undefined,
{ hour12: false }
);
2021-05-25 04:16:56 +00:00
this._outputChannel.appendLine(`[ ${dateTime} ]\n${message}`);
2020-10-22 22:37:47 +00:00
}
2021-04-19 12:43:20 +00:00
show() {
2021-05-25 04:16:56 +00:00
this._outputChannel.show(true);
2021-03-15 12:43:38 +00:00
}
2020-10-24 21:45:32 +00:00
dispose() {
2021-05-25 04:16:56 +00:00
this._outputChannel.dispose();
2020-10-22 22:37:47 +00:00
}
2021-04-19 12:43:20 +00:00
private readonly _outputChannel
= vscode.window.createOutputChannel('Texinfo');
2020-10-22 22:37:47 +00:00
}