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

@icd-iot-aicf/nestjs-logger

v4.0.2

Published

![Build Status](https://img.shields.io/github/actions/workflow/status/corp-ais/IoT-Common-Framework-AICF-Logging-Nest-JS/ci.yml?branch=main&style=flat-square) ![License](https://img.shields.io/github/license/corp-ais/IoT-Common-Framework-AICF-Logging-Nest

Downloads

2,734

Readme

@icd-iot-aicf/nestjs-logger

Build Status License Version Node

A structured logging and metrics library for NestJS microservices in the ICD IoT platform. It provides automatic request/response logging with team-standard format patterns and a fluent manual logging API — all wired in with a single module import.


Key Features

  • Three log format strategies — switch between AICF, Cloudron, and ESB output shapes via config; each format is fully consistent across all log events.
  • Automatic HTTP & AMQP logging — middleware and interceptors capture inbound/outbound requests, correlation IDs, and timing with microsecond precision out of the box.
  • AsyncLocalStorage context propagation — per-request transaction info, endpoint summaries, and external call metadata flow through the call stack with zero manual threading.
  • Prometheus metrics — built-in HTTP counters and gauges via MetricsModule; extend with MetricsManualService for custom business metrics.
  • Manual logging APICustomLoggerService exposes log(), warn(), error(), debug(), and verbose() with typed action DTOs (HttpAction, DBAction, RabbitMQAction, and more).

Installation

npm install @icd-iot-aicf/nestjs-logger

Peer dependencies — ensure your project has these installed:

npm install @nestjs/common @nestjs/core reflect-metadata

Quick Start

// app.module.ts
import { Module } from '@nestjs/common';
import { AppLogConfigModule, FORMAT_TYPE } from '@icd-iot-aicf/nestjs-logger';

@Module({
  imports: [
    AppLogConfigModule.forRoot({
      format: FORMAT_TYPE.AICF,
      appName: 'my-service',
      componentName: 'api',
    }),
  ],
})
export class AppModule {}
// my.service.ts
import { Injectable } from '@nestjs/common';
import { CustomLoggerService, HttpAction, RESULTS } from '@icd-iot-aicf/nestjs-logger';

@Injectable()
export class MyService {
  constructor(private readonly logger: CustomLoggerService) {}

  async getUser(id: string) {
    this.logger.log('Fetching user', HttpAction.GET({ userId: id }));

    // ... business logic ...

    this.logger.log('User fetched', HttpAction.GET({ result: RESULTS.SUCCESS }));
  }
}

Configuration

| Option | Type | Description | |---|---|---| | format | FORMAT_TYPE | Log output shape: AICF | Cloudron | ESB | | appName | string | Application name written into every log entry | | componentName | string | Sub-component or service layer identifier | | debugMode | DEBUG_MODE | Controls verbosity; defaults to OFF |


Automatic Logging

Register the middleware and interceptors in your module to get zero-config HTTP logging:

// app.module.ts
import {
  MiddlewareConsumer,
  Module,
  NestModule,
} from '@nestjs/common';
import {
  AppLogConfigModule,
  HTTPLogsMiddleware,
  FORMAT_TYPE,
} from '@icd-iot-aicf/nestjs-logger';

@Module({
  imports: [
    AppLogConfigModule.forRoot({ format: FORMAT_TYPE.AICF, appName: 'my-service', componentName: 'api' }),
  ],
})
export class AppModule implements NestModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(HTTPLogsMiddleware).forRoutes('*');
  }
}

Every inbound request will automatically emit structured logs for:

  • Inbound / outbound HTTP with correlation headers (x-ais-orderref, x-origin-session)
  • Timing in microseconds
  • Endpoint-level summary flush on response

Prometheus Metrics

import { MetricsModule } from '@icd-iot-aicf/nestjs-logger';

MetricsModule.forRoot({ path: '/metrics', defaultMetrics: true })

Custom metrics via MetricsManualService:

this.metrics.increment('orders_created_total', { status: 'success' });

Log Action Types

| Class | Methods | |---|---| | HttpAction | .GET() .POST() .PUT() .PATCH() .DELETE() | | DBAction | .CREATE() .READ() .UPDATE() .REMOVE() | | RabbitMQAction | .PRODUCE() .CONSUME() | | KafkaAction | .PRODUCE() .CONSUME() | | LogicAction | .FUNCTION() .CHECKPOINT() | | ExceptionAction | .LOG() |

For a full field-level reference of every key emitted in each log format (AICF, Cloudron), see docs/FORMAT_REFERENCE.md.


Upgrading to v4

Before upgrading, capture a snapshot of your current v3 log output so you can detect any unintended format changes after the upgrade.

Step 1 — While still on v3, copy and run the baseline script:

cp node_modules/@icd-iot-aicf/nestjs-logger/migration/log-snapshot-v3.e2e-spec.ts \
   test/log-snapshot.e2e-spec.ts

npx jest --config ./test/jest-e2e.json --testPathPatterns=log-snapshot --updateSnapshot

git add test/__snapshots__/log-snapshot.e2e-spec.ts.snap
git commit -m "test: capture v3 log format baseline snapshot"

Step 2 — Upgrade the package and apply breaking changes (see v3-to-v4-migration.md in the repo).

Step 3 — Compare v4 output against your baseline:

npx jest --config ./test/jest-e2e.json --testPathPatterns=log-snapshot

Any format differences are shown as a Jest diff. If they are expected (renamed fields from the breaking-changes table), accept them with --updateSnapshot.

The migration guide (v3-to-v4-migration.md) in the library repo contains the full step-by-step breakdown including a list of all breaking changes and renamed fields.


Benchmarks

Performance benchmarks coming soon.

Planned metrics: log throughput (events/sec), middleware overhead (ms/req), memory footprint under load.


License

MIT © ICD IoT Platform Team