forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogger.ts
More file actions
40 lines (36 loc) · 1.28 KB
/
logger.ts
File metadata and controls
40 lines (36 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import * as vscode from "vscode";
import * as settings from "./configSettings";
let outChannel: vscode.OutputChannel;
class Logger {
public static IsDebug: boolean;
static initializeChannel() {
if (settings.PythonSettings.getInstance().devOptions.indexOf("DEBUG") >= 0) {
Logger.IsDebug = true;
outChannel = vscode.window.createOutputChannel("PythonExtLog");
}
}
static write(category: string = "log", title: string = "", message: any) {
Logger.initializeChannel();
if (title.length > 0) {
Logger.writeLine(category, "---------------------------");
Logger.writeLine(category, title);
}
Logger.writeLine(category, message);
}
static writeLine(category: string = "log", line: any) {
console[category](line);
if (outChannel) {
outChannel.appendLine(line);
}
}
}
export function error(title: string = "", message: any) {
Logger.write.apply(Logger, ["error", title, message]);
}
export function warn(title: string = "", message: any) {
Logger.write.apply(Logger, ["warn", title, message]);
}
export function log(title: string = "", message: any) {
if (!Logger.IsDebug) return;
Logger.write.apply(Logger, ["log", title, message]);
}