@ygqygq2/vscode-log
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

vscode-log

Usage

vscode-log is a package that allows you to easily log messages in Visual Studio Code. Here's how you can use it:

  1. Install the @ygqygq2/vscode-log package by running the following command in your terminal:
npm install @ygqygq2/vscode-log
  1. Import the @ygqygq2/vscode-log module and configure, create and get the logger instance as follows:
import { ErrorCodeMessage, Logger, CustomError } from "@ygqygq2/vscode-log";

enum CustomErrorCode {
  // Git 相关错误 (1000 - 1009)
  GitNotInit = 1000,
  GitGetUserNameFail = 1001,
  GitGetUserEmailFail = 1002,
  GitGetBirthtimeFail = 1003,
  MissingUserNameEmail = 1004,
  ShouldSetUserName = 1005,
  ShouldSetUserEmail = 1006
}

const customErrorCodeMessages: ErrorCodeMessage = {
  ...gitCustomErrorCodeMessage
};

const { errorCodeEnum, errorCodeMessages } = createErrorCodeMessages(
  CustomErrorCode,
  customErrorCodeMessages,
);

const logger = new Logger();
CustomError.configure(errorCodeMessages);
Logger.configure(vscode.window, "Test Channel");
const logger = Logger.getInstance();
  1. Start logging messages using the available log levels:
logger.debug("This is a debug message");
logger.info("This is an info message");
logger.warn("This is a warning message");
logger.error("This is an error message");

logger.handleError(new CustomError(errorCodeEnum.GitNotInit, error));
logger.throw(new CustomError(errorCodeEnum.GitNotInit, error));
  1. View the logged messages in the Visual Studio Code output panel. Open the output panel by going to View -> Output or by pressing Ctrl+Shift+U.

For more information on the available methods and options, please refer to the API documentation.

License

This project is licensed under the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @ygqygq2/vscode-log

Weekly Downloads

0

Version

0.0.3

License

MIT

Unpacked Size

43.2 kB

Total Files

30

Last publish

Collaborators

  • ygqygq2