Skip to content

Commit 45ffd8a

Browse files
committed
Tidy up logging docs
1 parent 74e047c commit 45ffd8a

3 files changed

Lines changed: 28 additions & 19 deletions

File tree

extensions/ql-vscode/src/common/logging/logger.ts

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,34 @@
11
export interface LogOptions {
2-
/** If false, don't output a trailing newline for the log entry. Default true. */
2+
// If false, don't output a trailing newline for the log entry. Default true.
33
trailingNewline?: boolean;
44

5-
/** If specified, add this log entry to the log file at the specified location. */
5+
// If specified, add this log entry to the log file at the specified location.
66
additionalLogLocation?: string;
77
}
88

99
export interface Logger {
10-
/** Writes the given log message, optionally followed by a newline. */
10+
/**
11+
* Writes the given log message, optionally followed by a newline.
12+
* This function is asynchronous and will only resolve once the message is written
13+
* to the side log (if required). It is not necessary to await the results of this
14+
* function if you don't need to guarantee that the log writing is complete before
15+
* continuing.
16+
*
17+
* @param message The message to log.
18+
* @param options Optional settings.
19+
*/
1120
log(message: string, options?: LogOptions): Promise<void>;
21+
1222
/**
13-
* Reveal this channel in the UI.
23+
* Reveal the logger channel in the UI.
1424
*
1525
* @param preserveFocus When `true` the channel will not take focus.
1626
*/
1727
show(preserveFocus?: boolean): void;
1828

1929
/**
20-
* Remove the log at the specified location
30+
* Remove the log at the specified location.
31+
*
2132
* @param location log to remove
2233
*/
2334
removeAdditionalLogLocation(location: string | undefined): void;
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
1+
/**
2+
* This module contains instantiated loggers to use in the extension.
3+
*/
4+
15
import { OutputChannelLogger } from "./output-channel-logger";
26

3-
/** The global logger for the extension. */
7+
// Global logger for the extension.
48
export const logger = new OutputChannelLogger("CodeQL Extension Log");
59

6-
/** The logger for messages from the query server. */
10+
// Logger for messages from the query server.
711
export const queryServerLogger = new OutputChannelLogger("CodeQL Query Server");
812

9-
/** The logger for messages from the language server. */
13+
// Logger for messages from the language server.
1014
export const ideServerLogger = new OutputChannelLogger(
1115
"CodeQL Language Server",
1216
);
1317

14-
/** The logger for messages from tests. */
18+
// Logger for messages from tests.
1519
export const testLogger = new OutputChannelLogger("CodeQL Tests");

extensions/ql-vscode/src/common/logging/vscode/output-channel-logger.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import * as path from "path";
44
import { Logger, LogOptions } from "../logger";
55
import { DisposableObject } from "../../../pure/disposable-object";
66

7-
/** A logger that writes messages to an output channel in the Output tab. */
7+
/**
8+
* A logger that writes messages to an output channel in the VS Code Output tab.
9+
*/
810
export class OutputChannelLogger extends DisposableObject implements Logger {
911
public readonly outputChannel: OutputChannel;
1012
private readonly additionalLocations = new Map<
@@ -20,12 +22,6 @@ export class OutputChannelLogger extends DisposableObject implements Logger {
2022
this.isCustomLogDirectory = false;
2123
}
2224

23-
/**
24-
* This function is asynchronous and will only resolve once the message is written
25-
* to the side log (if required). It is not necessary to await the results of this
26-
* function if you don't need to guarantee that the log writing is complete before
27-
* continuing.
28-
*/
2925
async log(message: string, options = {} as LogOptions): Promise<void> {
3026
try {
3127
if (options.trailingNewline === undefined) {
@@ -82,9 +78,7 @@ export class OutputChannelLogger extends DisposableObject implements Logger {
8278
}
8379

8480
class AdditionalLogLocation {
85-
constructor(private location: string) {
86-
/**/
87-
}
81+
constructor(private location: string) {}
8882

8983
async log(message: string, options = {} as LogOptions): Promise<void> {
9084
if (options.trailingNewline === undefined) {

0 commit comments

Comments
 (0)