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

@landsoftco/customlogger

v1.0.2

Published

Librería para escribir logs en Wingo con estructura propia

Downloads

137

Readme

Bienvenido a Custom Logger!

Librería para escribir Logs customizado.

Instalar e importar

Para realizar la importación de la librería se debe hacer configurando un alias al momento de instalar, ya que la librería al pertenecer a una organización, tiene en su nombre un scope, en este caso @landsoftco, y al momento de importar la librería con este scope, Typescript cree que estamos importando un paquete Types y no un paquete normal.

Para corregir el problema, instalamos generando un alias de la siguiente manera:

npm i customlogger@npm:@landsoftco/customlogger

Una vez instalada, se debe importar y configurar de la siguiente manera.

import Logger from '@landsoftco/customlogger';

//en caso de que this se encuentre indefinido. Instanciamos fuera de la clase
const logger = new Logger(isPdn);

//en caso de que tengamos acceso a this. Definimos dentro de la clase, e instanciamos en el constructor
private logger: Logger; //definicion
this.logger = new Logger(isPdn); //instancia

isPdn es la variable de tipo Boolean que indica si estamos es un ambiente productivo o no, para determinar el nivel de log que se imprime. Si está no es enviada, por defecto se imprime el nivel info

Funciones que contiene

this.logger.info('Mi mensaje informativo') -> 2022-09-04 13:19:01 - info - [indexTest.js]: info
this.logger.error('Mi mensaje de error') -> 2022-09-04 13:19:01 - error - [indexTest.js]: error
this.logger.debug('Mi mensaje de debug') -> 2022-09-04 13:19:01 - warn - [indexTest.js]: warn
this.logger.warn('Mi mensaje de warn') -> 2022-09-04 13:19:01 - debug - [indexTest.js]: debug

En caso que se requiera enviar en el log un objeto, para evitar que en la consola se imprima [Object, Object] se debe hacer de la siguiente manera utilizando la función JSON.stringify().

this.logger.info(`Mi mensaje con objeto ${JSON.stringify(myObjeto)}`) -> 2022-09-04 13:40:13 - info - [indexTest.js]: Mi mensaje con objeto {"value":"hola","name":"mundo"}