Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: append activation timestamp to output channel names #505

Merged
merged 2 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ 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.
*
* @see https://github.com/microsoft/vscode/issues/204946
*/
export const activationTimestamp = Date.now();

/**
* Whether the current platform uses musl
*/
Expand Down
11 changes: 8 additions & 3 deletions src/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { LogLevel, window } from "vscode";
import { displayName } from "../package.json";
import { activationTimestamp } from "./constants";

/**
* Logger
Expand All @@ -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<string, unknown>;

Expand Down
21 changes: 14 additions & 7 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
},
Expand All @@ -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,
},
);
};

/**
Expand All @@ -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,
},
Expand All @@ -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,
},
Expand Down