@epegzz/winston-dev-console

中文文档
1.3.4发布于 2022/03/24MITTypeScriptCommonJS近 30 天下载 6.8万

Winston@3 console format aimed to improve development UX

原始使用文档
文档目录13 节
  1. Demo
  2. Real world screenshot:
  3. Install
  4. Usage TypeScript
  5. Usage JavaScript
  6. API
  7. winstonDevConsole.format(options)
  8. options
  9. options.inspectOptions
  10. options.basePath
  11. options.addLineSeparation
  12. options.showTimestamps
  13. Acknowledgements

winston-dev-console

A Winston@3 console format for development (based on winston-console-format) that aims to improve NodeJS development UX by

  • adding the source of the logging statement to the log output
  • optimizing readability of each log statement through log statement separation, output colorization and arg pretty printing

Demo

Real world screenshot:

Install

npm install winston @epegzz/winston-dev-console

or

yarn add winston @epegzz/winston-dev-console

Usage TypeScript

import { createLogger, format, transports } from "winston";
import winstonDevConsole from "@epegzz/winston-dev-console";
import util from "util";

let log = createLogger({
  level: "silly", // or use process.env.LOG_LEVEL
});

// Note: You probably only want to use winstonDevConsole during development
log = winstonDevConsole.init(log);
log.add(
  winstonDevConsole.transport({
    showTimestamps: false,
    addLineSeparation: true,
  })
);

log.silly("Logging initialized");
log.debug("Debug an object", { make: "Ford", model: "Mustang", year: 1969 });
log.verbose("Returned value", { value: util.format });
log.info("Information", {
  options: ["Lorem ipsum", "dolor sit amet"],
  values: ["Donec augue eros, ultrices."],
});
log.warn("Warning");
log.error(new Error("Unexpected error"));

Usage JavaScript

const { createLogger, format, transports } = require("winston");
const winstonDevConsole = require("@epegzz/winston-dev-console").default;
const util = require("util");

let log = createLogger({
  level: "silly", // or use process.env.LOG_LEVEL
});

// Note: You probably only want to use winstonDevConsole during development
log = winstonDevConsole.init(log);
log.add(
  winstonDevConsole.transport({
    showTimestamps: false,
    addLineSeparation: true,
  })
);

log.silly("Logging initialized");
log.debug("Debug an object", { make: "Ford", model: "Mustang", year: 1969 });
log.verbose("Returned value", { value: util.format });
log.info("Information", {
  options: ["Lorem ipsum", "dolor sit amet"],
  values: ["Donec augue eros, ultrices."],
});
log.warn("Warning");
log.error(new Error("Unexpected error"));

API

winstonDevConsole.format(options)

options

Configuration object.

Type: DevConsoleFormatOptions

options.inspectOptions

util.inspect() configuration object.

Type: Object

options.basePath

Used to remove the base path of the project when showing the file path of the log statement. By default anything in the path before (and including) the src folder will be removed.

Type: String

options.addLineSeparation

Wheather or not to separate each log statement with a blank line.

Type: Boolean
Default: true

options.showTimestamps

Wheather or not to show timestamps
During development the timestamps are usually more noise then helpful, therefore disabled by default.

Type: Boolean
Default: false

Acknowledgements

This project is inspired by and partly shamelessly copied from winston-console-format

版本与发布记录

@epegzz/winston-dev-console 共发布 9 个版本,首次发布于 2021/04/05;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.3.4latest2022/03/244 年前
1.3.32021/11/234 年前
1.3.22021/11/234 年前
1.3.12021/11/234 年前
1.2.12021/04/265 年前
1.2.02021/04/265 年前

关于 @epegzz/winston-dev-console 的常见问题

@epegzz/winston-dev-console 是什么?

Winston@3 console format aimed to improve development UX

如何安装 @epegzz/winston-dev-console?

在项目目录运行 npm install @epegzz/winston-dev-console,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:winston(^3.x)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@epegzz/winston-dev-console 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@epegzz/winston-dev-console 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@epegzz/winston-dev-console 可以商用吗?

@epegzz/winston-dev-console 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@epegzz/winston-dev-console 的下载量有多少?

根据 npm 官方下载统计,@epegzz/winston-dev-console 在 2026/10/14 – 2026/11/12 这 30 天内被下载 68,017 次,日均约 2,267 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@epegzz/winston-dev-console 还在维护吗?

最新版本 1.3.4 发布于 2022/03/24(4 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/04/05。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。