forked from mrsone40/.github-workflows
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlogging.ts
More file actions
60 lines (47 loc) · 1.52 KB
/
logging.ts
File metadata and controls
60 lines (47 loc) · 1.52 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
import * as util from 'util';
import { Disposable, LogOutputChannel } from 'vscode';
type Arguments = unknown[];
class OutputChannelLogger {
constructor(private readonly channel: LogOutputChannel) {}
public traceLog(...data: Arguments): void {
this.channel.appendLine(util.format(...data));
}
public traceError(...data: Arguments): void {
this.channel.error(util.format(...data));
}
public traceWarn(...data: Arguments): void {
this.channel.warn(util.format(...data));
}
public traceInfo(...data: Arguments): void {
this.channel.info(util.format(...data));
}
public traceVerbose(...data: Arguments): void {
this.channel.debug(util.format(...data));
}
}
let channel: OutputChannelLogger | undefined;
export function registerLogger(logChannel: LogOutputChannel): Disposable {
channel = new OutputChannelLogger(logChannel);
return {
dispose: () => {
channel = undefined;
},
};
}
export function traceLog(...args: Arguments): void {
channel?.traceLog(...args);
}
export function traceError(...args: Arguments): void {
channel?.traceError(...args);
}
export function traceWarn(...args: Arguments): void {
channel?.traceWarn(...args);
}
export function traceInfo(...args: Arguments): void {
channel?.traceInfo(...args);
}
export function traceVerbose(...args: Arguments): void {
channel?.traceVerbose(...args);
}