# winston-console-format

> Winston@3 console formatter for debugging purposes using util.inspect().

Latest version **1.0.8** (published 2020-08-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install winston-console-format
pnpm add winston-console-format
yarn add winston-console-format
bun add winston-console-format
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2020-08-04 |
| First published | 2019-05-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 224.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 31 |
| Author | Aldo Armiento |
| Maintainers | armiento |
| Keywords | winston, console, format, formatter, inspect, debug, debugging |

## Links

- npm: https://www.npmjs.com/package/winston-console-format
- Repository: https://github.com/duccio/winston-console-format
- Issues: https://github.com/duccio/winston-console-format/issues
- npm.io page: https://npm.io/package/winston-console-format

## Dependencies (3)

- [colors](https://npm.io/package/colors.md) ^1.4.0
- [logform](https://npm.io/package/logform.md) ^2.2.0
- [triple-beam](https://npm.io/package/triple-beam.md) ^1.3.0

## Alternatives

- [cli-color](https://npm.io/package/cli-color.md) — 3.4M weekly downloads
- [log](https://npm.io/package/log.md) — 1.3M weekly downloads
- [logstash-client](https://npm.io/package/logstash-client.md) — 4.5K weekly downloads
- [@nocobase/plugin-logger](https://npm.io/package/@nocobase/plugin-logger.md) — 2.0K weekly downloads
- [child-process-debug](https://npm.io/package/child-process-debug.md) — 695 weekly downloads

## Recent versions

- 1.0.8 (latest) — 2020-08-04
- 1.0.7 — 2020-08-04
- 1.0.6 — 2020-08-04
- 1.0.5 — 2019-06-04
- 1.0.4 — 2019-05-30
- 1.0.3 — 2019-05-27
- 1.0.2 — 2019-05-27
- 1.0.1 — 2019-05-27
- 1.0.0 — 2019-05-26

## README

# Winston@3 console format

[![Version npm](https://img.shields.io/npm/v/winston-console-format.svg?style=flat-square)](https://www.npmjs.com/package/winston-console-format)
[![npm Downloads](https://img.shields.io/npm/dm/winston-console-format.svg?style=flat-square)](https://npmcharts.com/compare/winston-console-format?minimal=true)
[![Dependencies](https://img.shields.io/david/duccio/winston-console-format.svg?style=flat-square)](https://david-dm.org/duccio/winston-console-format)
[![Build Status](https://img.shields.io/travis/duccio/winston-console-format/master.svg?style=flat-square)](https://travis-ci.com/duccio/winston-console-format)
[![Codecov](https://img.shields.io/codecov/c/github/duccio/winston-console-format.svg)](https://codecov.io/github/duccio/winston-console-format)
[![Known Vulnerabilities](https://snyk.io/test/github/duccio/winston-console-format/badge.svg)](https://snyk.io/test/github/duccio/winston-console-format)

Winston@3 console formatter for debugging purposes using util.inspect().

## Demo

![](demo.png)

## Install

```bash
npm install winston-console-format
```

## Usage TypeScript

```typescript
import { createLogger, format, transports } from "winston";
import { consoleFormat } from "winston-console-format";
import util from "util";

const logger = createLogger({
  level: "silly",
  format: format.combine(
    format.timestamp(),
    format.ms(),
    format.errors({ stack: true }),
    format.splat(),
    format.json()
  ),
  defaultMeta: { service: "Test" },
  transports: [
    new transports.Console({
      format: format.combine(
        format.colorize({ all: true }),
        format.padLevels(),
        consoleFormat({
          showMeta: true,
          metaStrip: ["timestamp", "service"],
          inspectOptions: {
            depth: Infinity,
            colors: true,
            maxArrayLength: Infinity,
            breakLength: 120,
            compact: Infinity,
          },
        })
      ),
    }),
  ],
});

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

## Usage JavaScript

```js
const { createLogger, format, transports } = require("winston");
const { consoleFormat } = require("winston-console-format");
const util = require("util");

const logger = createLogger({
  level: "silly",
  format: format.combine(
    format.timestamp(),
    format.ms(),
    format.errors({ stack: true }),
    format.splat(),
    format.json()
  ),
  defaultMeta: { service: "Test" },
  transports: [
    new transports.Console({
      format: format.combine(
        format.colorize({ all: true }),
        format.padLevels(),
        consoleFormat({
          showMeta: true,
          metaStrip: ["timestamp", "service"],
          inspectOptions: {
            depth: Infinity,
            colors: true,
            maxArrayLength: Infinity,
            breakLength: 120,
            compact: Infinity,
          },
        })
      ),
    }),
  ],
});

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

## API

## consoleFormat(options)

### options

Configuration object.<br><br>Type: `ConsoleFormatOptions`

### options.showMeta

Show/hide meta object(s).<br><br> Type: `boolean`<br> Default: `true`

### options.metaStrip

Array of meta-object properties to hide.<br><br> Type: `string[]`<br> Default: `[]`

### options.inspectOptions

`util.inspect()` configuration object.<br><br> Type: `Object`<br> Default: [Node util.inspect(object[, options])](https://nodejs.org/api/util.html#util_util_inspect_object_options)

---
_Source: https://npm.io/package/winston-console-format · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
