From 7b84918412e4237de9d73e645c543952c7c1f332 Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Fri, 17 Jan 2025 09:04:09 -0500 Subject: [PATCH] Tweak file naming and use `output.log()` --- editors/code/src/binary.ts | 10 +++++----- editors/code/src/lsp.ts | 2 +- editors/code/src/{logging.ts => output.ts} | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) rename editors/code/src/{logging.ts => output.ts} (85%) diff --git a/editors/code/src/binary.ts b/editors/code/src/binary.ts index 53306640..ab25bb85 100644 --- a/editors/code/src/binary.ts +++ b/editors/code/src/binary.ts @@ -1,7 +1,7 @@ import * as vscode from "vscode"; import which from "which"; +import * as output from "./output"; import { AIR_BINARY_NAME, BUNDLED_AIR_EXECUTABLE } from "./constants"; -import { outputLog } from "./logging"; export type ExecutableLocation = "environment" | "bundled"; @@ -9,7 +9,7 @@ export async function resolveAirBinaryPath( executableLocation: ExecutableLocation ): Promise { if (!vscode.workspace.isTrusted) { - outputLog( + output.log( `Workspace is not trusted, using bundled executable: ${BUNDLED_AIR_EXECUTABLE}` ); return BUNDLED_AIR_EXECUTABLE; @@ -17,7 +17,7 @@ export async function resolveAirBinaryPath( // User requested the bundled air binary if (executableLocation === "bundled") { - outputLog( + output.log( `Using bundled executable as requested by \`air.executableLocation\`: ${BUNDLED_AIR_EXECUTABLE}` ); return BUNDLED_AIR_EXECUTABLE; @@ -26,11 +26,11 @@ export async function resolveAirBinaryPath( // First choice: the executable in the global environment. const environmentPath = await which(AIR_BINARY_NAME, { nothrow: true }); if (environmentPath) { - outputLog(`Using environment executable: ${environmentPath}`); + output.log(`Using environment executable: ${environmentPath}`); return environmentPath; } // Second choice: bundled executable. - outputLog(`Using bundled executable: ${BUNDLED_AIR_EXECUTABLE}`); + output.log(`Using bundled executable: ${BUNDLED_AIR_EXECUTABLE}`); return BUNDLED_AIR_EXECUTABLE; } diff --git a/editors/code/src/lsp.ts b/editors/code/src/lsp.ts index 28ec61d8..c6eb6e48 100644 --- a/editors/code/src/lsp.ts +++ b/editors/code/src/lsp.ts @@ -3,7 +3,7 @@ import * as lc from "vscode-languageclient/node"; import { default as PQueue } from "p-queue"; import { getInitializationOptions, getWorkspaceSettings } from "./settings"; import { Middleware, ResponseError } from "vscode-languageclient/node"; -import { registerLogger } from "./logging"; +import { registerLogger } from "./output"; import { resolveAirBinaryPath } from "./binary"; import { getRootWorkspaceFolder } from "./workspace"; diff --git a/editors/code/src/logging.ts b/editors/code/src/output.ts similarity index 85% rename from editors/code/src/logging.ts rename to editors/code/src/output.ts index 4290951c..b2963b0f 100644 --- a/editors/code/src/logging.ts +++ b/editors/code/src/output.ts @@ -5,7 +5,7 @@ type Arguments = unknown[]; class OutputChannelLogger { constructor(private readonly channel: OutputChannel) {} - public outputLog(...data: Arguments): void { + public log(...data: Arguments): void { this.channel.appendLine(util.format(...data)); } } @@ -26,9 +26,9 @@ export function registerLogger(logChannel: OutputChannel): Disposable { * Adapted from: * https://github.com/microsoft/vscode-python-tools-extension-template/blob/main/src/common/log/logging.ts */ -export function outputLog(...args: Arguments): void { +export function log(...args: Arguments): void { if (process.env.CI === "true") { console.log(...args); } - channel?.outputLog(...args); + channel?.log(...args); }