MCPcopy
hub / github.com/microsoft/vscode-js-debug / Logger

Class Logger

src/common/logging/logger.ts:35–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 */
34@injectable()
35export class Logger implements ILogger, IDisposable {
36 /**
37 * The target of the logger. Either a list of sinks, or a queue of items
38 * to write once we get sinks.
39 */
40 private logTarget: { queue: ILogItem<unknown>[] } | { sinks: ILogSink[] } = { queue: [] };
41
42 /**
43 * Log buffer for replaying diagnostics.
44 */
45 private readonly logBuffer = new RingBuffer(1);
46
47 /**
48 * A no-op logger that never logs anything.
49 */
50 public static null = (() => {
51 const logger = new Logger();
52 logger.setup({ sinks: [] });
53 return logger;
54 })();
55
56 /**
57 * Creates a logger with the TestLogSink hooked up.
58 */
59 public static async test() {
60 const logger = new Logger();
61 logger.setup({ sinks: [new TestLogSink()], showWelcome: false });
62 return logger;
63 }
64
65 /**
66 * @inheritdoc
67 */
68 public info(tag: LogTag, msg?: string, metadata?: unknown): void {
69 this.log({
70 tag,
71 timestamp: Date.now(),
72 message: msg,
73 metadata,
74 level: LogLevel.Info,
75 });
76 }
77
78 /**
79 * @inheritdoc
80 */
81 public verbose(tag: LogTag, msg?: string, metadata?: unknown): void {
82 this.log({
83 tag,
84 timestamp: Date.now(),
85 message: msg,
86 metadata,
87 level: LogLevel.Verbose,
88 });
89 }
90
91 /**
92 * @inheritdoc

Callers

nothing calls this directly

Calls 1

setupMethod · 0.65

Tested by

no test coverage detected