vscode自动打印日志插件

435 阅读2分钟

自动日志工具(Auto Logger Log)

icon.png

icon1.gif

概述

自动日志工具(Auto Logger Log) 是一款 VS Code 扩展,用于简化生成调试日志的过程。它可以为选中的变量自动生成打印语句,帮助开发者快速记录和调试代码。该扩展支持多种流行编程语言,包括 Java、Python、JavaScript、Go 和 Rust。


主要功能

🛠 支持的语言

  • Java:生成针对变量类型的 System.out.println 语句。
  • Python:创建变量的 print 语句。
  • JavaScript/TypeScript:为变量生成 console.log 语句。
  • Go:支持生成 fmt.Println 日志语句。
  • Rust:提供 println! 日志宏。

github下载地址

github

微软离线插件下载地址

微软

⚙️ 详细功能

  1. 智能变量处理

    • 自动检测变量类型(字符串、数字、布尔值、数组等)。
    • 根据语言特性生成对应的打印语句。
  2. 行号集成

    • 在日志中记录变量所在的行号,方便快速定位变量的使用位置。
  3. 跨平台兼容

    • 无需额外配置即可使用。
    • 支持 Windows、Linux 和 macOS 开发环境。
  4. 可定制化

    • 支持自定义快捷键,适配个人开发习惯。

使用方法

1️⃣ 安装扩展

  1. 打开 VS Code。
  2. 前往扩展市场,搜索 Auto Logger Log
  3. 点击 安装

2️⃣ 触发快捷键

  • 在代码中选中变量。
  • 按下默认快捷键 Ctrl + Alt + P(Windows/Linux)或 Crtl + Option + P(macOS)。
  • 扩展会在选中变量的下一行自动插入一条与语言匹配的打印语句。

3️⃣ 示例

输入代码:
const myVariable = 42;
const anotherVariable = "Hello";

icon.png

icon1.gif

Auto Logger Log

Overview

Auto Logger Log is a VS Code extension designed to streamline the process of generating debug logs. It automatically generates print statements for selected variables, making it easier to log and debug code. The extension supports popular programming languages such as Java, Python, JavaScript, Go, and Rust.

Version supports a minimum of 1.79.2

Key Features

🛠 Supported Languages

  • Java: Generates System.out.println statements tailored to variable types.
  • Python: Creates print statements for variables.
  • JavaScript/TypeScript: Produces console.log statements for variables.
  • Go: Supports the generation of fmt.Println log statements.
  • Rust: Provides println! log macros.

⚙️ Detailed Features

  1. Smart Variable Handling

    • Automatically detects variable types (strings, numbers, booleans, arrays, etc.).
    • Generates language-specific print statements for logging variables.
  2. Line Number Integration

    • Logs the line number alongside the variable name for easy identification of where variables are used.
  3. Cross-Platform Compatibility

    • Works out of the box without additional configuration.
    • Supports Windows, Linux, and macOS development environments.
  4. Customizability

    • Shortcut keys are configurable to suit individual development preferences.

How to Use

1️⃣ Install the Extension

  1. Open VS Code.
  2. Go to the Extensions Marketplace and search for Auto Logger Log.
  3. Click Install.

2️⃣ Trigger the Shortcut

  • Select a variable in your code.
  • Press the default shortcut Ctrl + Alt + P (Windows/Linux) or Cmd + Alt + P (macOS).
  • The extension will automatically insert a language-appropriate print statement below the selection.

3️⃣ Example

Input Code:
const myVariable = 42;
const anotherVariable = "Hello";
// User selects `myVariable`

Microsoft Offline Plugin Download Address

marketplace.visualstudio.com/items?itemN…