npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@diamir/nestjs-logger

v11.0.2

Published

Nestjs logger based on winston

Readme

nestjs-logger

Description

Custom logger service based on [winston](https://github.com/winstonjs/winston.

Details from winston read-me:



Usage

Construct the WinstonLogger with an optional config during creation of the nest-application:

import { WinstonLogger } from '@diamir/nestjs-logger'

const app = await NestFactory.create(
  ServerModule,
  {
    logger: new WinstonLogger()
  }
)

After initialisation use the nest Logger as usual, to get the customised output.

Options

Available options and their default values.

import { LogLevel, PrettyFormat, transports, WinstonLogger } from '@diamir/nestjs-logger'

new WinstonLogger({
  context: 'WinstonLogger', // override the default context
  logLevel: LogLevel.debug, // set the output level
  traceLogLevel: LogLevel.verbose, // set the output level for stack-trace
  clsService: undefined, // (optional) link to the nestjs-cls service to log request ids
  format: undefined, // (optional) default console transport output format
  transports: [new transports.Console({ format: PrettyFormat })] // set custom winston transports
})

Log-Level

From least to most log output.

| level | |-----------| | none | | error | | warn | | info | | verbose | | debug |

Hint:

  • none sets winston to silent and will not output any logs
  • info is equal to log/Logger.log()

Formats

Predefined custom output formats Default output includes timestamp, context, message

  • PrettyFormat: [2025-09-25T07:09:44.496Z] [info] [SampleService] - Example log-message
  • JsonFormat: {"context":"SampleService","level":"info","message":"Example log-message","splat":[],"timestamp":"2025-09-25T07:19:09.874Z"}

BaseFormat used as base for the custom format.

e.g.

import { BaseFormat, format } from '@diamir/nestjs-logger'

const CustomFormat = format.combine(
  BaseFormat,
  format.ms(),
  format.simple()
)

Transports

By default, the Console transport is used with the format set in the format option or PrettyFormat.

To change the transports, pass a customised array in the options

import { JsonFormat, PrettyFormat, transports, WinstonLogger } from '@diamir/nestjs-logger'

// extend the default logger with a seconds transport
new WinstonLogger({
  transports: [ 
    new transports.Console({ format: PrettyFormat }),
    new transports.File({ format: JsonFormat, file: 'server.logs' })
  ]
})

// override the default logger with new transports
new WinstonLogger({
  transports: [ 
    new transports.File({ format: JsonFormat, file: 'server.logs' }),
    new transports.File({ format: JsonFormat, file: 'server_error.logs', level: 'error' })
  ]
})

ClsService

You can use the nestjs-cls package to include the current request-id in the logs, to see which log belongs to which request.

Fist add the nestjs-cls dependency, next set up the ClsModule in the server/application module and set the generateId option to true

e.g.

ClsModule.forRoot({
  global: true,
  middleware: {
    mount: true,
    generateId: true
  }
})

Finally update the WinstonLogger options to set the clsService like

import { WinstonLogger } from '@diamir/nestjs-logger'
import { ClsServiceManager } from 'nestjs-cls'

new WinstonLogger({
  clsService: ClsServiceManager.getClsService()
})

Migration

To migrate from the old @webundsoehne/nestjs-util to @diamir/nestjs-logger:

  • Change LoggerService class to WinstonLogger
  • manually link the logLevel in the class options (does not pull it via ConfigService any more)
  • update how the clsService is set (drop setClsService, move to class options)

Links