PolyLog is a VS Code extension that automatically detects the programming language and inserts the appropriate log statement for selected variables. Whether you’re working in JavaScript, TypeScript, PHP, or a mix within HTML, PolyLog simplifies debugging by adding language-specific log statements with a single click.
Features
Automatic Language Detection: Detects the file type based on its extension and determines the appropriate log statement for the language.
Flexible Log Placement: Works seamlessly within <script> tags in HTML and PHP files, inserting JavaScript log statements inside embedded scripts.
Language-Specific Logging: Automatically adds:
console.error statements for JavaScript and TypeScript files, with custom styling for enhanced readability.
echo statements for PHP files.
Supported Languages
JavaScript
TypeScript
PHP
Usage
Select a Variable: Highlight the variable you wish to log in your code. PolyLog will detect the variable and add a log statement for it only.
Insert Log Statement: Use the command palette or keyboard shortcut to insert the log statement:
Open the Command Palette with Cmd+Shift+P (Mac) or Ctrl+Shift+P (Windows) and select PolyLog: Add Log.
Alternatively, use Cmd+Shift+A (Mac) or Ctrl+Shift+A (Windows) for a quick shortcut to add the log.
Examples
In a JavaScript or TypeScript file:
Select a variable (e.g., logStr), and PolyLog will insert: