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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@nxtoai/aag

v1.0.1

Published

A flexible logging service for NestJS applications

Readme

AAG - Logging Service for NxtoAI APPLICATIONS

A powerful and flexible logging service for NxtoAI NestJS applications that provides structured logging with automatic formatting, timestamps, and labels.

Installation

npm install @nxtoai/aag

Configuration

Import the AagModule in your application module:

import { Module } from '@nestjs/common';
import { AagModule } from '@nxtoai/aag';

@Module({
  imports: [
    AagModule.forRoot({
      environment: 'development', // Debug logs enabled on test/dev environments ; only info logs for prod environment 
      debugUsers: ['user1', 'user2'] // Optional: List of debug users, if passed debug logs on production environment will be available for these set of users
    }),
  ],
})
export class AppModule {}

Usage

Inject the AagService into your service:

import { Injectable } from '@nestjs/common';
import { AagService } from '@nxtoai/aag';

@Injectable()
export class UserService {
  constructor(private readonly aag: AagService) {}

  async createUser(userData: any) {
    try {
      this.aag.debug('Creating new user with email :', { email: userData.email });
      // ... user creation logic
      this.aag.info('User created successfully with user id : ', { userId: newUser.id });
    } catch (error) {
      this.aag.error('Failed to create user due to : ', error.stack);
      throw error;
    }
  }
}

Logging Methods

debug(message: string, data?: any)

Logs debug level messages. Useful for development and troubleshooting.

this.aag.debug('Processing request', { requestId: '123' });

info(message: string, data?: any)

Logs informational messages. Used for general application flow.

this.aag.info('User logged in', { userId: '123' });

warn(message: string, data?: any)

Logs warning messages. Used for potentially harmful situations.

this.aag.warn('Rate limit approaching', { userId: '123', currentRate: 95 });

error(message: string, stack?: string)

Logs error messages. Used for error conditions.

try {
  // ... some code
} catch (error) {
  this.aag.error('Failed to process payment', error.stack);
}

Features

Automatic Formatting

  • JSON formatting for structured logging
  • Automatic timestamp addition
  • Application name and environment labeling
  • Stack trace formatting for errors

Debug Users

The service includes a debug users feature that allows you to bypass certain validations or restrictions for specific users. This is particularly useful during development and testing.

To use debug users:

  1. Configure debug users in your environment for whome debug logs will be available on prod environment:
// In your configuration
{
  debugUsers: ['user1', 'user2'] // List of user IDs that are considered debug users
}
  1. Check if a user is enabled for printing debug logs:
// In your service
if (this.isDebugUser(userId)) {
  // Skip certain validations or restrictions
  // For example, bypass OTP verification
}

Best Practices

  1. Use appropriate log levels:

    • debug: Detailed information for debugging
    • info: General operational information
    • warn: Warning messages for potentially harmful situations
    • error: Error conditions that need attention
  2. Include relevant context:

    this.aag.info('User action completed', {
      userId: '123',
      action: 'profile_update',
      timestamp: new Date().toISOString()
    });
  3. Always include stack traces for errors:

    try {
      // ... some code
    } catch (error) {
      this.aag.error('Operation failed', error.stack);
    }

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.