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

@tc-libs/logger

v3.9.0

Published

Wrapper NestJS su `winston` con supporto opzionale a notifiche Telegram.

Readme

@tc-libs/logger

Wrapper NestJS su winston con supporto opzionale a notifiche Telegram.

Il package espone un LoggerModule configurabile e una LogFactory che crea logger contestualizzati. Ogni logger scrive sempre su console; se abilitato, inoltra anche messaggi a Telegram.

Registrazione del modulo

Configurazione sincrona

import { LoggerModule } from '@tc-libs/logger';

LoggerModule.register(
  {
    telegram: {
      enabled: true,
      chatId: process.env.LOG_TELEGRAM_CHAT_ID!,
      apiToken: process.env.LOG_TELEGRAM_BOT_TOKEN!,
    },
  },
  true,
);

Configurazione asincrona

LoggerModule.registerAsync(
  {
    imports: [ConfigModule],
    inject: [ConfigService],
    useFactory: async (configService: ConfigService) => ({
      telegram: {
        enabled: configService.get('LOG_TELEGRAM_ENABLED') === 'true',
        chatId: configService.getOrThrow<string>('LOG_TELEGRAM_CHAT_ID'),
        apiToken: configService.getOrThrow<string>('LOG_TELEGRAM_BOT_TOKEN'),
      },
    }),
  },
  true,
);

Come si usa

Inietta LogFactory e crea un logger con un contesto leggibile:

import { Injectable } from '@nestjs/common';
import { LogFactory } from '@tc-libs/logger';

@Injectable()
export class UserService {
  private readonly logger = this.logFactory.createLogger('UserService');

  constructor(private readonly logFactory: LogFactory) {}

  run() {
    this.logger.log('Start processing');
    this.logger.warn('Unexpected condition');
    this.logger.error(new Error('Failure'));
  }
}

API del logger

Il logger creato implementa ITcLogService, che estende LoggerService Nest con metodi aggiuntivi:

logger.log(message);
logger.error(message);
logger.warn(message);
logger.debug(message);
logger.verbose(message);

logger.notifyLog(message);
logger.notifyInfo(message);
logger.notifyWarn(message);
logger.notifyError(message);

Differenza pratica:

  • log, warn, error, debug, verbose: scrivono su console
  • notify*: scrivono su console e, se Telegram e abilitato, inviano anche la notifica al bot

Cosa fa internamente

  • usa winston per il logging console con timestamp, contesto e metadata
  • serializza oggetti/errori in modo leggibile
  • usa un transport custom TelegramTransport per inviare messaggi HTML tramite telegraf

Quando usarlo

Usa questo package quando vuoi:

  • avere un logger consistente tra piu package Nest
  • creare logger per contesto senza configurare winston in ogni modulo
  • ricevere alert operativi su Telegram per errori o eventi importanti

Note operative

  • Se telegram.enabled e false, il logger continua a funzionare normalmente su console.
  • Anche con enabled: true, l'invio Telegram parte solo se chatId e valorizzato.
  • notifyError e utile per errori operativi da segnalare fuori dai log locali.

Export pubblici

import {
  ITcLogService,
  LogFactory,
  LoggerModule,
} from '@tc-libs/logger';

Sviluppo

nx build logger
nx test logger