• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / vscode-brightscript-language / 30096694707

24 Jul 2026 01:23PM UTC coverage: 59.949% (+0.04%) from 59.908%
30096694707

Pull #802

github

web-flow
Merge 333fa7808 into e465804e3
Pull Request #802: Route extension logs through the BrightScript Extension output channel

2592 of 4745 branches covered (54.63%)

Branch coverage included in aggregate %.

19 of 23 new or added lines in 3 files covered. (82.61%)

732 existing lines in 18 files now uncovered.

4036 of 6311 relevant lines covered (63.95%)

43.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.35
/src/logging.ts
1
import type * as vscode from 'vscode';
2
import type { LogMessage, Transport } from '@rokucommunity/logger';
3
import { Logger, ConsoleTransport } from '@rokucommunity/logger';
1✔
4

5
/**
6
 * Routes log messages to a vscode OutputChannel once one has been attached.
7
 * Until then, messages are buffered so logs emitted during module load
8
 * (before extension activation) are not lost.
9
 */
10
class OutputChannelTransport implements Transport {
11
    private channel: vscode.OutputChannel | undefined;
12
    private buffer: LogMessage[] = [];
1✔
13

14
    public attach(channel: vscode.OutputChannel) {
15
        this.channel = channel;
12✔
16
        for (const message of this.buffer) {
12✔
NEW
17
            this.write(message);
×
18
        }
19
        this.buffer = [];
12✔
20
    }
21

22
    public pipe(message: LogMessage) {
23
        if (this.channel) {
2!
24
            this.write(message);
2✔
25
        } else {
NEW
26
            this.buffer.push(message);
×
27
        }
28
    }
29

30
    private write(message: LogMessage) {
31
        this.channel.appendLine(message.logger.formatMessage(message, false));
2✔
32
    }
33
}
34

35
const outputChannelTransport = new OutputChannelTransport();
1✔
36

37
/**
38
 * Singleton logger for the extension. Writes to the developer console (for
39
 * extension-host debugging) and to the `BrightScript Extension` output channel
40
 * (for end-users). Use `logger.createLogger('Prefix')` to make a sub-logger
41
 * that tags every message with a component name.
42
 */
43
export const logger = new Logger({
1✔
44
    logLevel: 'log',
45
    transports: [
46
        new ConsoleTransport(),
47
        outputChannelTransport
48
    ]
49
});
50

51
export const createLogger = logger.createLogger.bind(logger) as typeof Logger.prototype.createLogger;
1✔
52

53
/**
54
 * Attach the extension output channel to the shared logger. Should be called
55
 * once during extension activation, right after the channel is created.
56
 */
57
export function attachExtensionOutputChannel(channel: vscode.OutputChannel) {
1✔
58
    outputChannelTransport.attach(channel);
12✔
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc