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

@designli/be-logger

v1.0.4

Published

Designli backend standard logger package for logging messages in a consistent format across the application

Downloads

23

Readme

@designli/be-logger

Standard logger package for Designli backend applications. It provides a consistent logging interface with support for multiple adapters (Console, JSON, Sentry) and automatic context tracking using nestjs-cls.

It is designed to work seamlessly with NestJS but also supports a detached mode for standalone scripts or non-NestJS contexts.

Installation

npm install @designli/be-logger

Usage

NestJS Setup

  1. Register the Module: Import DesignliLoggerModule in your AppModule.
// interceptors.providers.ts
import { APP_INTERCEPTOR } from '@nestjs/core';
import { AuthContextInterceptor, AfterRequestInterceptor } from '@designli/be-logger';

export const interceptorsProviders = [
  {
    provide: APP_INTERCEPTOR,
    useClass: AuthContextInterceptor,
  },
  {
    provide: APP_INTERCEPTOR,
    useClass: AfterRequestInterceptor,
  },
];

// app.module.ts
import { Module } from '@nestjs/common';
import { DesignliLoggerModule, NestLoggerAdapter } from '@designli/be-logger';
import { APP_INTERCEPTOR } from '@nestjs/core';

@Module({
  imports: [
    DesignliLoggerModule.forRoot({
      // Configuration options (see Configuration section)
      // available adapters: 'console', 'json', 'sentry'
      adapters: process.env.APP_ENV === 'local' ? ['console'] : ['json', 'sentry'],
    }),
  ],
  providers: [...interceptorsProviders, NestLoggerAdapter],
})
export class AppModule {}
  1. Use as Main Logger: Update your main.ts to use NestLoggerAdapter.
// main.ts
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { NestLoggerAdapter } from '@designli/be-logger';

async function bootstrap() {
  const app = await NestFactory.create(AppModule);
  
  // Use the custom logger
  app.useLogger(app.get(NestLoggerAdapter));
  
  await app.listen(3000);
}
bootstrap();

Usage in Services

Inject CompositeLogger to create a logger instance for your service.

import { Injectable } from '@nestjs/common';
import { DesignliLogger, CompositeLogger } from '@designli/be-logger';

@Injectable()
export class LoggerTestService {
  private readonly logger: DesignliLogger;

  constructor(private readonly loggerProvider: CompositeLogger) {
    this.logger = this.loggerProvider.new(LoggerTestService);
  }

  test() {
    this.logger.log('This is an info message', { meta: { test: 'test' } });
    
    // This will also log an error message with stack trace
    throw new Error('This is an error message');
  }
}

Detached Usage (Non-NestJS)

You can use the logger without the NestJS dependency injection system, which is useful for scripts or libraries.

import { CompositeLogger } from '@designli/be-logger';

// Create a detached logger instance
const loggerProvider = CompositeLogger.detached();
const logger = loggerProvider.new('MyScript');

logger.log('Starting script...');
logger.warn('This is a warning');

Configuration

The DesignliLoggerModule.forRoot() method accepts a configuration object.

Example Configuration

DesignliLoggerModule.forRoot({
  adapters: process.env.APP_ENV === 'local' ? ['sentry', 'console'] : ['json'],
  adaptersOptions: {
    console: {
      colorize: true,
      contextInfo: true,
    },
    json: {
      prettyPrint: true,
    },
  },
})

Environment Variables

The package uses the following environment variables:

| Variable | Description | Default | | ---------------- | --------------------------------------------------------------------------------------------------------------- | --------------------- | | LOG_TRACE_RATE | Probability (0-1) of logging a trace message when a request finalizes (used in AfterRequestInterceptor). | 0.1 (10%) | | SENTRY_DSN | The Data Source Name (DSN) for Sentry integration. | undefined | | LOG_LEVEL | Minimum log level enabled. Levels: trace < debug < info < warn < error < fatal. | trace (all enabled) | | LOG_LEVELS | Comma-separated list of explicitly enabled log levels (e.g., error,fatal). Overrides/supplements LOG_LEVEL. | undefined |