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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tresdoce/nestjs-logger

v0.0.2

Published

NestJS logging module

Downloads

3

Readme

Esta dependencia está pensada para ser utilizada en NestJs Starter, o cualquier proyecto que utilice una configuración centralizada, siguiendo la misma arquitectura del starter.

Glosario


📝 Requerimientos básicos

🛠️ Instalar dependencia

npm install @tresdoce/nestjs-logger

⚙️ Configuración

Para utilizar este módulo, es necesario instanciarlo en la creación de la app con su global interceptor y también en el módulo principal.

// ./src/main.ts
import { LoggingInterceptor, LoggingService } from '@tresdoce/nestjs-logger';
import { config } from './config';

async function bootstrap() {
  const app = await NestFactory.create(AppModule, {
    logger: new LoggingService('info', config()),
  });
  ...
  app.useGlobalInterceptors(new LoggingInterceptor(app.get<LoggingService>(LoggingService)));
  ...
}
// ./src/app.module.ts
import { LoggingModule } from '@tresdoce/nestjs-logger';

@Module({
  ...
  imports: [
    ...
    LoggingModule.register(),
    ...
  ],
  ...
})

👨‍💻️ Uso

Para poder hacer uso de algún metódo del servicio que se exporta mediante este módulo, debes inyectar el LoggingService en el constructor del componente donde vas a utilizarlo, definiendo el type como LoggingService.

Logs disponibles: log info error warn debug trace

// ./src/app.controller.ts
import { Inject, Injectable } from '@nestjs/common';
import { LoggingService } from '@tresdoce/nestjs-logger';
...
@Injectable()
export class AppService {
  constructor(
    @Inject(LoggingService) private logger: LoggingService,
  ) {}

  getHello(): string {
    this.logger.log('this is a log');
  }
}

🖥 Logs

Los diferentes formatos de logging según el metódo que estés invocando.

  • Tipo log
this.logger.log('This is a log message');
[1641844177933] INFO (24552 on VDINAME): This is a log message
  • Tipo info
this.logger.info('This is a info message', 'This is an info context');
[1641844177933] INFO (24552 on VDINAME):
    context: "This is an info context"
    msg: {
      "application_name": "nestjs-starter",
      "application_version": "0.0.1",
      "logger_name": "@tresdoce/nestjs-logger",
      "logger_version": "0.0.1",
      "@timestamp": 1646350040866,
      "log_level": "INFO",
      "log_type": "DEFAULT",
      "message": "This is a info message"
    }
  • Tipo error
this.logger.error('This is a error message', 'This is an error context');
[1641844177936] ERROR (24552 on VDINAME):
    context: "This is an error context"
    msg: {
      "application_name": "nestjs-starter",
      "application_version": "0.0.1",
      "logger_name": "@tresdoce/nestjs-logger",
      "logger_version": "0.0.1",
      "@timestamp": 1646350040866,
      "log_level": "ERROR",
      "log_type": "DEFAULT",
      "message": "This is a error message"
      "stack_trace": "This is a error message"
    }
  • Tipo warn
this.logger.warn('This is a warn message', 'This is an warn context');
[1641844177939] WARN (24552 on VDINAME):
    context: "This is an warn context"
    msg: {
      "application_name": "nestjs-starter",
      "application_version": "0.0.1",
      "logger_name": "@tresdoce/nestjs-logger",
      "logger_version": "0.0.1",
      "@timestamp": 1646350040866,
      "log_level": "WARN",
      "log_type": "DEFAULT",
      "message": "This is a warn message"
    }
  • Tipo debug
this.logger.debug('This is a debug message', 'This is an debug context');
[1641844177943] DEBUG (24552 on VDINAME):
    context: "This is an debug context"
    msg: {
      "application_name": "nestjs-starter",
      "application_version": "0.0.1",
      "logger_name": "@tresdoce/nestjs-logger",
      "logger_version": "0.0.1",
      "@timestamp": 1646350040866,
      "log_level": "DEBUG",
      "log_type": "DEFAULT",
      "message": "This is a debug message"
    }
  • Tipo verbose
this.logger.trace('This is a trace message', 'This is an trace context');
[1641844177946] TRACE (24552 on VDINAME):
    context: "This is an trace context"
    msg: {
      "application_name": "nestjs-starter",
      "application_version": "0.0.1",
      "logger_name": "@tresdoce/nestjs-logger",
      "logger_version": "0.0.1",
      "@timestamp": 1646350040866,
      "log_level": "TRACE",
      "log_type": "DEFAULT",
      "message": "This is a trace message"
    }

📤 Commits

Para los mensajes de commits se toma como referencia conventional commits.

<type>[optional scope]: <description>

[optional body]

[optional footer]
  • type: chore, docs, feat, fix, refactor (más comunes)
  • scope: indica la página, componente, funcionalidad
  • description: comienza en minúsculas y no debe superar los 72 caracteres.

📄 Changelog

All notable changes to this package will be documented in Changelog file.