Created
July 23, 2025 19:55
-
-
Save DaelonSuzuka/2cd94bc0b7588706cfbadb7550d980fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { LogOutputChannel, window } from "vscode"; | |
| const RESET = "\u001b[0m"; | |
| const LOG_COLORS = { | |
| RESET, // SILENT, normal | |
| ERROR: "\u001b[1;31m", // ERROR, red | |
| WARNING: "\u001b[1;33m", // WARNING, yellow | |
| INFO: "\u001b[1;36m", // INFO, cyan | |
| DEBUG: "\u001b[1;32m", // DEBUG, green | |
| TRACE: "\u001b[1;35m", // TRACE, magenta | |
| }; | |
| export class Logger { | |
| trace; | |
| debug; | |
| info; | |
| warn; | |
| error; | |
| constructor(public readonly name: string) { | |
| console.log("creating new Logger: ", name); | |
| this.trace = console.trace.bind(console, `[${LOG_COLORS.TRACE}${name}${RESET}]`); | |
| this.debug = console.debug.bind(console, `[${LOG_COLORS.DEBUG}${name}${RESET}]`); | |
| this.info = console.info.bind(console, `[${LOG_COLORS.INFO}${name}${RESET}]`); | |
| this.warn = console.warn.bind(console, `[${LOG_COLORS.WARNING}${name}${RESET}]`); | |
| this.error = console.error.bind(console, `[${LOG_COLORS.ERROR}${name}${RESET}]`); | |
| } | |
| } | |
| export function getLogger(name: string) { | |
| return new Logger(name); | |
| // return { | |
| // trace: console.trace.bind(console, `[${LOG_COLORS.TRACE}${name}${RESET}]`), | |
| // debug: console.debug.bind(console, `[${LOG_COLORS.DEBUG}${name}${RESET}]`), | |
| // info: console.info.bind(console, `[${LOG_COLORS.INFO}${name}${RESET}]`), | |
| // warn: console.warn.bind(console, `[${LOG_COLORS.WARNING}${name}${RESET}]`), | |
| // error: console.error.bind(console, `[${LOG_COLORS.ERROR}${name}${RESET}]`), | |
| // }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment