Registry / devops / winston-dev-format

winston-dev-format

JSON →
library0.2.1jsnpmunverified

A pretty, human-readable log formatter for Winston, designed for local development. Version 0.2.1 is the latest stable release, with no frequent updates. It formats log messages using Node's util.format, making complex objects readable, in contrast to JSON formatting used in production. Requires Winston >=3.

npm install winston-dev-format
INSTALL
IMPORT
SIG · WINSTON-DEV-FORMAT
W
winston-dev-format
devopsjavascriptv0.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default (function returned by require)
const devFormat = require('winston-dev-format');
import devFormat from 'winston-dev-format';
Package does not provide ESM exports; use CommonJS require.
default (via import with default export)
import devFormat from 'winston-dev-format';
If using ESM, this package may need a default import shim; but it's safer to use require.
N/A - named exports
const devFormat = require('winston-dev-format');
const { devFormat } = require('winston-dev-format');
Only default export; destructuring will result in undefined.

Creates a winston logger using devFormat for pretty development logs, switching to JSON in production.

const { createLogger, format, transports } = require('winston'); const devFormat = require('winston-dev-format'); const isProduction = process.env.NODE_ENV === 'production'; const logger = createLogger({ format: isProduction ? format.json() : format.combine(format.colorize(), devFormat()), transports: [new transports.Console()], }); logger.info('Some things', { timestamp: new Date(), nested: { some: { complex: 'object', with: [1, 'array'] } }, 'and then': 'a\nmulti\nline\nstring', func: function hello() {}, }); logger.warn('It is pitch black. You are likely to be eaten by a grue.'); logger.error('Unexpected monkeys', { result: new Error('HTTP 500') });
Debug
Known issues
gotchaThe package only provides a CommonJS module; using ES import may fail without proper bundler configuration.
fix
Use require() or configure your bundler to handle CommonJS.
affects: >=0.1.0
gotchaRequires winston >=3. Using with older winston versions may cause incompatibility.
fix
Ensure winston is version 3 or higher.
affects: >=0.1.0
gotchaThe function returned by require('winston-dev-format') must be called (e.g., devFormat()) to produce a format; passing it directly to format.combine will fail.
fix
Always invoke devFormat() when using in format.combine.
affects: >=0.1.0
Errors
Common errors & fixes
TypeError: devFormat is not a function
The imported value is the format function itself, not a format object. It needs to be called.
fix
Use devFormat() instead of devFormat.
Error: Cannot find module 'winston-dev-format'
Package not installed or required from wrong path.
fix
Run 'npm install winston-dev-format' and ensure the require path is correct.
TypeError: format.combine is not a function
Incorrect import of winston format utilities.
fix
Use const { format } = require('winston'); or import { format } from 'winston';
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
winstonrequiredpeer dependency; this is a custom format for winston, requires winston >=3
Agent activity
6 hits · last 30 days
node
6
Resources
winston-dev-format — npm install winston-dev-format · libregistry