UNPKG

@arkts/shared

Version:
84 lines (80 loc) 3.34 kB
import { LanguageServerLogger } from "./lsp-logger-CF8e27mS.mjs"; import kleur from "kleur"; import * as vscode from "vscode"; //#region ../vscode/package.json var version = "1.0.26"; //#endregion //#region src/log/ext-reporter.ts var OutputChannelReporter = class { constructor(outputChannel, prefix) { this.outputChannel = outputChannel; this.prefix = prefix; } safeStringify(value) { try { return JSON.stringify(value); } catch { return String(value); } } toString(logObj) { if (logObj.message) return logObj.message; if (logObj.args.length === 0) return this.safeStringify(logObj); return logObj.args.join(" "); } log(logObj, _ctx) { switch (logObj.type) { case "log": this.outputChannel.appendLine(kleur.gray(`[${logObj.type.toUpperCase()}] 📅:${this.prefix ? ` <${this.prefix}>` : ""}${logObj.tag} ${kleur.dim(logObj.date.toLocaleString())} ${this.toString(logObj)}`)); break; case "warn": this.outputChannel.appendLine(kleur.yellow(`[${logObj.type.toUpperCase()}] ⚠️:${this.prefix ? ` <${this.prefix}>` : ""}${logObj.tag} ${kleur.dim(logObj.date.toLocaleString())} ${this.toString(logObj)}`)); break; case "info": this.outputChannel.appendLine(kleur.blue(`[${logObj.type.toUpperCase()}] 🔥:${this.prefix ? ` <${this.prefix}>` : ""}${logObj.tag} ${kleur.dim(logObj.date.toLocaleString())} ${this.toString(logObj)}`)); break; case "success": case "ready": case "start": this.outputChannel.appendLine(kleur.green(`[${logObj.type.toUpperCase()}] ✅:${this.prefix ? ` <${this.prefix}>` : ""}${logObj.tag} ${kleur.dim(logObj.date.toLocaleString())} ${this.toString(logObj)}`)); break; case "fail": case "fatal": case "error": this.outputChannel.appendLine(kleur.red(`[${logObj.type.toUpperCase()}] ❌:${this.prefix ? ` <${this.prefix}>` : ""}${logObj.tag} ${kleur.dim(logObj.date.toLocaleString())} ${this.toString(logObj)}`)); break; case "debug": case "verbose": case "trace": this.outputChannel.appendLine(kleur.gray(`[${logObj.type.toUpperCase()}] 🐛:${this.prefix ? ` <${this.prefix}>` : ""}${logObj.tag} ${kleur.dim(logObj.date.toLocaleString())} ${this.toString(logObj)}`)); break; case "box": this.outputChannel.appendLine(kleur.gray(`[${logObj.type.toUpperCase()}] 📦:${this.prefix ? ` <${this.prefix}>` : ""}${logObj.tag} ${kleur.dim(logObj.date.toLocaleString())} ${this.toString(logObj)}`)); break; } } }; //#endregion //#region src/log/extension-logger.ts var ExtensionLogger = class ExtensionLogger extends LanguageServerLogger { static outputChannel; static extensionVersionIsLogged = false; constructor() { const outputChannel = ExtensionLogger.outputChannel ? ExtensionLogger.outputChannel : vscode.window.createOutputChannel(`ETS Support Powered by Naily`, "log"); super({ reporters: [new OutputChannelReporter(outputChannel, "Naily's ETS Support")], prefix: "Naily's ETS Support" }); ExtensionLogger.outputChannel = outputChannel; if (!ExtensionLogger.extensionVersionIsLogged) { this.getConsola().info(`ETS Support Plugin version: ${version}`); ExtensionLogger.extensionVersionIsLogged = true; } } getOutputChannel() { return ExtensionLogger.outputChannel; } }; //#endregion export { ExtensionLogger }; //# sourceMappingURL=vscode.mjs.map