From 22bfe725ac5ccb714288edb00f271bc7c06569c9 Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Sun, 23 Feb 2025 19:25:01 +0100 Subject: [PATCH 1/2] chore: append activation timestamp to output channel names --- src/constants.ts | 10 ++++++++++ src/logger.ts | 11 ++++++++--- src/session.ts | 21 ++++++++++++++------- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 67371d3..90c67e5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -2,6 +2,16 @@ import { spawnSync } from "node:child_process"; import isWSL from "is-wsl"; import { workspace } from "vscode"; +/** + * Activation timestamp + * + * This constant contains the timestamp at which the extension was activated. + * + * We use this constant to generate unique identifiers for output channels to + * mitigate a bug in VS Code where the output channel is not cleared. + */ +export const activationTimestamp = Date.now(); + /** * Whether the current platform uses musl */ diff --git a/src/logger.ts b/src/logger.ts index c1ef355..79264d4 100644 --- a/src/logger.ts +++ b/src/logger.ts @@ -1,5 +1,6 @@ import { LogLevel, window } from "vscode"; import { displayName } from "../package.json"; +import { activationTimestamp } from "./constants"; /** * Logger @@ -11,9 +12,13 @@ import { displayName } from "../package.json"; * logging verbosity, so only messages with the appropriate log level will be * displayed. */ -export const logger = window.createOutputChannel(displayName, { - log: true, -}); + +export const logger = window.createOutputChannel( + `${displayName} (${activationTimestamp})`, + { + log: true, + }, +); type LogArguments = Record; diff --git a/src/session.ts b/src/session.ts index 91d0ecb..b578a17 100644 --- a/src/session.ts +++ b/src/session.ts @@ -16,7 +16,11 @@ import { import { displayName } from "../package.json"; import { findBiomeGlobally, findBiomeLocally } from "./binary-finder"; import { isEnabledGlobally } from "./config"; -import { operatingMode, supportedLanguageIdentifiers } from "./constants"; +import { + activationTimestamp, + operatingMode, + supportedLanguageIdentifiers, +} from "./constants"; import { debug, error, info, error as logError, warn } from "./logger"; import { type Project, createProjects } from "./project"; import { state } from "./state"; @@ -294,7 +298,7 @@ const createLspLogger = (project?: Project): LogOutputChannel => { // logger name, so we just use the display name of the extension. if (!project?.folder) { return window.createOutputChannel( - `${displayName} LSP (global session)`, + `${displayName} LSP (global session) (${activationTimestamp})`, { log: true, }, @@ -309,9 +313,12 @@ const createLspLogger = (project?: Project): LogOutputChannel => { operatingMode === "multi-root" ? `${project.folder.name}::` : ""; const path = subtractURI(project.path, project.folder.uri).fsPath; - return window.createOutputChannel(`${displayName} LSP (${prefix}${path})`, { - log: true, - }); + return window.createOutputChannel( + `${displayName} LSP (${prefix}${path}) (${activationTimestamp})`, + { + log: true, + }, + ); }; /** @@ -323,7 +330,7 @@ const createLspTraceLogger = (project?: Project): LogOutputChannel => { // logger name, so we just use the display name of the extension. if (!project?.folder) { return window.createOutputChannel( - `${displayName} LSP trace (global session)`, + `${displayName} LSP trace (global session) (${activationTimestamp})`, { log: true, }, @@ -339,7 +346,7 @@ const createLspTraceLogger = (project?: Project): LogOutputChannel => { const path = subtractURI(project.path, project.folder.uri).fsPath; return window.createOutputChannel( - `${displayName} LSP trace (${prefix}${path})`, + `${displayName} LSP trace (${prefix}${path}) (${activationTimestamp})`, { log: true, }, From 58cde73ca103075f809e693efbb764b4cb3ae693 Mon Sep 17 00:00:00 2001 From: Nicolas Hedger Date: Sun, 23 Feb 2025 19:29:15 +0100 Subject: [PATCH 2/2] add issue link --- src/constants.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/constants.ts b/src/constants.ts index 90c67e5..eddc4a5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -9,6 +9,8 @@ import { workspace } from "vscode"; * * We use this constant to generate unique identifiers for output channels to * mitigate a bug in VS Code where the output channel is not cleared. + * + * @see https://github.com/microsoft/vscode/issues/204946 */ export const activationTimestamp = Date.now();